Skip to content

Commit

Permalink
Move the span checking outside the mention building loop
Browse files Browse the repository at this point in the history
  • Loading branch information
AngledLuffa committed Jan 5, 2024
1 parent 2120a87 commit b33f912
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions stanza/pipeline/coref_processor.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,14 @@ def process(self, document):
continue
span_cluster = sorted(span_cluster)

for span in span_cluster:
# check there are no sentence crossings before
# manipulating the spans, since we will expect it to
# be this way for multiple usages of the spans
sent_id = sent_ids[span[0]]
if sent_ids[span[1]] != sent_id:
raise ValueError("The coref model predicted a span that crossed two sentences! Please send this example to us on our github")

# treat the longest span as the representative
# break ties using the first one
max_len = 0
Expand All @@ -116,8 +124,6 @@ def process(self, document):
mentions = []
for span in span_cluster:
sent_id = sent_ids[span[0]]
if sent_ids[span[1]] != sent_id:
raise ValueError("The coref model predicted a span that crossed two sentences! Please send this example to us on our github")
start_word = word_pos[span[0]]
end_word = word_pos[span[1]]
mentions.append(CorefMention(sent_id, start_word, end_word))
Expand Down

0 comments on commit b33f912

Please sign in to comment.