summaryrefslogtreecommitdiff
path: root/decoder/apply_fsa_models.cc
diff options
context:
space:
mode:
authorgraehl@gmail.com <graehl@gmail.com@ec762483-ff6d-05da-a07a-a48fb63a330f>2010-08-08 08:49:13 +0000
committergraehl@gmail.com <graehl@gmail.com@ec762483-ff6d-05da-a07a-a48fb63a330f>2010-08-08 08:49:13 +0000
commitffd4acfe5b84f413c66af6ec5a76bdbc0d3aa9e8 (patch)
treee5e6f9063e200a7bee863fa34557007d5271a22f /decoder/apply_fsa_models.cc
parentb588990fe985be78c05a9497d7f95b440d454cd3 (diff)
cfg
git-svn-id: https://ws10smt.googlecode.com/svn/trunk@493 ec762483-ff6d-05da-a07a-a48fb63a330f
Diffstat (limited to 'decoder/apply_fsa_models.cc')
-rwxr-xr-xdecoder/apply_fsa_models.cc24
1 files changed, 15 insertions, 9 deletions
diff --git a/decoder/apply_fsa_models.cc b/decoder/apply_fsa_models.cc
index 01de62d3..416b9323 100755
--- a/decoder/apply_fsa_models.cc
+++ b/decoder/apply_fsa_models.cc
@@ -7,6 +7,7 @@
#include "apply_models.h"
#include <stdexcept>
#include <cassert>
+#include "cfg.h"
using namespace std;
@@ -15,33 +16,38 @@ struct ApplyFsa {
const SentenceMetadata& smeta,
const FsaFeatureFunction& fsa,
DenseWeightVector const& weights,
- ApplyFsaBy const& cfg,
+ ApplyFsaBy const& by,
Hypergraph* oh)
- :ih(ih),smeta(smeta),fsa(fsa),weights(weights),cfg(cfg),oh(oh)
+ :ih(ih),smeta(smeta),fsa(fsa),weights(weights),by(by),oh(oh)
{
// sparse_to_dense(weight_vector,&weights);
Init();
}
void Init() {
- ApplyBottomUp();
- //TODO: implement l->r
+ if (by.IsBottomUp())
+ ApplyBottomUp();
+ else
+ ApplyEarley();
}
void ApplyBottomUp() {
- assert(cfg.IsBottomUp());
+ assert(by.IsBottomUp());
FeatureFunctionFromFsa<FsaFeatureFunctionFwd> buff(&fsa);
buff.Init(); // mandatory to call this (normally factory would do it)
vector<const FeatureFunction*> ffs(1,&buff);
ModelSet models(weights, ffs);
- IntersectionConfiguration i(cfg.BottomUpAlgorithm(),cfg.pop_limit);
+ IntersectionConfiguration i(by.BottomUpAlgorithm(),by.pop_limit);
ApplyModelSet(ih,smeta,models,i,oh);
}
+ void ApplyEarley() {
+ CFG cfg(ih,true,false,true);
+ }
private:
const Hypergraph& ih;
const SentenceMetadata& smeta;
const FsaFeatureFunction& fsa;
// WeightVector weight_vector;
DenseWeightVector weights;
- ApplyFsaBy cfg;
+ ApplyFsaBy by;
Hypergraph* oh;
};
@@ -50,10 +56,10 @@ void ApplyFsaModels(const Hypergraph& ih,
const SentenceMetadata& smeta,
const FsaFeatureFunction& fsa,
DenseWeightVector const& weight_vector,
- ApplyFsaBy const& cfg,
+ ApplyFsaBy const& by,
Hypergraph* oh)
{
- ApplyFsa a(ih,smeta,fsa,weight_vector,cfg,oh);
+ ApplyFsa a(ih,smeta,fsa,weight_vector,by,oh);
}