Fix bug in Span.similarity when called via hook

This commit is contained in:
Ines Montani 2019-07-27 15:33:27 +02:00
parent 109b5e1798
commit d5bce35fb1

View File

@ -311,7 +311,7 @@ cdef class Span:
DOCS: https://spacy.io/api/span#similarity
"""
if "similarity" in self.doc.user_span_hooks:
self.doc.user_span_hooks["similarity"](self, other)
return self.doc.user_span_hooks["similarity"](self, other)
if len(self) == 1 and hasattr(other, "orth"):
if self[0].orth == other.orth:
return 1.0