Correct max position for SQUAD and TFDS

This commit is contained in:
Lysandre committed 2019-12-19 12:25:55 -05:00
1 parent 62c1fc3c1e
commit a1f1dce0ae
1 file changed
+3 -1
+3 -1
View File
@@ -571,7 +571,9 @@ class SquadExample(object):
# Start end end positions only has a value during evaluation.
if start_position_character is not None and not is_impossible:
self.start_position = char_to_word_offset[start_position_character]
self.end_position = char_to_word_offset[start_position_character + len(answer_text) - 1]
self.end_position = char_to_word_offset[
min(start_position_character + len(answer_text) - 1, len(char_to_word_offset) - 1)
]
class SquadFeatures(object):