Skip to content

Commit

Permalink
add reversed relation labels to labels_per_layer in _prepare()
Browse files Browse the repository at this point in the history
  • Loading branch information
ArneBinder committed Nov 13, 2024
1 parent 7bd6da2 commit 1932b18
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/pie_modules/taskmodules/pointer_network_for_end2end_re.py
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,17 @@ def _prepare(self, documents: Sequence[DocumentType]) -> None:
ac.label for ac in doc[layer_name] if ac.label not in exclude_labels
)

if self.add_reversed_relations:
for rel_label in set(labels[self.relation_layer_name]):
reversed_label = rel_label
if rel_label not in self.symmetric_relations:
reversed_label += self.REVERSED_RELATION_LABEL_SUFFIX
if reversed_label in labels[self.relation_layer_name]:
raise ValueError(
f"reversed relation label {reversed_label} already exists in relation layer labels"
)
labels[self.relation_layer_name].add(reversed_label)

self.labels_per_layer = {
# sort labels to ensure deterministic order
layer_name: sorted(labels)
Expand Down

0 comments on commit 1932b18

Please sign in to comment.