Skip to content

Commit 24328d9

Browse files
committed
fix a few indexing issues
1 parent 003fd71 commit 24328d9

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

tibert/bertcoref.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ def from_wpieced_to_tokenized(
190190
new_chain = []
191191
for mention in chain:
192192
new_start_idx = wp_to_token[mention.start_idx]
193-
new_end_idx = wp_to_token[mention.end_idx]
193+
new_end_idx = wp_to_token[mention.end_idx - 1] + 1
194194
new_chain.append(
195195
Mention(
196196
tokens[new_start_idx:new_end_idx],
@@ -657,7 +657,7 @@ def coreference_documents(
657657
top_antecedent_idx = int(antecedents_idx[b_i][m_j].item())
658658

659659
span_mention = Mention(
660-
tokens[b_i][span_coords[0] : span_coords[1] + 1],
660+
tokens[b_i][span_coords[0] : span_coords[1]],
661661
span_coords[0],
662662
span_coords[1],
663663
)
@@ -676,7 +676,7 @@ def coreference_documents(
676676
antecedent_coords = spans_idx[antecedent_idx]
677677

678678
antecedent_mention = Mention(
679-
tokens[b_i][antecedent_coords[0] : antecedent_coords[1] + 1],
679+
tokens[b_i][antecedent_coords[0] : antecedent_coords[1]],
680680
antecedent_coords[0],
681681
antecedent_coords[1],
682682
)

0 commit comments

Comments
 (0)