Skip to content

Commit

Permalink
minor improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
ArneBinder committed Feb 7, 2024
1 parent a704b8a commit fcb47f7
Showing 1 changed file with 2 additions and 8 deletions.
10 changes: 2 additions & 8 deletions src/serializer/brat.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,34 +111,28 @@ def serialize_annotations(
serialized_labeled_spans_gold, span2id = serialize_labeled_spans(
entities=labeled_span_layer,
label_prefix=gold_label_prefix,
first_span_id=0,
)
serialized_labeled_spans.extend(serialized_labeled_spans_gold)
serialized_binary_relations_gold = serialize_binary_relations(
relations=binary_relation_layer,
span2id=span2id,
label_prefix=gold_label_prefix,
first_relation_id=0,
)
serialized_binary_relations.extend(serialized_binary_relations_gold)
last_span_id = len(serialized_labeled_spans_gold)
last_rel_id = len(serialized_binary_relations_gold)
else:
last_span_id = 0
last_rel_id = 0
span2id = {}
serialized_labeled_spans_pred, span2id_pred = serialize_labeled_spans(
entities=labeled_span_layer.predictions,
label_prefix=prediction_label_prefix,
first_span_id=last_span_id,
first_span_id=len(serialized_labeled_spans),
)
span2id.update(span2id_pred)
serialized_labeled_spans.extend(serialized_labeled_spans_pred)
serialized_binary_relations_pred = serialize_binary_relations(
relations=binary_relation_layer.predictions,
span2id=span2id,
label_prefix=prediction_label_prefix,
first_relation_id=last_rel_id,
first_relation_id=len(serialized_binary_relations),
)
serialized_binary_relations.extend(serialized_binary_relations_pred)
return serialized_labeled_spans + serialized_binary_relations
Expand Down

0 comments on commit fcb47f7

Please sign in to comment.