From bd82a4999499408ba8d2d63325bf592963dcc582 Mon Sep 17 00:00:00 2001 From: Matthew Honnibal Date: Tue, 2 Jun 2015 18:37:10 +0200 Subject: [PATCH] * Add set_scores method to Model --- spacy/_ml.pxd | 1 + spacy/_ml.pyx | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/spacy/_ml.pxd b/spacy/_ml.pxd index 0329faf08..add162e69 100644 --- a/spacy/_ml.pxd +++ b/spacy/_ml.pxd @@ -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 diff --git a/spacy/_ml.pyx b/spacy/_ml.pyx index 6087dc8db..be647c2dd 100644 --- a/spacy/_ml.pyx +++ b/spacy/_ml.pyx @@ -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: