diff options
author | Matthias Huck <huck@i6.informatik.rwth-aachen.de> | 2014-08-08 00:43:09 +0400 |
---|---|---|
committer | Matthias Huck <huck@i6.informatik.rwth-aachen.de> | 2014-08-08 00:43:09 +0400 |
commit | d1706a54dde3856c7598d9b00963a1592d97fd4f (patch) | |
tree | ca75ad9e5c0a20022ac63a0b392c579c82cb77b0 /moses/PP | |
parent | 3da03f4459db9ad50a60b46f4bb8cc0251faa0f7 (diff) |
OrientationPhraseProperty
Diffstat (limited to 'moses/PP')
-rw-r--r-- | moses/PP/OrientationPhraseProperty.cpp | 26 | ||||
-rw-r--r-- | moses/PP/OrientationPhraseProperty.h | 65 |
2 files changed, 91 insertions, 0 deletions
diff --git a/moses/PP/OrientationPhraseProperty.cpp b/moses/PP/OrientationPhraseProperty.cpp new file mode 100644 index 000000000..653a1bf3b --- /dev/null +++ b/moses/PP/OrientationPhraseProperty.cpp @@ -0,0 +1,26 @@ +#include "moses/PP/OrientationPhraseProperty.h" +#include <iostream> + + +namespace Moses +{ + +void OrientationPhraseProperty::ProcessValue(const std::string &value) +{ + // bidirectional MSLR phrase orientation with 2x4 orientation classes: + // mono swap dright dleft + + std::istringstream tokenizer(value); + + try { + if (! (tokenizer >> m_l2rMonoProbability >> m_l2rSwapProbability >> m_l2rDrightProbability >> m_l2rDleftProbability + >> m_r2lMonoProbability >> m_r2lSwapProbability >> m_r2lDrightProbability >> m_r2lDleftProbability)) { + UTIL_THROW2("OrientationPhraseProperty: Not able to read value. Flawed property?"); + } + } catch (const std::exception &e) { + UTIL_THROW2("OrientationPhraseProperty: Read error. Flawed property?"); + } +}; + +} // namespace Moses + diff --git a/moses/PP/OrientationPhraseProperty.h b/moses/PP/OrientationPhraseProperty.h new file mode 100644 index 000000000..32c6ff208 --- /dev/null +++ b/moses/PP/OrientationPhraseProperty.h @@ -0,0 +1,65 @@ + +#pragma once + +#include "moses/PP/PhraseProperty.h" +#include "util/exception.hh" +#include <string> + +namespace Moses +{ + +class OrientationPhraseProperty : public PhraseProperty +{ +public: + OrientationPhraseProperty() {}; + + virtual void ProcessValue(const std::string &value); + + + double GetLeftToRightProbabilityMono() const { + return m_l2rMonoProbability; + }; + + double GetLeftToRightProbabilitySwap() const { + return m_l2rSwapProbability; + }; + + double GetLeftToRightProbabilityDright() const { + return m_l2rDrightProbability; + }; + + double GetLeftToRightProbabilityDleft() const { + return m_l2rDleftProbability; + }; + + + double GetRightToLeftProbabilityMono() const { + return m_r2lMonoProbability; + }; + + double GetRightToLeftProbabilitySwap() const { + return m_r2lSwapProbability; + }; + + double GetRightToLeftProbabilityDright() const { + return m_r2lDrightProbability; + }; + + double GetRightToLeftProbabilityDleft() const { + return m_r2lDleftProbability; + }; + + + virtual const std::string *GetValueString() const { + UTIL_THROW2("OrientationPhraseProperty: value string not available in this phrase property"); + return NULL; + }; + +protected: + + float m_l2rMonoProbability, m_l2rSwapProbability, m_l2rDrightProbability, m_l2rDleftProbability, + m_r2lMonoProbability, m_r2lSwapProbability, m_r2lDrightProbability, m_r2lDleftProbability; +}; + +} // namespace Moses + |