From 337b647baac15609a0a493902d58c473d25d2ed8 Mon Sep 17 00:00:00 2001 From: graehl Date: Thu, 8 Jul 2010 16:44:20 +0000 Subject: --show_features git-svn-id: https://ws10smt.googlecode.com/svn/trunk@184 ec762483-ff6d-05da-a07a-a48fb63a330f --- decoder/hg.h | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'decoder/hg.h') 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 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 Weight; inline const SparseVector operator()(const Hypergraph::Edge& e) const { SparseVector res; for (SparseVector::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; } }; -- cgit v1.2.3