diff options
author | Chris Dyer <cdyer@cab.ark.cs.cmu.edu> | 2012-10-16 01:43:01 -0400 |
---|---|---|
committer | Chris Dyer <cdyer@cab.ark.cs.cmu.edu> | 2012-10-16 01:43:01 -0400 |
commit | daaa8aaed96f23d74d86b77e436883cd7c451717 (patch) | |
tree | b8542a6462748527bd2f795d00478915b4bbee46 /python/src/mteval.pxi | |
parent | b98f7e8de2c35937c227236ddb986df4879edb5f (diff) | |
parent | 62bf03f0ec79b658c9208f0ae8976397e64a7dee (diff) |
Merge branch 'master' of github.com:redpony/cdec
Diffstat (limited to 'python/src/mteval.pxi')
-rw-r--r-- | python/src/mteval.pxi | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/python/src/mteval.pxi b/python/src/mteval.pxi index 00355f96..f3bec393 100644 --- a/python/src/mteval.pxi +++ b/python/src/mteval.pxi @@ -93,6 +93,8 @@ cdef class CandidateSet: yield self[i] def add_kbest(self, Hypergraph hypergraph, unsigned k): + """cs.add_kbest(Hypergraph hypergraph, int k) -> Extract K-best hypotheses + from the hypergraph and add them to the candidate set.""" self.cs.AddKBestCandidates(hypergraph.hg[0], k, self.scorer.get()) cdef class SegmentEvaluator: @@ -103,15 +105,17 @@ cdef class SegmentEvaluator: del self.scorer def evaluate(self, sentence): + """se.evaluate(sentence) -> SufficientStats for the given hypothesis.""" cdef vector[WordID] hyp cdef SufficientStats sf = SufficientStats() sf.metric = self.metric sf.stats = new mteval.SufficientStats() - ConvertSentence(string(as_str(sentence.strip())), &hyp) + ConvertSentence(as_str(sentence.strip()), &hyp) self.scorer.get().Evaluate(hyp, sf.stats) return sf def candidate_set(self): + """se.candidate_set() -> Candidate set using this segment evaluator for scoring.""" return CandidateSet(self) cdef class Scorer: @@ -133,7 +137,7 @@ cdef class Scorer: cdef vector[WordID]* refv for ref in refs: refv = new vector[WordID]() - ConvertSentence(string(as_str(ref.strip())), refv) + ConvertSentence(as_str(ref.strip()), refv) refsv.push_back(refv[0]) del refv cdef unsigned i @@ -173,7 +177,8 @@ cdef class Metric: cdef Scorer scorer def __cinit__(self): self.scorer = Scorer() - self.scorer.name = new string(as_str(self.__class__.__name__)) + cdef bytes class_name = self.__class__.__name__ + self.scorer.name = new string(class_name) self.scorer.metric = mteval.PyMetricInstance(self.scorer.name[0], <void*> self, _compute_sufficient_stats, _compute_score) |