mosesdecoder/phrase-extract/extract-mixed-syntax/NonTerm.cpp

70 lines
1.4 KiB
C++
Raw Normal View History

/*
* NonTerm.cpp
*
* Created on: 22 Feb 2014
* Author: hieu
*/
#include <sstream>
#include "NonTerm.h"
#include "Word.h"
#include "ConsistentPhrase.h"
#include "Parameter.h"
using namespace std;
NonTerm::NonTerm(const ConsistentPhrase &consistentPhrase,
2015-01-15 14:18:39 +03:00
const std::string &source,
const std::string &target)
:m_consistentPhrase(&consistentPhrase)
,m_source(source)
,m_target(target)
{
2015-01-15 14:18:39 +03:00
// TODO Auto-generated constructor stub
}
2015-01-15 14:18:39 +03:00
NonTerm::~NonTerm()
{
// TODO Auto-generated destructor stub
}
std::string NonTerm::Debug() const
{
stringstream out;
out << m_source << m_target;
out << m_consistentPhrase->Debug();
return out.str();
}
void NonTerm::Output(std::ostream &out) const
{
out << m_source << m_target;
}
void NonTerm::Output(std::ostream &out, Moses::FactorDirection direction) const
{
2015-01-15 14:18:39 +03:00
out << GetLabel(direction);
}
const std::string &NonTerm::GetLabel(Moses::FactorDirection direction) const
{
return (direction == Moses::Input) ? m_source : m_target;
}
bool NonTerm::IsHiero(Moses::FactorDirection direction, const Parameter &params) const
{
2015-01-15 14:18:39 +03:00
const std::string &label = NonTerm::GetLabel(direction);
return label == params.hieroNonTerm;
}
bool NonTerm::IsHiero(const Parameter &params) const
{
2015-01-15 14:18:39 +03:00
return IsHiero(Moses::Input, params) && IsHiero(Moses::Output, params);
}
2014-08-30 10:44:53 +04:00
int NonTerm::GetWidth(Moses::FactorDirection direction) const
2015-01-15 14:18:39 +03:00
{
return GetConsistentPhrase().GetWidth(direction);
}