00001 #include "moses/PP/CountsPhraseProperty.h" 00002 #include <sstream> 00003 #include <cassert> 00004 00005 namespace Moses 00006 { 00007 00008 void CountsPhraseProperty::ProcessValue(const std::string &value) 00009 { 00010 std::istringstream tokenizer(value); 00011 00012 if (! (tokenizer >> m_targetMarginal)) { // first token: countE 00013 UTIL_THROW2("CountsPhraseProperty: Not able to read target marginal. Flawed property?"); 00014 } 00015 assert( m_targetMarginal > 0 ); 00016 00017 if (! (tokenizer >> m_sourceMarginal)) { // first token: countF 00018 UTIL_THROW2("CountsPhraseProperty: Not able to read source marginal. Flawed property?"); 00019 } 00020 assert( m_sourceMarginal > 0 ); 00021 00022 if (! (tokenizer >> m_jointCount)) { // first token: countEF 00023 UTIL_THROW2("CountsPhraseProperty: Not able to read joint count. Flawed property?"); 00024 } 00025 assert( m_jointCount > 0 ); 00026 }; 00027 00028 std::ostream& operator<<(std::ostream &out, const CountsPhraseProperty &obj) 00029 { 00030 out << "Count property=" 00031 << obj.GetTargetMarginal() << " " 00032 << obj.GetSourceMarginal() << " " 00033 << obj.GetJointCount(); 00034 return out; 00035 } 00036 00037 } // namespace Moses 00038