Skip to content

Commit

Permalink
Update sktalk/corpus/conversation.py
Browse files Browse the repository at this point in the history
Co-authored-by: Ji Qi <[email protected]>
  • Loading branch information
bvreede and jiqicn authored Nov 29, 2023
1 parent 9229e8a commit 574a729
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions sktalk/corpus/conversation.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,11 +92,9 @@ def _subconversation_by_index(self,
raise IndexError("Index out of range")
if after is None:
after = before
if index - before < 0:
before = index
if index + after + 1 > len(self._utterances):
after = len(self._utterances) - index - 1
returned_utterances = self._utterances[index-before:index+after+1]
left_bound = max(index-before, 0)
right_bound = min(index + after + 1, len(self._utterances))
returned_utterances = self._utterances[left_bound:right_bound]
return Conversation(utterances=returned_utterances, suppress_warnings=True)

def _subconversation_by_time(self,
Expand Down

0 comments on commit 574a729

Please sign in to comment.