summaryrefslogtreecommitdiff
path: root/decoder/ff_factory.cc
diff options
context:
space:
mode:
authorgraehl <graehl@ec762483-ff6d-05da-a07a-a48fb63a330f>2010-07-23 21:02:44 +0000
committergraehl <graehl@ec762483-ff6d-05da-a07a-a48fb63a330f>2010-07-23 21:02:44 +0000
commit353ff197b082b71c623c7851e0df0ac60d770533 (patch)
tree3d55c79807f86cbe579df3a9d1aebf4464331423 /decoder/ff_factory.cc
parent37f4f68effe3b5ab823985798e77fa64dd66088d (diff)
implicit first param to ffs: "debug". fsa final traversal set feature=0 first. set FF_FSA_DEBUG (also FSA_DEBUG).
git-svn-id: https://ws10smt.googlecode.com/svn/trunk@387 ec762483-ff6d-05da-a07a-a48fb63a330f
Diffstat (limited to 'decoder/ff_factory.cc')
-rw-r--r--decoder/ff_factory.cc16
1 files changed, 15 insertions, 1 deletions
diff --git a/decoder/ff_factory.cc b/decoder/ff_factory.cc
index fe733ca5..a6d834e0 100644
--- a/decoder/ff_factory.cc
+++ b/decoder/ff_factory.cc
@@ -1,6 +1,7 @@
#include "ff_factory.h"
#include "ff.h"
+#include "stringlib.h"
using boost::shared_ptr;
using namespace std;
@@ -21,14 +22,27 @@ string FFRegistry::usage(string const& ffname,bool params,bool verbose) const {
: it->second->usage(params,verbose);
}
+namespace {
+std::string const& debug_pre="debug";
+}
+
shared_ptr<FeatureFunction> FFRegistry::Create(const string& ffname, const string& param) const {
map<string, shared_ptr<FFFactoryBase> >::const_iterator it = reg_.find(ffname);
shared_ptr<FeatureFunction> res;
if (it == reg_.end()) {
cerr << "I don't know how to create feature " << ffname << endl;
} else {
- res = it->second->Create(param);
+ int pl=debug_pre.size();
+ bool space=false;
+ std::string p=param;
+ bool debug=match_begin(p,debug_pre)&&(p.size()==pl||(space=p[pl]==' '));
+ if (debug) {
+ p.erase(0,debug_pre.size()+space);
+ cerr<<"debug enabled for "<<ffname<< " - rest of param='"<<p<<"'\n";
+ }
+ res = it->second->Create(p);
res->name=ffname;
+ res->debug=debug;
}
return res;
}