* Add has_vector attribute to Token and Lexeme

This commit is contained in:
Matthew Honnibal 2015-09-21 19:52:43 +10:00
parent c0a63ac157
commit 596fde8daa
2 changed files with 8 additions and 0 deletions

View File

@ -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

View File

@ -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