From 321b402739f9734db69d2df3675385b299fb5e6b Mon Sep 17 00:00:00 2001 From: Matthew Honnibal Date: Sat, 7 Feb 2015 08:42:16 -0500 Subject: [PATCH] * Store the l2 norm of the word's vector --- spacy/lexeme.pxd | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/spacy/lexeme.pxd b/spacy/lexeme.pxd index 0723ed6fe..41324cd38 100644 --- a/spacy/lexeme.pxd +++ b/spacy/lexeme.pxd @@ -37,6 +37,7 @@ cdef class Lexeme: cdef readonly attr_t cluster cdef readonly float prob cdef readonly float sentiment + cdef readonly float l2_norm # Workaround for an apparent bug in the way the decorator is handled --- # TODO: post bug report / patch to Cython. @@ -45,6 +46,7 @@ cdef class Lexeme: cdef Lexeme py = Lexeme.__new__(Lexeme, 300) for i in range(300): py.repvec[i] = ptr.repvec[i] + py.l2_norm = ptr.l2_norm py.flags = ptr.flags py.id = ptr.id py.length = ptr.length @@ -68,6 +70,8 @@ cdef class Lexeme: py.sentiment = ptr.sentiment return py + cpdef bint check(self, attr_id_t flag_id) except -1 + cdef inline bint check_flag(const LexemeC* lexeme, attr_id_t flag_id) nogil: return lexeme.flags & (1 << flag_id)