From 51b618d646108dfece447482669fe940ab5971de Mon Sep 17 00:00:00 2001 From: Matthew Honnibal Date: Sat, 7 Feb 2015 08:42:44 -0500 Subject: [PATCH] * Add a has_repvec property to Lexeme, and a check function to check flags --- spacy/lexeme.pyx | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/spacy/lexeme.pyx b/spacy/lexeme.pyx index 30d3c2b31..7a2bce95a 100644 --- a/spacy/lexeme.pyx +++ b/spacy/lexeme.pyx @@ -39,3 +39,10 @@ cdef class Lexeme: """ def __cinit__(self, int vec_size): self.repvec = numpy.ndarray(shape=(vec_size,), dtype=numpy.float32) + + @property + def has_repvec(self): + return self.l2_norm != 0 + + cpdef bint check(self, attr_id_t flag_id) except -1: + return self.flags & (1 << flag_id)