Welcome to mirror list, hosted at ThFree Co, Russian Federation.

OpSequenceModel.h « OSM-Feature « FF « moses - github.com/moses-smt/mosesdecoder.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 1e32bd6a1154a6da17e2ba267b29b6f3f9cbff57 (plain)
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#pragma once

#include <string>
#include <map>
#include <vector>
#include "moses/FF/StatefulFeatureFunction.h"
#include "moses/Manager.h"
#include "moses/FF/OSM-Feature/osmHyp.h"
#include "lm/model.hh"


namespace Moses
{

class OpSequenceModel : public StatefulFeatureFunction
{
public:

	
	lm::ngram::Model * OSM;
	
	int lmOrder;
	float unkOpProb;

	OpSequenceModel(const std::string &line);

	void readLanguageModel(const char *);
	void Load();

	FFState* Evaluate(
	    const Hypothesis& cur_hypo,
	    const FFState* prev_state,
	    ScoreComponentCollection* accumulator) const;

	void  Evaluate(const Phrase &source
                        , const TargetPhrase &targetPhrase
                        , ScoreComponentCollection &scoreBreakdown
                        , ScoreComponentCollection &estimatedFutureScore) const;

  virtual FFState* EvaluateChart(
    const ChartHypothesis& /* cur_hypo */,
    int /* featureID - used to index the state in the previous hypotheses */,
    ScoreComponentCollection* accumulator) const;

  virtual const FFState* EmptyHypothesisState(const InputType &input) const;

  virtual std::string GetScoreProducerWeightShortName(unsigned idx=0) const;

  std::vector<float> GetFutureScores(const Phrase &source, const Phrase &target) const;
  void SetParameter(const std::string& key, const std::string& value);

  bool IsUseable(const FactorMask &mask) const
  { return true; }

protected:
	typedef std::pair<Phrase, Phrase> ParallelPhrase;
	typedef std::vector<float> Scores;
	std::map<ParallelPhrase, Scores> m_futureCost;

	std::vector < std::pair < std::set <int> , std::set <int> > > ceptsInPhrase;
	std::set <int> targetNullWords;
	std::string m_featurePath, m_lmPath;



};


} // namespace