mosesdecoder/moses/PP/CountsPhraseProperty.cpp
Jeroen Vermeulen a9c8f44896 Modernize "C" includes in moses.
This is one of those little chores in managing a long-lived C++
project: standard C headers like stdio.h and math.h now have their own
place in the C++ standard as resp. cstdio, cmath, and so on.  In this
branch the #include names are updated for the moses/ subdirectory; more
branches to follow.

C++11 adds cstdint, but to support compilation with the previous
standard, that change is left for later.
2015-03-28 20:09:03 +07:00

39 lines
1.0 KiB
C++

#include "moses/PP/CountsPhraseProperty.h"
#include <sstream>
#include <cassert>
namespace Moses
{
void CountsPhraseProperty::ProcessValue(const std::string &value)
{
std::istringstream tokenizer(value);
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 );
};
std::ostream& operator<<(std::ostream &out, const CountsPhraseProperty &obj)
{
out << "Count property="
<< obj.GetTargetMarginal() << " "
<< obj.GetSourceMarginal() << " "
<< obj.GetJointCount();
return out;
}
} // namespace Moses