File size: 1,050 Bytes
158b61b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#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