spaCy/spacy/lexeme.pyx

33 lines
756 B
Cython
Raw Normal View History

from cpython.ref cimport Py_INCREF
from cymem.cymem cimport Pool
2014-10-29 12:19:38 +00:00
from murmurhash.mrmr cimport hash64
from libc.string cimport memset
2015-01-05 07:49:19 +00:00
from .orth cimport word_shape
2014-09-10 18:41:37 +00:00
memset(&EMPTY_LEXEME, 0, sizeof(LexemeC))
cdef LexemeC init(id_t i, unicode string, hash_t hashed,
StringStore string_store, dict props) except *:
cdef LexemeC lex
lex.id = i
2014-10-29 12:19:38 +00:00
lex.length = len(string)
lex.sic = string_store[string]
2014-10-29 12:19:38 +00:00
lex.cluster = props.get('cluster', 0)
lex.pos_type = props.get('pos_type', 0)
2014-10-29 12:19:38 +00:00
lex.prob = props.get('prob', 0)
lex.prefix = string_store[string[:1]]
lex.suffix = string_store[string[-3:]]
2015-01-05 07:49:19 +00:00
lex.shape = string_store[word_shape(string)]
lex.flags = props.get('flags', 0)
2014-10-29 12:19:38 +00:00
return lex