diff options
author | Hieu Hoang <hieu@hoang.co.uk> | 2014-06-13 20:08:22 +0400 |
---|---|---|
committer | Hieu Hoang <hieu@hoang.co.uk> | 2014-06-13 20:08:22 +0400 |
commit | 5c5770266461a6189d9e890deaf950b9ca002c7d (patch) | |
tree | 403b9c779fec19a4db8a4ef1d78bc4ea4e68f58b /moses/PP | |
parent | ab3ed27f2054e1bafa6ebbde5d2f756a2cd8e73c (diff) | |
parent | 6cffb39bd664e1d4dfddd32759dca30347e7ffed (diff) |
merge
Diffstat (limited to 'moses/PP')
-rw-r--r-- | moses/PP/CountsPhraseProperty.cpp | 6 | ||||
-rw-r--r-- | moses/PP/CountsPhraseProperty.h | 10 | ||||
-rw-r--r-- | moses/PP/Factory.cpp | 5 | ||||
-rw-r--r-- | moses/PP/PhraseProperty.h | 8 | ||||
-rw-r--r-- | moses/PP/SourceLabelsPhraseProperty.cpp | 5 | ||||
-rw-r--r-- | moses/PP/SourceLabelsPhraseProperty.h | 10 | ||||
-rw-r--r-- | moses/PP/TreeStructurePhraseProperty.h | 2 |
7 files changed, 27 insertions, 19 deletions
diff --git a/moses/PP/CountsPhraseProperty.cpp b/moses/PP/CountsPhraseProperty.cpp index f7af18d5b..def07e5da 100644 --- a/moses/PP/CountsPhraseProperty.cpp +++ b/moses/PP/CountsPhraseProperty.cpp @@ -1,14 +1,13 @@ #include "moses/PP/CountsPhraseProperty.h" #include <sstream> #include <assert.h> -#include "util/exception.hh" namespace Moses { -void CountsPhraseProperty::ProcessValue() +void CountsPhraseProperty::ProcessValue(const std::string &value) { - std::istringstream tokenizer(m_value); + std::istringstream tokenizer(value); if (! (tokenizer >> m_targetMarginal)) { // first token: countE UTIL_THROW2("CountsPhraseProperty: Not able to read target marginal. Flawed property?"); @@ -24,7 +23,6 @@ void CountsPhraseProperty::ProcessValue() UTIL_THROW2("CountsPhraseProperty: Not able to read joint count. Flawed property?"); } assert( m_jointCount > 0 ); - }; } // namespace Moses diff --git a/moses/PP/CountsPhraseProperty.h b/moses/PP/CountsPhraseProperty.h index f633381b6..19382fe29 100644 --- a/moses/PP/CountsPhraseProperty.h +++ b/moses/PP/CountsPhraseProperty.h @@ -2,6 +2,7 @@ #pragma once #include "moses/PP/PhraseProperty.h" +#include "util/exception.hh" #include <string> #include <list> @@ -28,9 +29,9 @@ class CountsPhraseProperty : public PhraseProperty { public: - CountsPhraseProperty(const std::string &value) : PhraseProperty(value) {}; + CountsPhraseProperty() {}; - virtual void ProcessValue(); + virtual void ProcessValue(const std::string &value); size_t GetSourceMarginal() const { return m_sourceMarginal; @@ -44,6 +45,11 @@ public: return m_jointCount; } + virtual const std::string *GetValueString() const { + UTIL_THROW2("CountsPhraseProperty: value string not available in this phrase property"); + return NULL; + }; + protected: float m_sourceMarginal, m_targetMarginal, m_jointCount; diff --git a/moses/PP/Factory.cpp b/moses/PP/Factory.cpp index fe907f5c8..497eabaff 100644 --- a/moses/PP/Factory.cpp +++ b/moses/PP/Factory.cpp @@ -37,8 +37,8 @@ template <class P> class DefaultPhrasePropertyCreator : public PhrasePropertyCre { public: boost::shared_ptr<PhraseProperty> CreateProperty(const std::string &value) { - P* property = new P(value); - property->ProcessValue(); + P* property = new P(); + property->ProcessValue(value); return Create(property); } }; @@ -57,7 +57,6 @@ PhrasePropertyFactory::PhrasePropertyFactory() MOSES_PNAME2("SourceLabels", SourceLabelsPhraseProperty); MOSES_PNAME2("Tree",TreeStructurePhraseProperty); MOSES_PNAME2("SpanLength", SpanLengthPhraseProperty); - } PhrasePropertyFactory::~PhrasePropertyFactory() diff --git a/moses/PP/PhraseProperty.h b/moses/PP/PhraseProperty.h index a4353e634..36de46033 100644 --- a/moses/PP/PhraseProperty.h +++ b/moses/PP/PhraseProperty.h @@ -11,15 +11,15 @@ namespace Moses class PhraseProperty { public: - PhraseProperty(const std::string &value) : m_value(value) {}; + PhraseProperty() {}; - virtual void ProcessValue() {}; + virtual void ProcessValue(const std::string &value) { m_value = new std::string(value); }; - const std::string &GetValueString() const { return m_value; }; + virtual const std::string *GetValueString() const { return m_value; }; protected: - const std::string m_value; + std::string *m_value; }; diff --git a/moses/PP/SourceLabelsPhraseProperty.cpp b/moses/PP/SourceLabelsPhraseProperty.cpp index 6f18480c5..bca5c9a30 100644 --- a/moses/PP/SourceLabelsPhraseProperty.cpp +++ b/moses/PP/SourceLabelsPhraseProperty.cpp @@ -7,14 +7,13 @@ #include <queue> #include <assert.h> #include <limits> -#include "util/exception.hh" namespace Moses { -void SourceLabelsPhraseProperty::ProcessValue() +void SourceLabelsPhraseProperty::ProcessValue(const std::string &value) { - std::istringstream tokenizer(m_value); + std::istringstream tokenizer(value); if (! (tokenizer >> m_nNTs)) { // first token: number of non-terminals (incl. left-hand side) UTIL_THROW2("SourceLabelsPhraseProperty: Not able to read number of non-terminals. Flawed property?"); diff --git a/moses/PP/SourceLabelsPhraseProperty.h b/moses/PP/SourceLabelsPhraseProperty.h index 049d88f17..39b43ad3e 100644 --- a/moses/PP/SourceLabelsPhraseProperty.h +++ b/moses/PP/SourceLabelsPhraseProperty.h @@ -2,6 +2,7 @@ #pragma once #include "moses/PP/PhraseProperty.h" +#include "util/exception.hh" #include <string> #include <list> @@ -43,9 +44,9 @@ private: class SourceLabelsPhraseProperty : public PhraseProperty { public: - SourceLabelsPhraseProperty(const std::string &value) : PhraseProperty(value) {}; + SourceLabelsPhraseProperty() {}; - virtual void ProcessValue(); + virtual void ProcessValue(const std::string &value); size_t GetNumberOfNonTerminals() const { return m_nNTs; @@ -59,6 +60,11 @@ public: return m_sourceLabelItems; }; + virtual const std::string *GetValueString() const { + UTIL_THROW2("SourceLabelsPhraseProperty: value string not available in this phrase property"); + return NULL; + }; + protected: size_t m_nNTs; diff --git a/moses/PP/TreeStructurePhraseProperty.h b/moses/PP/TreeStructurePhraseProperty.h index f9acc38dd..45124973f 100644 --- a/moses/PP/TreeStructurePhraseProperty.h +++ b/moses/PP/TreeStructurePhraseProperty.h @@ -10,7 +10,7 @@ namespace Moses class TreeStructurePhraseProperty : public PhraseProperty { public: - TreeStructurePhraseProperty(const std::string &value) : PhraseProperty(value) {}; + TreeStructurePhraseProperty() {}; }; |