diff options
author | maria nadejde <maria.nadejde@gmail.com> | 2013-09-12 20:46:40 +0400 |
---|---|---|
committer | maria nadejde <maria.nadejde@gmail.com> | 2013-09-12 20:46:40 +0400 |
commit | 43a9323d0fa68d49c1a2d0f0c8c50ef758d80baf (patch) | |
tree | ffe292215478d8fdf8c63683d2666dbb2fbca531 /phrase-extract | |
parent | b036a038d53289f4b908b7e83201135225b2514e (diff) |
add feature files
Diffstat (limited to 'phrase-extract')
-rw-r--r-- | phrase-extract/InternalStructFeature.cpp | 46 | ||||
-rw-r--r-- | phrase-extract/InternalStructFeature.h | 66 |
2 files changed, 112 insertions, 0 deletions
diff --git a/phrase-extract/InternalStructFeature.cpp b/phrase-extract/InternalStructFeature.cpp new file mode 100644 index 000000000..160a0baa2 --- /dev/null +++ b/phrase-extract/InternalStructFeature.cpp @@ -0,0 +1,46 @@ +#include "InternalStructFeature.h" + +using namespace std; + +namespace MosesTraining +{ + +InternalStructFeature::InternalStructFeature() + :m_type(0){ + cout<<"InternalStructFeature: Construct "<<m_type<<"\n"; +} + +bool InternalStructFeature::equals(const PhraseAlignment& lhs, const PhraseAlignment& rhs) const{ + cout<<"InternalStructFeature: Equals\n"; + //don't know what it's used for and what we should compare + //-> if the dense score is the same + //-> if the sparse feature is set + // compare phrases? with the internalStrucutre string? + /** Return true if the two phrase pairs are equal from the point of this feature. Assume + that they already compare true according to PhraseAlignment.equals() + **/ + return true; +} + +void InternalStructFeature::add(const ScoreFeatureContext& context, + std::vector<float>& denseValues, + std::map<std::string,float>& sparseValues) const{ + std::string *internalStruct=new string("(NP((DT)(NN)))"); + add(internalStruct, denseValues, sparseValues); +} + +void InternalStructFeatureDense::add(std::string *internalStruct, + std::vector<float>& denseValues, + std::map<std::string,float>& sparseValues) const{ + cout<<internalStruct<<endl; + +} + +void InternalStructFeatureSparse::add(std::string *internalStruct, + std::vector<float>& denseValues, + std::map<std::string,float>& sparseValues) const{ + cout<<internalStruct<<endl; +} + + +} diff --git a/phrase-extract/InternalStructFeature.h b/phrase-extract/InternalStructFeature.h new file mode 100644 index 000000000..353808ef2 --- /dev/null +++ b/phrase-extract/InternalStructFeature.h @@ -0,0 +1,66 @@ +#include <iostream> +#include <fstream> +#include <assert.h> +#include <stdlib.h> +#include <string> +#include <queue> +#include <map> +#include <cmath> + +#include "ScoreFeature.h" +#include "extract-ghkm/Node.h" + +using namespace MosesTraining; +using namespace Moses; +using namespace GHKM; + +namespace MosesTraining +{ + + +class InternalStructFeature : public ScoreFeature +{ +public: + InternalStructFeature(); + /** Return true if the two phrase pairs are equal from the point of this feature. Assume + that they already compare true according to PhraseAlignment.equals() + **/ + bool equals(const PhraseAlignment& lhs, const PhraseAlignment& rhs) const; + /** Add the values for this feature function. */ + void add(const ScoreFeatureContext& context, + std::vector<float>& denseValues, + std::map<std::string,float>& sparseValues) const; + + +protected: + /** Overriden in subclass */ + virtual void add(std::string *internalStruct, + std::vector<float>& denseValues, + std::map<std::string,float>& sparseValues) const; + int m_type; + +}; + +class InternalStructFeatureDense : public InternalStructFeature +{ +public: + InternalStructFeatureDense() + :InternalStructFeature(){m_type=1; std::cout<<"InternalStructFeatureDense: Construct "<<m_type<<"\n";} +protected: + virtual void add(std::string *internalStruct, + std::vector<float>& denseValues, + std::map<std::string,float>& sparseValues) const; +}; + +class InternalStructFeatureSparse : public InternalStructFeature +{ +public: + InternalStructFeatureSparse() + :InternalStructFeature(){m_type=2; std::cout<<"InternalStructFeatureSparse: Construct "<<m_type<<"\n";} +protected: + virtual void add(std::string *internalStruct, + std::vector<float>& denseValues, + std::map<std::string,float>& sparseValues) const; +}; + +} |