Add tensor field to Lexeme, Token, Doc and Span, so that users have a place to hang neural network outputs

This commit is contained in:
Matthew Honnibal 2016-10-14 03:24:13 +02:00
parent afe20bd8fb
commit f3be9d0a9a
4 changed files with 9 additions and 0 deletions

View File

@ -15,6 +15,7 @@ cdef class Lexeme:
cdef LexemeC* c cdef LexemeC* c
cdef readonly Vocab vocab cdef readonly Vocab vocab
cdef readonly attr_t orth cdef readonly attr_t orth
cdef public ndarray tensor
@staticmethod @staticmethod
cdef inline Lexeme from_ptr(LexemeC* lex, Vocab vocab, int vector_length): cdef inline Lexeme from_ptr(LexemeC* lex, Vocab vocab, int vector_length):

View File

@ -32,6 +32,8 @@ cdef class Doc:
cdef public object _vector cdef public object _vector
cdef public object _vector_norm cdef public object _vector_norm
cdef public np.ndarray tensor
cdef TokenC* c cdef TokenC* c
cdef public bint is_tagged cdef public bint is_tagged

View File

@ -1,3 +1,5 @@
cimport numpy as np
from .doc cimport Doc from .doc cimport Doc
@ -9,6 +11,8 @@ cdef class Span:
cdef readonly int end_char cdef readonly int end_char
cdef readonly int label cdef readonly int label
cdef public np.ndarray tensor
cdef public _vector cdef public _vector
cdef public _vector_norm cdef public _vector_norm

View File

@ -1,3 +1,4 @@
from numpy cimport ndarray
from ..vocab cimport Vocab from ..vocab cimport Vocab
from ..structs cimport TokenC from ..structs cimport TokenC
from ..attrs cimport attr_id_t from ..attrs cimport attr_id_t
@ -9,6 +10,7 @@ cdef class Token:
cdef TokenC* c cdef TokenC* c
cdef readonly int i cdef readonly int i
cdef readonly Doc doc cdef readonly Doc doc
cdef public ndarray tensor
@staticmethod @staticmethod
cdef inline Token cinit(Vocab vocab, const TokenC* token, int offset, Doc doc): cdef inline Token cinit(Vocab vocab, const TokenC* token, int offset, Doc doc):