2014-09-15 01:22:40 +00:00
|
|
|
from cpython.ref cimport Py_INCREF
|
2014-09-17 21:09:24 +00:00
|
|
|
from cymem.cymem cimport Pool
|
2014-10-29 12:19:38 +00:00
|
|
|
from murmurhash.mrmr cimport hash64
|
2014-09-15 01:22:40 +00:00
|
|
|
|
2014-10-22 14:57:59 +00:00
|
|
|
from libc.string cimport memset
|
|
|
|
|
2015-01-05 07:49:19 +00:00
|
|
|
from .orth cimport word_shape
|
2015-01-13 13:03:48 +00:00
|
|
|
from .typedefs cimport attr_t
|
2014-09-10 18:41:37 +00:00
|
|
|
|
2014-10-09 08:53:30 +00:00
|
|
|
|
2015-01-11 23:26:22 +00:00
|
|
|
memset(&EMPTY_LEXEME, 0, sizeof(LexemeC))
|
2014-10-09 08:53:30 +00:00
|
|
|
|
|
|
|
|
2015-01-13 13:03:48 +00:00
|
|
|
cdef int set_lex_struct_props(LexemeC* lex, dict props, StringStore string_store) except -1:
|
|
|
|
|
|
|
|
lex.length = props['length']
|
|
|
|
lex.sic = string_store[props['sic']]
|
|
|
|
lex.norm1 = string_store[props['norm1']]
|
|
|
|
lex.norm2 = string_store[props['norm2']]
|
|
|
|
lex.shape = string_store[props['shape']]
|
|
|
|
lex.prefix = string_store[props['prefix']]
|
|
|
|
lex.suffix = string_store[props['suffix']]
|
2014-10-29 12:19:38 +00:00
|
|
|
|
2015-01-13 13:03:48 +00:00
|
|
|
lex.cluster = props['cluster']
|
|
|
|
lex.prob = props['prob']
|
|
|
|
lex.sentiment = props['sentiment']
|
|
|
|
|
|
|
|
lex.flags = props['flags']
|
2015-01-11 23:26:22 +00:00
|
|
|
|
|
|
|
|
2015-01-12 00:23:44 +00:00
|
|
|
cdef class Lexeme:
|
|
|
|
def __init__(self):
|
|
|
|
pass
|
|
|
|
|
2015-01-11 23:26:22 +00:00
|
|
|
|
2015-01-12 00:23:44 +00:00
|
|
|
cdef Lexeme Lexeme_cinit(const LexemeC* c, StringStore strings):
|
|
|
|
cdef Lexeme py = Lexeme.__new__(Lexeme)
|
|
|
|
|
|
|
|
py.vec = c.vec
|
|
|
|
|
|
|
|
py.flags = c.flags
|
|
|
|
py.id = c.id
|
|
|
|
py.length = c.length
|
|
|
|
|
|
|
|
py.sic = strings[c.sic]
|
|
|
|
py.norm1 = strings[c.norm1]
|
|
|
|
py.norm2 = strings[c.norm2]
|
|
|
|
py.shape = strings[c.shape]
|
|
|
|
py.prefix = strings[c.prefix]
|
|
|
|
py.suffix = strings[c.suffix]
|
|
|
|
|
|
|
|
py.sic_id = c.sic
|
|
|
|
py.norm1_id = c.norm1
|
|
|
|
py.norm2_id = c.norm2
|
|
|
|
py.shape_id = c.shape
|
|
|
|
py.prefix_id = c.prefix
|
|
|
|
py.suffix_id = c.suffix
|
|
|
|
|
|
|
|
py.cluster = c.cluster
|
|
|
|
|
|
|
|
py.prob = c.prob
|
|
|
|
py.sentiment = c.sentiment
|
|
|
|
return py
|