diff options
author | graehl <graehl@ec762483-ff6d-05da-a07a-a48fb63a330f> | 2010-07-08 16:44:20 +0000 |
---|---|---|
committer | graehl <graehl@ec762483-ff6d-05da-a07a-a48fb63a330f> | 2010-07-08 16:44:20 +0000 |
commit | d5ff16caf653f6fab31a3f0620214c331d6eebc4 (patch) | |
tree | 696c66cc1a217564cb08ce947047ccc2f1092b1f /decoder/hg.h | |
parent | cea8791b9c517a1ab7e29c34fa6bf52843a3ab55 (diff) |
--show_features
git-svn-id: https://ws10smt.googlecode.com/svn/trunk@184 ec762483-ff6d-05da-a07a-a48fb63a330f
Diffstat (limited to 'decoder/hg.h')
-rw-r--r-- | decoder/hg.h | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/decoder/hg.h b/decoder/hg.h index ab90650c..0f8d21fd 100644 --- a/decoder/hg.h +++ b/decoder/hg.h @@ -59,6 +59,9 @@ class Hypergraph { short int prev_j_; }; + // returns edge with rule_.IsGoal, returns 0 if none found. otherwise gives best edge_prob_ - note: I don't think edge_prob_ is viterbi cumulative, so this would just be the best local probability. + Edge const* ViterbiGoalEdge() const; + void swap(Hypergraph& other) { other.nodes_.swap(nodes_); std::swap(is_linear_chain_, other.is_linear_chain_); @@ -218,10 +221,12 @@ class Hypergraph { // common WeightFunctions, map an edge -> WeightType // for generic Viterbi/Inside algorithms struct EdgeProb { + typedef prob_t Weight; inline const prob_t& operator()(const Hypergraph::Edge& e) const { return e.edge_prob_; } }; struct EdgeSelectEdgeWeightFunction { + typedef prob_t Weight; typedef std::vector<bool> EdgeMask; EdgeSelectEdgeWeightFunction(const EdgeMask& v) : v_(v) {} inline prob_t operator()(const Hypergraph::Edge& e) const { @@ -236,10 +241,12 @@ struct ScaledEdgeProb { ScaledEdgeProb(const double& alpha) : alpha_(alpha) {} inline prob_t operator()(const Hypergraph::Edge& e) const { return e.edge_prob_.pow(alpha_); } const double alpha_; + typedef prob_t Weight; }; // see Li (2010), Section 3.2.2-- this is 'x_e = p_e*r_e' struct EdgeFeaturesAndProbWeightFunction { + typedef const SparseVector<prob_t> Weight; inline const SparseVector<prob_t> operator()(const Hypergraph::Edge& e) const { SparseVector<prob_t> res; for (SparseVector<double>::const_iterator it = e.feature_values_.begin(); @@ -250,6 +257,7 @@ struct EdgeFeaturesAndProbWeightFunction { }; struct TransitionCountWeightFunction { + typedef double Weight; inline double operator()(const Hypergraph::Edge& e) const { (void)e; return 1.0; } }; |