2014-06-11 23:02:31 +04:00
|
|
|
#include "moses/PP/CountsPhraseProperty.h"
|
|
|
|
#include <sstream>
|
2015-03-28 16:09:03 +03:00
|
|
|
#include <cassert>
|
2014-06-11 23:02:31 +04:00
|
|
|
|
|
|
|
namespace Moses
|
|
|
|
{
|
|
|
|
|
2014-06-13 19:37:13 +04:00
|
|
|
void CountsPhraseProperty::ProcessValue(const std::string &value)
|
2014-06-11 23:02:31 +04:00
|
|
|
{
|
2014-06-13 19:37:13 +04:00
|
|
|
std::istringstream tokenizer(value);
|
2014-06-11 23:02:31 +04:00
|
|
|
|
|
|
|
if (! (tokenizer >> m_targetMarginal)) { // first token: countE
|
|
|
|
UTIL_THROW2("CountsPhraseProperty: Not able to read target marginal. Flawed property?");
|
|
|
|
}
|
|
|
|
assert( m_targetMarginal > 0 );
|
|
|
|
|
|
|
|
if (! (tokenizer >> m_sourceMarginal)) { // first token: countF
|
|
|
|
UTIL_THROW2("CountsPhraseProperty: Not able to read source marginal. Flawed property?");
|
|
|
|
}
|
|
|
|
assert( m_sourceMarginal > 0 );
|
|
|
|
|
|
|
|
if (! (tokenizer >> m_jointCount)) { // first token: countEF
|
|
|
|
UTIL_THROW2("CountsPhraseProperty: Not able to read joint count. Flawed property?");
|
|
|
|
}
|
|
|
|
assert( m_jointCount > 0 );
|
|
|
|
};
|
|
|
|
|
2014-06-19 22:23:33 +04:00
|
|
|
std::ostream& operator<<(std::ostream &out, const CountsPhraseProperty &obj)
|
|
|
|
{
|
2015-01-14 14:07:42 +03:00
|
|
|
out << "Count property="
|
|
|
|
<< obj.GetTargetMarginal() << " "
|
|
|
|
<< obj.GetSourceMarginal() << " "
|
|
|
|
<< obj.GetJointCount();
|
|
|
|
return out;
|
2014-06-19 22:23:33 +04:00
|
|
|
}
|
|
|
|
|
2014-06-11 23:02:31 +04:00
|
|
|
} // namespace Moses
|
|
|
|
|