From 353ff197b082b71c623c7851e0df0ac60d770533 Mon Sep 17 00:00:00 2001 From: graehl Date: Fri, 23 Jul 2010 21:02:44 +0000 Subject: 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 --- decoder/ff_factory.cc | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) (limited to 'decoder/ff_factory.cc') 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 FFRegistry::Create(const string& ffname, const string& param) const { map >::const_iterator it = reg_.find(ffname); shared_ptr 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 "<second->Create(p); res->name=ffname; + res->debug=debug; } return res; } -- cgit v1.2.3