Skip to content

Commit 4758149

Browse files
committed
add test_mention_labels_number_is_correct
1 parent b05e06f commit 4758149

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

tests/test_bertcoref.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,3 +26,22 @@ def test_doc_is_reconstructed(
2626

2727
assert doc.tokens == reconstructed_doc.tokens
2828
assert doc.coref_chains == reconstructed_doc.coref_chains
29+
30+
31+
@given(doc=coref_docs())
32+
def test_mention_labels_number_is_correct(doc: CoreferenceDocument):
33+
"""
34+
The number of mentions labeled as such by
35+
:meth:`CoreferenceDocument.mention_labels` should be equal to the
36+
number of mentions of the document (that have a length lower then
37+
`max_span_size`)
38+
"""
39+
max_span_size = min(4, len(doc))
40+
mentions = [
41+
mention
42+
for chain in doc.coref_chains
43+
for mention in chain
44+
if len(mention.tokens) <= max_span_size
45+
]
46+
labels = doc.mention_labels(max_span_size)
47+
assert sum(labels) == len(mentions)

0 commit comments

Comments
 (0)