2011-05-13 23:28:23 +04:00
|
|
|
//
|
|
|
|
|
|
|
|
#ifndef moses_SyntacticLanguageModel_h
|
|
|
|
#define moses_SyntacticLanguageModel_h
|
|
|
|
|
|
|
|
#include "FeatureFunction.h"
|
2012-03-31 00:21:39 +04:00
|
|
|
#include <stdexcept>
|
2011-05-13 23:28:23 +04:00
|
|
|
|
|
|
|
class YModel; // hidden model
|
|
|
|
class XModel; // observed model
|
|
|
|
|
|
|
|
namespace Moses
|
|
|
|
{
|
|
|
|
|
2013-05-29 21:16:15 +04:00
|
|
|
template <class MH, class MO> class SyntacticLanguageModelFiles;
|
2011-05-13 23:28:23 +04:00
|
|
|
|
2013-05-29 21:16:15 +04:00
|
|
|
class SyntacticLanguageModel : public StatefulFeatureFunction
|
|
|
|
{
|
|
|
|
|
|
|
|
public:
|
|
|
|
SyntacticLanguageModel(const std::string &line);
|
2011-05-13 23:28:23 +04:00
|
|
|
|
2013-05-29 21:16:15 +04:00
|
|
|
~SyntacticLanguageModel();
|
2011-05-13 23:28:23 +04:00
|
|
|
|
2013-05-29 21:16:15 +04:00
|
|
|
size_t GetNumScoreComponents() const;
|
2011-05-13 23:28:23 +04:00
|
|
|
|
2013-05-29 21:16:15 +04:00
|
|
|
const FFState* EmptyHypothesisState(const InputType &input) const;
|
2011-05-13 23:28:23 +04:00
|
|
|
|
2013-05-29 21:16:15 +04:00
|
|
|
FFState* Evaluate(const Hypothesis& cur_hypo,
|
|
|
|
const FFState* prev_state,
|
|
|
|
ScoreComponentCollection* accumulator) const;
|
2011-05-13 23:28:23 +04:00
|
|
|
|
2013-05-29 21:16:15 +04:00
|
|
|
FFState* EvaluateChart(const ChartHypothesis& cur_hypo,
|
|
|
|
int featureID,
|
|
|
|
ScoreComponentCollection* accumulator) const {
|
|
|
|
throw std::runtime_error("Syntactic LM can only be used with phrase-based decoder.");
|
|
|
|
}
|
2012-03-31 00:21:39 +04:00
|
|
|
|
|
|
|
|
2013-05-29 21:16:15 +04:00
|
|
|
// double perplexity();
|
2011-05-13 23:28:23 +04:00
|
|
|
|
2013-05-29 21:16:15 +04:00
|
|
|
private:
|
2011-05-13 23:28:23 +04:00
|
|
|
|
2013-05-29 21:16:15 +04:00
|
|
|
const size_t m_NumScoreComponents;
|
|
|
|
SyntacticLanguageModelFiles<YModel,XModel>* m_files;
|
|
|
|
const FactorType m_factorType;
|
|
|
|
const size_t m_beamWidth;
|
2011-05-13 23:28:23 +04:00
|
|
|
|
2013-05-29 21:16:15 +04:00
|
|
|
};
|
2011-05-13 23:28:23 +04:00
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|