We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 42abc74 commit c5bb3c2Copy full SHA for c5bb3c2
tibert/bertcoref.py
@@ -210,7 +210,14 @@ def from_wpieced_to_tokenized(
210
for mention in chain:
211
212
new_start_idx = wp_to_token[mention.start_idx]
213
- new_end_idx = wp_to_token[mention.end_idx - 1] + 1
+ new_end_idx = wp_to_token[mention.end_idx - 1]
214
+ # NOTE: this happens in case the model has predicted
215
+ # an erroneous mention such as '[CLS]' or '[SEP]'. In
216
+ # that case, we simply ignore the mention.
217
+ if new_start_idx is None or new_end_idx is None:
218
+ continue
219
+ new_end_idx += 1
220
+
221
new_mention = Mention(
222
tokens[new_start_idx:new_end_idx],
223
new_start_idx,
0 commit comments