2014-12-30 13:20:15 +03:00
|
|
|
from libc.stdint cimport uint8_t
|
|
|
|
|
|
|
|
from cymem.cymem cimport Pool
|
|
|
|
|
|
|
|
from thinc.learner cimport LinearModel
|
2015-05-26 23:17:15 +03:00
|
|
|
from thinc.features cimport Extractor, Feature
|
2014-12-30 13:20:15 +03:00
|
|
|
from thinc.typedefs cimport atom_t, feat_t, weight_t, class_t
|
2015-06-28 23:36:03 +03:00
|
|
|
from thinc.api cimport ExampleC
|
2014-12-30 13:20:15 +03:00
|
|
|
|
|
|
|
from preshed.maps cimport PreshMapArray
|
|
|
|
|
|
|
|
from .typedefs cimport hash_t, id_t
|
|
|
|
from .tokens cimport Tokens
|
|
|
|
|
|
|
|
|
2014-12-31 11:40:59 +03:00
|
|
|
cdef int arg_max(const weight_t* scores, const int n_classes) nogil
|
|
|
|
|
2015-06-26 14:51:39 +03:00
|
|
|
cdef int arg_max_if_true(const weight_t* scores, const int* is_valid, int n_classes) nogil
|
|
|
|
|
|
|
|
cdef int arg_max_if_zero(const weight_t* scores, const int* costs, int n_classes) nogil
|
|
|
|
|
2014-12-31 11:40:59 +03:00
|
|
|
|
2014-12-30 13:20:15 +03:00
|
|
|
cdef class Model:
|
2015-06-30 15:26:32 +03:00
|
|
|
cdef readonly int n_classes
|
|
|
|
cdef readonly int n_feats
|
2015-05-26 23:17:15 +03:00
|
|
|
|
2015-06-02 01:27:07 +03:00
|
|
|
cdef const weight_t* score(self, atom_t* context) except NULL
|
2015-06-02 19:37:10 +03:00
|
|
|
cdef int set_scores(self, weight_t* scores, atom_t* context) except -1
|
2014-12-31 11:40:59 +03:00
|
|
|
|
|
|
|
cdef int update(self, atom_t* context, class_t guess, class_t gold, int cost) except -1
|
2015-05-31 19:48:05 +03:00
|
|
|
|
2014-12-30 13:20:15 +03:00
|
|
|
cdef object model_loc
|
|
|
|
cdef Extractor _extractor
|
|
|
|
cdef LinearModel _model
|