* Add set_scores method to Model

This commit is contained in:
Matthew Honnibal 2015-06-02 18:37:10 +02:00
parent a3964957f6
commit bd82a49994
2 changed files with 7 additions and 0 deletions

View File

@ -19,6 +19,7 @@ cdef class Model:
cdef int n_classes
cdef const weight_t* score(self, atom_t* context) except NULL
cdef int set_scores(self, weight_t* scores, atom_t* context) except -1
cdef int update(self, atom_t* context, class_t guess, class_t gold, int cost) except -1

View File

@ -1,3 +1,4 @@
# cython: profile=True
from __future__ import unicode_literals
from __future__ import division
@ -38,6 +39,11 @@ cdef class Model:
feats = self._extractor.get_feats(context, &n_feats)
return self._model.get_scores(feats, n_feats)
cdef int set_scores(self, weight_t* scores, atom_t* context) except -1:
cdef int n_feats
feats = self._extractor.get_feats(context, &n_feats)
self._model.set_scores(scores, feats, n_feats)
cdef int update(self, atom_t* context, class_t guess, class_t gold, int cost) except -1:
cdef int n_feats
if cost == 0: