summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorgraehl <graehl@ec762483-ff6d-05da-a07a-a48fb63a330f>2010-08-07 05:18:55 +0000
committergraehl <graehl@ec762483-ff6d-05da-a07a-a48fb63a330f>2010-08-07 05:18:55 +0000
commit9ba05d189390e6a8ae1a1de67de9eee84babbaca (patch)
tree8328418bf8922e0d1e4d2e60ce21bc9d2fdd7174
parentdf7cae6928285c7902cd1f8a5244c9ffcc5ae499 (diff)
forgot to add
git-svn-id: https://ws10smt.googlecode.com/svn/trunk@488 ec762483-ff6d-05da-a07a-a48fb63a330f
-rwxr-xr-xdecoder/ff_register.h46
1 files changed, 46 insertions, 0 deletions
diff --git a/decoder/ff_register.h b/decoder/ff_register.h
new file mode 100755
index 00000000..f0828ca3
--- /dev/null
+++ b/decoder/ff_register.h
@@ -0,0 +1,46 @@
+#ifndef FF_FSA_REGISTER_H
+#define FF_FSA_REGISTER_H
+
+#include "ff_factory.h"
+#include "ff_from_fsa.h"
+#include "ff_fsa_dynamic.h"
+
+inline std::string prefix_fsa(std::string const& name,bool fsa_prefix_ff) {
+ return fsa_prefix_ff ? "Fsa"+name : name;
+}
+
+//FIXME: problem with FeatureFunctionFromFsa<FsaFeatureFunction> - need to use factory rather than ctor.
+#if 0
+template <class DynFsa>
+inline void RegisterFsa(bool ff_also=true,bool fsa_prefix_ff=true) {
+ assert(!ff_also);
+// global_fsa_ff_registry->RegisterFsa<DynFsa>();
+//if (ff_also) ff_registry.RegisterFF<FeatureFunctionFromFsa<DynFsa> >(prefix_fsa(DynFsa::usage(false,false)),fsa_prefix_ff);
+}
+#endif
+
+//TODO: ff from fsa that uses pointer to fsa impl? e.g. in LanguageModel we share underlying lm file by recognizing same param, but without that effort, otherwise stateful ff may duplicate state if we enable both fsa and ff_from_fsa
+template <class FsaImpl>
+inline void RegisterFsaImpl(bool ff_also=true,bool fsa_prefix_ff=false) {
+ typedef FsaFeatureFunctionDynamic<FsaImpl> DynFsa;
+ typedef FeatureFunctionFromFsa<FsaImpl> FFFrom;
+ std::string name=FsaImpl::usage(false,false);
+ fsa_ff_registry.Register(new FsaFactory<DynFsa>);
+ if (ff_also)
+ ff_registry.Register(prefix_fsa(name,fsa_prefix_ff),new FFFactory<FFFrom>);
+}
+
+template <class Impl>
+inline void RegisterFF() {
+ ff_registry.Register(new FFFactory<Impl>);
+}
+
+template <class FsaImpl>
+inline void RegisterFsaDynToFF(bool prefix=true) {
+ typedef FsaFeatureFunctionDynamic<FsaImpl> DynFsa;
+ std::string name=FsaImpl::usage(false,false);
+ ff_registry.Register(prefix?"DynamicFsa"+name:name,new FFFactory<FeatureFunctionFromFsa<DynFsa> >);
+}
+
+
+#endif