From 6c0e5139068b8e92a10445b7e19f4878443ade03 Mon Sep 17 00:00:00 2001 From: Patrick Simianer Date: Fri, 26 Apr 2013 15:30:44 +0200 Subject: added Gesa's alternative source syntax features --- decoder/ff_source_syntax2_p.h | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 decoder/ff_source_syntax2_p.h (limited to 'decoder/ff_source_syntax2_p.h') diff --git a/decoder/ff_source_syntax2_p.h b/decoder/ff_source_syntax2_p.h new file mode 100644 index 00000000..b6b7dc3d --- /dev/null +++ b/decoder/ff_source_syntax2_p.h @@ -0,0 +1,25 @@ +#ifndef _FF_SOURCE_TOOLS2_H_ +#define _FF_SOURCE_TOOLS2_H_ + +#include "ff.h" +#include "hg.h" + +struct SourceSyntaxFeatures2Impl; + +class SourceSyntaxFeatures2 : public FeatureFunction { + public: + SourceSyntaxFeatures2(const std::string& param); + ~SourceSyntaxFeatures2(); + protected: + virtual void TraversalFeaturesImpl(const SentenceMetadata& smeta, + const Hypergraph::Edge& edge, + const std::vector& ant_contexts, + SparseVector* features, + SparseVector* estimated_features, + void* context) const; + virtual void PrepareForInput(const SentenceMetadata& smeta); + private: + SourceSyntaxFeatures2Impl* impl; +}; + +#endif -- cgit v1.2.3 From 46f2a84ae599fdf53c70519950873df4318a16b1 Mon Sep 17 00:00:00 2001 From: Patrick Simianer Date: Mon, 29 Apr 2013 11:01:38 +0200 Subject: added (broken) variant of a feature --- decoder/Makefile.am | 13 +++---------- decoder/cdec_ff.cc | 24 +++++++++++++++++++----- decoder/ff_source_syntax2_p.cc | 14 +++++++------- decoder/ff_source_syntax2_p.h | 10 +++++----- 4 files changed, 34 insertions(+), 27 deletions(-) (limited to 'decoder/ff_source_syntax2_p.h') diff --git a/decoder/Makefile.am b/decoder/Makefile.am index a93a5dbe..00f8b5f9 100644 --- a/decoder/Makefile.am +++ b/decoder/Makefile.am @@ -142,20 +142,13 @@ libcdec_a_SOURCES = \ ff_csplit.cc \ ff_tagger.cc \ ff_source_path.cc \ - ff_source_syntax.h \ + ff_parse_match.cc \ + ff_soft_syntax.cc \ + ff_soft_syntax2.cc \ ff_source_syntax.cc \ - ff_source_syntax_p.h \ ff_source_syntax_p.cc \ - ff_source_syntax2.h \ ff_source_syntax2.cc \ - ff_source_syntax2_p.h \ ff_source_syntax2_p.cc \ - ff_parse_match.cc \ - ff_parse_match.h \ - ff_soft_syntax.cc \ - ff_soft_syntax.h \ - ff_soft_syntax2.cc \ - ff_soft_syntax2.h \ ff_bleu.cc \ ff_factory.cc \ incremental.cc \ diff --git a/decoder/cdec_ff.cc b/decoder/cdec_ff.cc index 186c4de3..bbb83258 100644 --- a/decoder/cdec_ff.cc +++ b/decoder/cdec_ff.cc @@ -17,11 +17,15 @@ #include "ff_soft_syntax.h" #include "ff_soft_syntax2.h" #include "ff_source_path.h" + + +#include "ff_parse_match.h" #include "ff_source_syntax.h" #include "ff_source_syntax_p.h" #include "ff_source_syntax2.h" #include "ff_source_syntax2_p.h" -#include "ff_parse_match.h" + + #include "ff_register.h" #include "ff_charset.h" #include "ff_wordset.h" @@ -54,14 +58,24 @@ void register_feature_functions() { ff_registry.Register("NgramFeatures", new FFFactory()); ff_registry.Register("RuleContextFeatures", new FFFactory()); ff_registry.Register("RuleIdentityFeatures", new FFFactory()); - ff_registry.Register("SoftSyntactcFeatures", new FFFactory); - ff_registry.Register("SoftSyntcticFeatures2", new FFFactory); + + + ff_registry.Register("ParseMatchFeatures", new FFFactory); + + ff_registry.Register("SoftSyntacticFeatures", new FFFactory); + ff_registry.Register("SoftSyntacticFeatures2", new FFFactory); + ff_registry.Register("SourceSyntaxFeatures", new FFFactory); - //ff_registry.Register("PSourceSyntaxFeatures", new FFFactory); ff_registry.Register("SourceSyntaxFeatures2", new FFFactory); - ff_registry.Register("ParseMatchFeatures", new FFFactory); + ff_registry.Register("SourceSpanSizeFeatures", new FFFactory); + + //ff_registry.Register("PSourceSyntaxFeatures", new FFFactory); //ff_registry.Register("PSourceSpanSizeFeatures", new FFFactory); + ff_registry.Register("PSourceSyntaxFeatures2", new FFFactory); + + + ff_registry.Register("CMR2008ReorderingFeatures", new FFFactory()); ff_registry.Register("RuleSourceBigramFeatures", new FFFactory()); ff_registry.Register("RuleTargetBigramFeatures", new FFFactory()); diff --git a/decoder/ff_source_syntax2_p.cc b/decoder/ff_source_syntax2_p.cc index 3517b87f..dfa791ea 100644 --- a/decoder/ff_source_syntax2_p.cc +++ b/decoder/ff_source_syntax2_p.cc @@ -15,8 +15,8 @@ using namespace std; // source trees must be represented in Penn Treebank format, e.g. // (S (NP John) (VP (V left))) -struct SourceSyntaxFeatures2Impl { - SourceSyntaxFeatures2Impl(const string& param) { +struct PSourceSyntaxFeatures2Impl { + PSourceSyntaxFeatures2Impl(const string& param) { if (param.compare("") != 0) { string triggered_features_fn = param; ReadFile triggered_features(triggered_features_fn); @@ -137,17 +137,17 @@ struct SourceSyntaxFeatures2Impl { }; -SourceSyntaxFeatures2::SourceSyntaxFeatures2(const string& param) : +PSourceSyntaxFeatures2::PSourceSyntaxFeatures2(const string& param) : FeatureFunction(sizeof(WordID)) { - impl = new SourceSyntaxFeatures2Impl(param); + impl = new PSourceSyntaxFeatures2Impl(param); } -SourceSyntaxFeatures2::~SourceSyntaxFeatures2() { +PSourceSyntaxFeatures2::~PSourceSyntaxFeatures2() { delete impl; impl = NULL; } -void SourceSyntaxFeatures2::TraversalFeaturesImpl(const SentenceMetadata& smeta, +void PSourceSyntaxFeatures2::TraversalFeaturesImpl(const SentenceMetadata& smeta, const Hypergraph::Edge& edge, const vector& ant_contexts, SparseVector* features, @@ -161,6 +161,6 @@ void SourceSyntaxFeatures2::TraversalFeaturesImpl(const SentenceMetadata& smeta, impl->FireFeatures(*edge.rule_, edge.i_, edge.j_, ants, features); } -void SourceSyntaxFeatures2::PrepareForInput(const SentenceMetadata& smeta) { +void PSourceSyntaxFeatures2::PrepareForInput(const SentenceMetadata& smeta) { impl->InitializeGrids(smeta.GetSGMLValue("src_tree"), smeta.GetSourceLength()); } diff --git a/decoder/ff_source_syntax2_p.h b/decoder/ff_source_syntax2_p.h index b6b7dc3d..d56ecab0 100644 --- a/decoder/ff_source_syntax2_p.h +++ b/decoder/ff_source_syntax2_p.h @@ -4,12 +4,12 @@ #include "ff.h" #include "hg.h" -struct SourceSyntaxFeatures2Impl; +struct PSourceSyntaxFeatures2Impl; -class SourceSyntaxFeatures2 : public FeatureFunction { +class PSourceSyntaxFeatures2 : public FeatureFunction { public: - SourceSyntaxFeatures2(const std::string& param); - ~SourceSyntaxFeatures2(); + PSourceSyntaxFeatures2(const std::string& param); + ~PSourceSyntaxFeatures2(); protected: virtual void TraversalFeaturesImpl(const SentenceMetadata& smeta, const Hypergraph::Edge& edge, @@ -19,7 +19,7 @@ class SourceSyntaxFeatures2 : public FeatureFunction { void* context) const; virtual void PrepareForInput(const SentenceMetadata& smeta); private: - SourceSyntaxFeatures2Impl* impl; + PSourceSyntaxFeatures2Impl* impl; }; #endif -- cgit v1.2.3