2011-05-11 02:02:25 +04:00
|
|
|
#ifndef moses_PhraseBoundaryFeature_h
|
|
|
|
#define moses_PhraseBoundaryFeature_h
|
|
|
|
|
2013-05-24 16:04:39 +04:00
|
|
|
#include <stdexcept>
|
2011-05-11 02:02:25 +04:00
|
|
|
#include <sstream>
|
|
|
|
#include <string>
|
|
|
|
|
2013-05-24 22:11:15 +04:00
|
|
|
#include "StatefulFeatureFunction.h"
|
2013-05-24 21:02:49 +04:00
|
|
|
#include "moses/FF/FFState.h"
|
|
|
|
#include "moses/Word.h"
|
2011-05-11 02:02:25 +04:00
|
|
|
|
|
|
|
namespace Moses
|
|
|
|
{
|
|
|
|
|
2013-05-29 21:16:15 +04:00
|
|
|
class PhraseBoundaryState : public FFState
|
|
|
|
{
|
2011-05-11 02:02:25 +04:00
|
|
|
public:
|
2011-06-24 17:06:58 +04:00
|
|
|
PhraseBoundaryState(const Word* sourceWord, const Word* targetWord) :
|
2013-05-29 21:16:15 +04:00
|
|
|
m_sourceWord(sourceWord), m_targetWord(targetWord) {}
|
|
|
|
const Word* GetSourceWord() const {
|
|
|
|
return m_sourceWord;
|
|
|
|
}
|
|
|
|
const Word* GetTargetWord() const {
|
|
|
|
return m_targetWord;
|
|
|
|
}
|
2015-10-14 17:21:37 +03:00
|
|
|
virtual size_t hash() const;
|
|
|
|
virtual bool operator==(const FFState& other) const;
|
2015-10-08 19:14:08 +03:00
|
|
|
|
2011-05-11 02:02:25 +04:00
|
|
|
|
|
|
|
private:
|
2011-06-24 17:06:58 +04:00
|
|
|
const Word* m_sourceWord;
|
|
|
|
const Word* m_targetWord;
|
2011-05-11 02:02:25 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Concatenations of factors on boundaries of phrases.
|
|
|
|
**/
|
2013-05-29 21:16:15 +04:00
|
|
|
class PhraseBoundaryFeature : public StatefulFeatureFunction
|
|
|
|
{
|
2011-05-11 02:02:25 +04:00
|
|
|
public:
|
2013-01-02 20:06:22 +04:00
|
|
|
PhraseBoundaryFeature(const std::string &line);
|
2011-05-11 02:02:25 +04:00
|
|
|
|
2013-05-30 15:41:08 +04:00
|
|
|
bool IsUseable(const FactorMask &mask) const;
|
2011-05-11 02:02:25 +04:00
|
|
|
|
2011-08-22 17:52:02 +04:00
|
|
|
virtual const FFState* EmptyHypothesisState(const InputType &) const;
|
2011-05-11 02:02:25 +04:00
|
|
|
|
2014-07-10 02:41:08 +04:00
|
|
|
virtual FFState* EvaluateWhenApplied(const Hypothesis& cur_hypo, const FFState* prev_state,
|
2015-01-14 14:07:42 +03:00
|
|
|
ScoreComponentCollection* accumulator) const;
|
2011-05-11 02:02:25 +04:00
|
|
|
|
2014-07-10 02:54:16 +04:00
|
|
|
virtual FFState* EvaluateWhenApplied( const ChartHypothesis& /* cur_hypo */,
|
2015-01-14 14:07:42 +03:00
|
|
|
int /* featureID */,
|
|
|
|
ScoreComponentCollection* ) const {
|
2013-05-24 16:04:39 +04:00
|
|
|
throw std::logic_error("PhraseBoundaryState not supported in chart decoder, yet");
|
|
|
|
}
|
2013-08-30 18:49:00 +04:00
|
|
|
|
2013-06-20 16:25:02 +04:00
|
|
|
void SetParameter(const std::string& key, const std::string& value);
|
2013-05-24 16:04:39 +04:00
|
|
|
|
2011-05-11 02:02:25 +04:00
|
|
|
private:
|
|
|
|
void AddFeatures(
|
2013-05-29 21:16:15 +04:00
|
|
|
const Word* leftWord, const Word* rightWord, const FactorList& factors,
|
2011-05-11 02:02:25 +04:00
|
|
|
const std::string& side, ScoreComponentCollection* scores) const ;
|
|
|
|
FactorList m_sourceFactors;
|
|
|
|
FactorList m_targetFactors;
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#endif
|