Skip to content

Commit

Permalink
Merge pull request #135 from ArneBinder/fix_text_based_document_to_to…
Browse files Browse the repository at this point in the history
…ken_based

fix `token_based_document_to_text_based` / `text_based_document_to_token_based` for dependent predicted annotations
  • Loading branch information
ArneBinder authored Oct 21, 2024
2 parents 86146b6 + a3ebe6c commit 1739476
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/pie_modules/document/processing/tokenization.py
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,9 @@ def char_to_token(char_idx: int) -> Optional[int]:
)
if added_annotations is not None:
for layer_name, orig_ann_id2new_ann in added_annotations_from_remaining_layers.items():
ann_id2ann = {ann._id: ann for ann in doc[layer_name]}
ann_id2ann = {
ann._id: ann for ann in list(doc[layer_name]) + list(doc[layer_name].predictions)
}
annotation_mapping = {
ann_id2ann[orig_ann_id]: new_ann
for orig_ann_id, new_ann in orig_ann_id2new_ann.items()
Expand Down Expand Up @@ -385,7 +387,9 @@ def token_based_document_to_text_based(
)
if added_annotations is not None:
for layer_name, orig_ann_id2new_ann in added_annotations_from_remaining_layers.items():
ann_id2ann = {ann._id: ann for ann in doc[layer_name]}
ann_id2ann = {
ann._id: ann for ann in list(doc[layer_name]) + list(doc[layer_name].predictions)
}
annotation_mapping = {
ann_id2ann[orig_ann_id]: new_ann
for orig_ann_id, new_ann in orig_ann_id2new_ann.items()
Expand Down

0 comments on commit 1739476

Please sign in to comment.