summaryrefslogtreecommitdiff
path: root/python/cdec/mteval.pxd
diff options
context:
space:
mode:
authorVictor Chahuneau <vchahune@cs.cmu.edu>2013-08-26 20:12:32 -0400
committerVictor Chahuneau <vchahune@cs.cmu.edu>2013-08-26 20:12:32 -0400
commit03799a2d330c6dbbe12154d4bcea236210b4f6ed (patch)
tree7adb0bc8dd2987fa32ee1299d8821dd8b7b06706 /python/cdec/mteval.pxd
parent8b491e57f8a011f4f8496e44bed7eb7a4360bc93 (diff)
Improve the package structure of pycdec
This change should not break anything, but now you can run: python setup.py build_ext --inplace and use the cleaner: PYTHONPATH=/path/to/cdec/python python -m ...
Diffstat (limited to 'python/cdec/mteval.pxd')
-rw-r--r--python/cdec/mteval.pxd56
1 files changed, 56 insertions, 0 deletions
diff --git a/python/cdec/mteval.pxd b/python/cdec/mteval.pxd
new file mode 100644
index 00000000..33a6b7a5
--- /dev/null
+++ b/python/cdec/mteval.pxd
@@ -0,0 +1,56 @@
+from libcpp.vector cimport vector
+from libcpp.string cimport string
+from utils cimport *
+from hypergraph cimport Hypergraph
+
+cdef extern from "mteval/ns.h":
+ cdef cppclass SufficientStats:
+ SufficientStats()
+ SufficientStats(SufficientStats&)
+ unsigned size()
+ float operator[](unsigned i)
+ void swap(SufficientStats& other)
+ vector[float] fields
+
+ SufficientStats add "operator+" (SufficientStats&, SufficientStats&)
+
+ cdef cppclass SegmentEvaluator:
+ void Evaluate(vector[WordID]& hyp, SufficientStats* out)
+
+ cdef cppclass EvaluationMetric:
+ string& MetricId()
+ bint IsErrorMetric()
+ float ComputeScore(SufficientStats& stats)
+ string DetailedScore(SufficientStats& stats)
+ shared_ptr[SegmentEvaluator] CreateSegmentEvaluator(vector[vector[WordID]]& refs)
+ ComputeSufficientStatistics(vector[WordID]& hyp,
+ vector[WordID]& refs,
+ SufficientStats* out)
+
+ cdef EvaluationMetric* MetricInstance "EvaluationMetric::Instance" (string& metric_id)
+
+cdef extern from "py_scorer.h":
+ ctypedef float (*MetricScoreCallback)(void*, SufficientStats* stats)
+ ctypedef void (*MetricStatsCallback)(void*,
+ string* hyp, vector[string]* refs, SufficientStats* out)
+
+ cdef EvaluationMetric* PyMetricInstance "PythonEvaluationMetric::Instance"(
+ string& metric_id, void*, MetricStatsCallback, MetricScoreCallback)
+
+cdef extern from "training/utils/candidate_set.h" namespace "training":
+ cdef cppclass Candidate:
+ vector[WordID] ewords
+ FastSparseVector[weight_t] fmap
+ SufficientStats eval_feats
+
+ ctypedef Candidate const_Candidate "const training::Candidate"
+
+ cdef cppclass CandidateSet:
+ CandidateSet()
+ unsigned size()
+ const_Candidate& operator[](unsigned i)
+ void ReadFromFile(string& file)
+ void WriteToFile(string& file)
+ void AddKBestCandidates(Hypergraph& hg,
+ unsigned kbest_size,
+ SegmentEvaluator* scorer)