2011-03-22 17:33:16 +03:00
|
|
|
#ifndef moses_PhrasePairFeature_h
|
|
|
|
#define moses_PhrasePairFeature_h
|
|
|
|
|
2012-09-21 14:56:01 +04:00
|
|
|
#include <stdexcept>
|
2013-05-27 03:33:01 +04:00
|
|
|
#include <boost/unordered_set.hpp>
|
2012-09-21 14:56:01 +04:00
|
|
|
|
2013-05-24 22:11:15 +04:00
|
|
|
#include "StatelessFeatureFunction.h"
|
2013-05-24 21:02:49 +04:00
|
|
|
#include "moses/Factor.h"
|
|
|
|
#include "moses/Sentence.h"
|
2012-03-19 06:45:59 +04:00
|
|
|
|
2013-05-29 21:16:15 +04:00
|
|
|
namespace Moses
|
|
|
|
{
|
2011-03-22 17:33:16 +03:00
|
|
|
|
|
|
|
/**
|
2012-03-07 15:48:58 +04:00
|
|
|
* Phrase pair feature: complete source/target phrase pair
|
2011-03-22 17:33:16 +03:00
|
|
|
**/
|
2013-05-29 21:16:15 +04:00
|
|
|
class PhrasePairFeature: public StatelessFeatureFunction
|
|
|
|
{
|
|
|
|
|
|
|
|
typedef std::map< char, short > CharHash;
|
|
|
|
typedef std::vector< std::set<std::string> > DocumentVector;
|
|
|
|
|
|
|
|
boost::unordered_set<std::string> m_vocabSource;
|
|
|
|
DocumentVector m_vocabDomain;
|
|
|
|
FactorType m_sourceFactorId;
|
|
|
|
FactorType m_targetFactorId;
|
|
|
|
bool m_unrestricted;
|
|
|
|
bool m_simple;
|
|
|
|
bool m_sourceContext;
|
|
|
|
bool m_domainTrigger;
|
|
|
|
bool m_ignorePunctuation;
|
|
|
|
CharHash m_punctuationHash;
|
2013-06-11 02:16:28 +04:00
|
|
|
std::string m_filePathSource;
|
2013-05-29 21:16:15 +04:00
|
|
|
|
|
|
|
public:
|
|
|
|
PhrasePairFeature(const std::string &line);
|
|
|
|
|
2013-05-30 15:41:08 +04:00
|
|
|
bool IsUseable(const FactorMask &mask) const;
|
|
|
|
|
2013-05-29 21:16:15 +04:00
|
|
|
void Evaluate(const PhraseBasedFeatureContext& context,
|
|
|
|
ScoreComponentCollection* accumulator) const;
|
|
|
|
|
|
|
|
void EvaluateChart(const ChartBasedFeatureContext& context,
|
|
|
|
ScoreComponentCollection*) const {
|
|
|
|
throw std::logic_error("PhrasePairFeature not valid in chart decoder");
|
|
|
|
}
|
|
|
|
|
2013-06-11 02:16:28 +04:00
|
|
|
void Load();
|
2013-06-20 16:25:02 +04:00
|
|
|
void SetParameter(const std::string& key, const std::string& value);
|
2012-07-26 20:32:50 +04:00
|
|
|
|
2011-03-22 17:33:16 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#endif
|