From b38cfd0ef93cf7eb8a863b028ae2ce3ca91b0906 Mon Sep 17 00:00:00 2001 From: tiago Date: Wed, 9 Nov 2016 14:58:19 +0000 Subject: [PATCH 1/2] now span.merge returns token like it says on documentation --- spacy/tokens/span.pyx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spacy/tokens/span.pyx b/spacy/tokens/span.pyx index c55de3c3e..e645c1a6f 100644 --- a/spacy/tokens/span.pyx +++ b/spacy/tokens/span.pyx @@ -99,7 +99,7 @@ cdef class Span: token (Token): The newly merged token. """ - self.doc.merge(self.start_char, self.end_char, *args, **attributes) + return self.doc.merge(self.start_char, self.end_char, *args, **attributes) def similarity(self, other): '''Make a semantic similarity estimate. The default estimate is cosine From 2a3e342c1f8a81fcaa8d0b795e3f958806af6e2b Mon Sep 17 00:00:00 2001 From: tiago Date: Wed, 9 Nov 2016 18:57:50 +0000 Subject: [PATCH 2/2] Added a test case to cover the span.merge returning values --- spacy/tests/spans/test_merge.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/spacy/tests/spans/test_merge.py b/spacy/tests/spans/test_merge.py index 9b792d80b..f96d532cd 100644 --- a/spacy/tests/spans/test_merge.py +++ b/spacy/tests/spans/test_merge.py @@ -52,6 +52,13 @@ def test_np_merges(EN): merged = tokens.merge(start, end, label, lemma, label) assert merged != None, (start, end, label, lemma) + + tokens = EN(u'One test with entities like New York City so the ents list is not void') + + for span in tokens.ents: + merged = span.merge() + assert merged != None, (span.start, span.end, span.label_, span.lemma_) + @pytest.mark.models def test_entity_merge(EN): tokens = EN(u'Stewart Lee is a stand up comedian who lives in England and loves Joe Pasquale.\n')