mirror of
https://github.com/explosion/spaCy.git
synced 2024-12-25 09:26:27 +03:00
Ensure doc.similarity returns a float (on develop) (#4969)
This commit is contained in:
parent
cabd60fa1e
commit
781e95cf53
|
@ -391,7 +391,9 @@ cdef class Doc:
|
||||||
return 0.0
|
return 0.0
|
||||||
vector = self.vector
|
vector = self.vector
|
||||||
xp = get_array_module(vector)
|
xp = get_array_module(vector)
|
||||||
return xp.dot(vector, other.vector) / (self.vector_norm * other.vector_norm)
|
result = xp.dot(vector, other.vector) / (self.vector_norm * other.vector_norm)
|
||||||
|
# ensure we get a scalar back (numpy does this automatically but cupy doesn't)
|
||||||
|
return result.item()
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def has_vector(self):
|
def has_vector(self):
|
||||||
|
|
Loading…
Reference in New Issue
Block a user