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

LanguageModelDALM.h « LM « moses2 - github.com/moses-smt/mosesdecoder.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: a9a010dca6c36ef45f7d6e6d17a51b46a25fbf04 (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
70
71
72
73
74
75
/*
 * LanguageModelDALM.h
 *
 *  Created on: 5 Dec 2015
 *      Author: hieu
 */

#pragma once
#include "../FF/StatefulFeatureFunction.h"
#include "../legacy/Util2.h"
#include "../legacy/Factor.h"

namespace DALM
{
class Logger;
class Vocabulary;
class State;
class LM;
union Fragment;
class Gap;

typedef unsigned int VocabId;
}

namespace Moses2
{

class LanguageModelDALM: public StatefulFeatureFunction
{
public:
  LanguageModelDALM(size_t startInd, const std::string &line);
  virtual ~LanguageModelDALM();

  virtual void Load(System &system);
  virtual void SetParameter(const std::string& key, const std::string& value);

  virtual FFState* BlankState(MemPool &pool, const System &sys) const;
  virtual void EmptyHypothesisState(FFState &state, const ManagerBase &mgr,
                                    const InputType &input, const Hypothesis &hypo) const;

  virtual void
  EvaluateInIsolation(MemPool &pool, const System &system, const Phrase &source,
                      const TargetPhraseImpl &targetPhrase, Scores &scores,
                      SCORE &estimatedScore) const;

  virtual void EvaluateWhenApplied(const ManagerBase &mgr,
                                   const Hypothesis &hypo, const FFState &prevState, Scores &scores,
                                   FFState &state) const;

  virtual void EvaluateWhenApplied(const SCFG::Manager &mgr,
                                   const SCFG::Hypothesis &hypo, int featureID, Scores &scores,
                                   FFState &state) const;

protected:
  FactorType m_factorType;

  std::string m_filePath;
  size_t m_nGramOrder; //! max n-gram length contained in this LM
  size_t m_ContextSize;

  DALM::Logger *m_logger;
  DALM::Vocabulary *m_vocab;
  DALM::LM *m_lm;
  DALM::VocabId wid_start, wid_end;

  const Factor *m_beginSentenceFactor;

  mutable std::vector<DALM::VocabId> m_vocabMap;

  void CreateVocabMapping(const std::string &wordstxt, const System &system);

};

}