2014-09-15 05:22:40 +04:00
|
|
|
from cpython.ref cimport Py_INCREF
|
2014-09-18 01:09:24 +04:00
|
|
|
from cymem.cymem cimport Pool
|
2014-10-29 15:19:38 +03:00
|
|
|
from murmurhash.mrmr cimport hash64
|
2014-09-15 05:22:40 +04:00
|
|
|
|
2014-10-22 18:57:59 +04:00
|
|
|
from libc.string cimport memset
|
|
|
|
|
2014-10-09 12:53:30 +04:00
|
|
|
import orth
|
2014-09-10 22:41:37 +04:00
|
|
|
|
2014-10-09 12:53:30 +04:00
|
|
|
|
2014-10-23 17:59:17 +04:00
|
|
|
memset(&EMPTY_LEXEME, 0, sizeof(Lexeme))
|
2014-10-09 12:53:30 +04:00
|
|
|
|
|
|
|
|
2014-10-31 09:43:00 +03:00
|
|
|
cpdef Lexeme init(id_t i, unicode string, hash_t hashed,
|
2014-12-03 03:04:00 +03:00
|
|
|
StringStore string_store, dict props) except *:
|
2014-10-29 15:19:38 +03:00
|
|
|
cdef Lexeme lex
|
2014-10-31 09:43:00 +03:00
|
|
|
lex.id = i
|
2014-10-29 15:19:38 +03:00
|
|
|
lex.length = len(string)
|
2014-12-03 03:04:00 +03:00
|
|
|
lex.sic = string_store[string]
|
2014-10-29 15:19:38 +03:00
|
|
|
|
|
|
|
lex.cluster = props.get('cluster', 0)
|
2014-12-03 03:04:00 +03:00
|
|
|
lex.pos_type = props.get('pos_type', 0)
|
2014-10-29 15:19:38 +03:00
|
|
|
lex.prob = props.get('prob', 0)
|
|
|
|
|
2014-12-03 03:04:00 +03:00
|
|
|
lex.prefix = string_store[string[:1]]
|
|
|
|
lex.suffix = string_store[string[-3:]]
|
|
|
|
lex.shape = string_store[orth.word_shape(string)]
|
2014-12-07 15:52:41 +03:00
|
|
|
lex.dense = string_store[props['dense']]
|
2014-12-03 03:04:00 +03:00
|
|
|
|
|
|
|
lex.flags = props.get('flags', 0)
|
2014-10-29 15:19:38 +03:00
|
|
|
return lex
|