Skip to content

Commit

Permalink
removed try error case
Browse files Browse the repository at this point in the history
  • Loading branch information
Xing Wang committed Jan 15, 2024
1 parent 2fe2fd0 commit fdb5ec9
Showing 1 changed file with 7 additions and 12 deletions.
19 changes: 7 additions & 12 deletions flair/models/sequence_tagger_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -1210,18 +1210,13 @@ def apply_predictions(
new_labels = augmented_sentence.get_labels(source_annotation_layer)
len_task_prompt = len(self.task_prompt)

try:
for label in new_labels:
if label.data_point.tokens[0].idx - len_task_prompt - 1 < 0:
continue
orig_span = original_sentence[
label.data_point.tokens[0].idx - len_task_prompt - 1 : label.data_point.tokens[-1].idx
- len_task_prompt
]
orig_span.add_label(target_annotation_layer, label.value, label.score)
except IndexError:
for token in original_sentence:
print(token)
for label in new_labels:
if label.data_point.tokens[0].idx - len_task_prompt - 1 < 0:
continue
orig_span = original_sentence[
label.data_point.tokens[0].idx - len_task_prompt - 1 : label.data_point.tokens[-1].idx - len_task_prompt
]
orig_span.add_label(target_annotation_layer, label.value, label.score)

def _build_tag_prompt_prefix(self, entity_types: List[str]) -> List[str]:
if len(self.entity_types) == 1:
Expand Down

0 comments on commit fdb5ec9

Please sign in to comment.