Skip to content

Commit 7ee36ee

Browse files
committed
fix a bug in mention pruning
1 parent 3c158f9 commit 7ee36ee

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

tibert/bertcoref.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1093,9 +1093,9 @@ def pruned_mentions_indexs(
10931093
The algorithm works as follows :
10941094
10951095
1. Sort mentions by individual scores
1096-
2. Accept mention in orders, from best to worst score, until k of
1096+
2. Accept mention in order, from best to worst score, until k of
10971097
them are accepted. A mention can only be accepted if no
1098-
previously accepted span os overlapping with it.
1098+
previously accepted span is overlapping with it.
10991099
11001100
See section 5 of the E2ECoref paper and the C++ kernel in the
11011101
E2ECoref repository.
@@ -1119,9 +1119,7 @@ def pruned_mentions_indexs(
11191119
def spans_are_overlapping(
11201120
span1: Tuple[int, int], span2: Tuple[int, int]
11211121
) -> bool:
1122-
return (
1123-
span1[0] < span2[0] and span2[0] <= span1[1] and span1[1] < span2[1]
1124-
) or (span2[0] < span1[0] and span1[0] <= span2[1] and span2[1] < span1[1])
1122+
return not (span1[1] <= span2[0] or span1[0] >= span2[1])
11251123

11261124
_, sorted_indexs = torch.sort(mention_scores, 1, descending=True)
11271125
# TODO: what if we can't have top_mentions_nb mentions ??

0 commit comments

Comments
 (0)