Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG-FIX] Fixed initialization of the RelationSentence class #3

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -385,7 +385,8 @@ def predict(self,
head_entity, tail_entity = first, second
else:
head_entity, tail_entity = second, first
new_sent = RelationSentence.from_spans(context, head=head_entity, tail=tail_entity, label=cur_label)
new_sent = RelationSentence(tokens=context.split(), head=[], tail=[], raw=batch["outputs"][jj],
head_text=head_entity, tail_text=tail_entity, label=cur_label)
new_sent.head_text = head_entity
new_sent.tail_text = tail_entity
new_sent.raw = batch["outputs"][jj]
Expand Down Expand Up @@ -458,7 +459,9 @@ def score(path_pred: str, path_gold: str) -> dict:
for p in pred.sents[i].triplets:
results_by_label[p.label]["n_pred"] += 1
for g in gold.sents[i].triplets:
if (p.head, p.tail, p.label) == (g.head, g.tail, g.label):
gold_head = " ".join([g.tokens[i] for i in g.head])
gold_tail = " ".join([g.tokens[i] for i in g.tail])
if (p.head_text, p.tail_text, p.label) == (gold_head, gold_tail, g.label):
num_correct += 1
results_by_label[g.label]["tp"] += 1
if p.label == g.label:
Expand Down