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-10 10:02:04 +0000
committergraehl@gmail.com <graehl@gmail.com@ec762483-ff6d-05da-a07a-a48fb63a330f>2010-08-10 10:02:04 +0000
commit32154b45828f05add1db7c89752ef4220c0fdf16 (patch)
treefa99e4d4847a89d41b464e9ae3c9aacf611e5500 /decoder/apply_fsa_models.cc
parent43db0573b15719d48b89b3a1ad2828036d008560 (diff)
cdec --cfg_output=-
git-svn-id: https://ws10smt.googlecode.com/svn/trunk@499 ec762483-ff6d-05da-a07a-a48fb63a330f
Diffstat (limited to 'decoder/apply_fsa_models.cc')
-rwxr-xr-xdecoder/apply_fsa_models.cc55
1 files changed, 32 insertions, 23 deletions
diff --git a/decoder/apply_fsa_models.cc b/decoder/apply_fsa_models.cc
index 416b9323..31b2002d 100755
--- a/decoder/apply_fsa_models.cc
+++ b/decoder/apply_fsa_models.cc
@@ -12,57 +12,66 @@
using namespace std;
struct ApplyFsa {
- ApplyFsa(const Hypergraph& ih,
+ ApplyFsa(HgCFG &i,
const SentenceMetadata& smeta,
const FsaFeatureFunction& fsa,
DenseWeightVector const& weights,
ApplyFsaBy const& by,
- Hypergraph* oh)
- :ih(ih),smeta(smeta),fsa(fsa),weights(weights),by(by),oh(oh)
+ Hypergraph* oh
+ )
+ :hgcfg(i),smeta(smeta),fsa(fsa),weights(weights),by(by),oh(oh)
{
-// sparse_to_dense(weight_vector,&weights);
- Init();
}
- void Init() {
+ void Compute() {
if (by.IsBottomUp())
ApplyBottomUp();
else
ApplyEarley();
}
- void ApplyBottomUp() {
- 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(by.BottomUpAlgorithm(),by.pop_limit);
- ApplyModelSet(ih,smeta,models,i,oh);
- }
- void ApplyEarley() {
- CFG cfg(ih,true,false,true);
- }
+ void ApplyBottomUp();
+ void ApplyEarley();
+ CFG const& GetCFG();
private:
- const Hypergraph& ih;
+ CFG cfg;
+ HgCFG &hgcfg;
const SentenceMetadata& smeta;
const FsaFeatureFunction& fsa;
// WeightVector weight_vector;
DenseWeightVector weights;
ApplyFsaBy by;
Hypergraph* oh;
+ std::string cfg_out;
};
+void ApplyFsa::ApplyBottomUp()
+{
+ 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(by.BottomUpAlgorithm(),by.pop_limit);
+ ApplyModelSet(hgcfg.ih,smeta,models,i,oh);
+}
-void ApplyFsaModels(const Hypergraph& ih,
+void ApplyFsa::ApplyEarley()
+{
+ hgcfg.GiveCFG(cfg);
+ //TODO:
+}
+
+
+void ApplyFsaModels(HgCFG &i,
const SentenceMetadata& smeta,
const FsaFeatureFunction& fsa,
DenseWeightVector const& weight_vector,
ApplyFsaBy const& by,
Hypergraph* oh)
{
- ApplyFsa a(ih,smeta,fsa,weight_vector,by,oh);
+ ApplyFsa a(i,smeta,fsa,weight_vector,by,oh);
+ a.Compute();
}
-
namespace {
char const* anames[]={
"BU_CUBE",
@@ -88,7 +97,7 @@ std::string ApplyFsaBy::all_names() {
return o.str();
}
-ApplyFsaBy::ApplyFsaBy(std::string const& n, int pop_limit) : pop_limit(pop_limit){
+ApplyFsaBy::ApplyFsaBy(std::string const& n, int pop_limit) : pop_limit(pop_limit) {
algorithm=0;
std::string uname=toupper(n);
while(anames[algorithm] && anames[algorithm] != uname) ++algorithm;