mirror of
https://github.com/explosion/spaCy.git
synced 2024-12-25 09:26:27 +03:00
* Add has_vector attribute to Token and Lexeme
This commit is contained in:
parent
c0a63ac157
commit
596fde8daa
|
@ -45,6 +45,10 @@ cdef class Lexeme:
|
|||
def similarity(self, other):
|
||||
return numpy.dot(self.vector, other.vector) / (self.vector_norm * other.vector_norm)
|
||||
|
||||
property has_vector:
|
||||
def __get__(self):
|
||||
return sum(abs(self.c.repvec)) != 0
|
||||
|
||||
property vector_norm:
|
||||
def __get__(self):
|
||||
return self.c.l2_norm
|
||||
|
|
|
@ -128,6 +128,10 @@ cdef class Token:
|
|||
def __get__(self):
|
||||
return self.c.dep
|
||||
|
||||
property has_vector:
|
||||
def __get__(self):
|
||||
return sum(abs(self.c.lex.repvec)) != 0
|
||||
|
||||
property vector:
|
||||
def __get__(self):
|
||||
cdef int length = self.vocab.vectors_length
|
||||
|
|
Loading…
Reference in New Issue
Block a user