summaryrefslogtreecommitdiff
path: root/decoder/hg.h
diff options
context:
space:
mode:
authorChris Dyer <redpony@gmail.com>2014-03-18 01:41:17 -0400
committerChris Dyer <redpony@gmail.com>2014-03-18 01:41:17 -0400
commit606e3e38b8a830dbbe65963ebf6c5ce7866b7800 (patch)
tree332cec5e0b4c8e3b8d6cc0d631fe5d5815f088f6 /decoder/hg.h
parentcc87bfed0697583b7c11243913254dde3c0047d4 (diff)
star function
Diffstat (limited to 'decoder/hg.h')
-rw-r--r--decoder/hg.h17
1 files changed, 16 insertions, 1 deletions
diff --git a/decoder/hg.h b/decoder/hg.h
index 3d8cd9bc..343b99cf 100644
--- a/decoder/hg.h
+++ b/decoder/hg.h
@@ -25,6 +25,7 @@
#include "tdict.h"
#include "trule.h"
#include "prob.h"
+#include "exp_semiring.h"
#include "indices_after.h"
#include "nt_span.h"
@@ -527,7 +528,21 @@ struct EdgeFeaturesAndProbWeightFunction {
struct TransitionCountWeightFunction {
typedef double Weight;
- inline double operator()(const HG::Edge& e) const { (void)e; return 1.0; }
+ inline double operator()(const HG::Edge&) const { return 1.0; }
+};
+
+template <class P, class PWeightFunction, class R, class RWeightFunction>
+struct PRWeightFunction {
+ explicit PRWeightFunction(const PWeightFunction& pwf = PWeightFunction(),
+ const RWeightFunction& rwf = RWeightFunction()) :
+ pweight(pwf), rweight(rwf) {}
+ PRPair<P,R> operator()(const HG::Edge& e) const {
+ const P p = pweight(e);
+ const R r = rweight(e);
+ return PRPair<P,R>(p, r * p);
+ }
+ const PWeightFunction pweight;
+ const RWeightFunction rweight;
};
#endif