summaryrefslogtreecommitdiff
path: root/decoder/ff_fsa_dynamic.h
diff options
context:
space:
mode:
authorgraehl <graehl@ec762483-ff6d-05da-a07a-a48fb63a330f>2010-08-07 02:24:51 +0000
committergraehl <graehl@ec762483-ff6d-05da-a07a-a48fb63a330f>2010-08-07 02:24:51 +0000
commitf86133971c2bf97ac53873e28adf05c863c72b49 (patch)
tree009c510b1cfa9b55fded88fa792be094f7cb8324 /decoder/ff_fsa_dynamic.h
parentf9d54fd08e217c7bca19f7c821a64d8ae9d81a2a (diff)
propagation of feature name+debug from factory, return correct features array for fsa ffs
git-svn-id: https://ws10smt.googlecode.com/svn/trunk@486 ec762483-ff6d-05da-a07a-a48fb63a330f
Diffstat (limited to 'decoder/ff_fsa_dynamic.h')
-rwxr-xr-xdecoder/ff_fsa_dynamic.h29
1 files changed, 24 insertions, 5 deletions
diff --git a/decoder/ff_fsa_dynamic.h b/decoder/ff_fsa_dynamic.h
index 2a26676d..d03fddee 100755
--- a/decoder/ff_fsa_dynamic.h
+++ b/decoder/ff_fsa_dynamic.h
@@ -26,10 +26,14 @@ struct FsaFeatureFunction : public FsaFeatureFunctionData {
virtual void *ScanPhraseAccumBounce(SentenceMetadata const& smeta,Hypergraph::Edge const& edge,WordID const* i, WordID const* end,void *cs,void *ns,Accum *accum) const = 0;
virtual int early_score_words(SentenceMetadata const& smeta,Hypergraph::Edge const& edge,WordID const* i, WordID const* end,Accum *accum) const { return 0; }
+ // called after constructor, before use
+ virtual void Init() = 0;
virtual std::string usage_v(bool param,bool verbose) const {
return FeatureFunction::usage_helper("unnamed_dynamic_fsa_feature","","",param,verbose);
}
-
+ virtual void init_name_debug(std::string const& n,bool debug) {
+ FsaFeatureFunctionData::init_name_debug(n,debug);
+ }
virtual void print_state(std::ostream &o,void const*state) const {
FsaFeatureFunctionData::print_state(o,state);
@@ -49,10 +53,13 @@ struct FsaFeatureFunction : public FsaFeatureFunctionData {
// you might be wondering: why do this? answer: it's cool, and it means that the bottom-up ff over ff_fsa wrapper doesn't go through multiple layers of dynamic dispatch
// usage: typedef FsaFeatureFunctionDynamic<MyFsa> MyFsaDyn;
template <class Impl>
-struct FsaFeatureFunctionDynamic : public FsaFeatureFunction,Impl {
+struct FsaFeatureFunctionDynamic : public FsaFeatureFunction {
static const bool simple_phrase_score=Impl::simple_phrase_score;
- Impl& d() { return static_cast<Impl&>(*this); }
- Impl const& d() const { return static_cast<Impl const&>(*this); }
+ Impl& d() { return impl;//static_cast<Impl&>(*this);
+ }
+ Impl const& d() const { return impl;
+ //static_cast<Impl const&>(*this);
+ }
int markov_order() const { return d().markov_order(); }
virtual void ScanAccum(SentenceMetadata const& smeta,Hypergraph::Edge const& edge,
@@ -92,11 +99,23 @@ struct FsaFeatureFunctionDynamic : public FsaFeatureFunction,Impl {
return d().print_state(o,state);
}
- FsaFeatureFunctionDynamic(std::string const& param) : Impl(param) {
+ void init_name_debug(std::string const& n,bool debug) {
+ FsaFeatureFunction::init_name_debug(n,debug);
+ d().init_name_debug(n,debug);
+ }
+
+ virtual void Init() {
d().sync_to_=(FsaFeatureFunction*)this;
+ d().Init();
d().sync();
}
+ FsaFeatureFunctionDynamic(std::string const& param) : impl(param) {
+ Init();
+ }
+private:
+ Impl impl;
+
};