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

Incremental.h « moses - github.com/moses-smt/mosesdecoder.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: c856f6a936d25bcf979e9a9f44c18614a0be4cbd (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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
#pragma once

#include "lm/word_index.hh"
#include "search/applied.hh"
#include "search/nbest.hh"

#include "moses/ChartCellCollection.h"
#include "moses/ChartParser.h"

#include "BaseManager.h"

#include <vector>
#include <string>

namespace Moses
{
class ScoreComponentCollection;
class InputType;
class LanguageModel;

namespace Incremental
{

class Manager : public BaseManager
{
public:
  Manager(const InputType &source);

  ~Manager();

  template <class Model> void LMCallback(const Model &model, const std::vector<lm::WordIndex> &words);

  void Decode();

  const std::vector<search::Applied> &GetNBest() const;

  // Call to get the same value as ProcessSentence returned.
  const std::vector<search::Applied> &Completed() const {
    return *completed_nbest_;
  }

  // output
  void OutputNBest(OutputCollector *collector) const;
  void OutputDetailedTranslationReport(OutputCollector *collector) const;
  void OutputNBestList(OutputCollector *collector, const std::vector<search::Applied> &nbest, long translationId) const;
  void OutputLatticeSamples(OutputCollector *collector) const
  {}
  void OutputAlignment(OutputCollector *collector) const
  {}
  void OutputDetailedTreeFragmentsTranslationReport(OutputCollector *collector) const;
  void OutputWordGraph(OutputCollector *collector) const
  {}
  void OutputSearchGraph(OutputCollector *collector) const
  {}
  void OutputSearchGraphSLF() const
  {}


private:
  template <class Model, class Best> search::History PopulateBest(const Model &model, const std::vector<lm::WordIndex> &words, Best &out);

  const InputType &source_;
  ChartCellCollectionBase cells_;
  ChartParser parser_;

  // Only one of single_best_ or n_best_ will be used, but it was easier to do this than a template.
  search::SingleBest single_best_;
  // ProcessSentence returns a reference to a vector.  ProcessSentence
  // doesn't have one, so this is populated and returned.
  std::vector<search::Applied> backing_for_single_;

  search::NBest n_best_;

  const std::vector<search::Applied> *completed_nbest_;

  // outputs
  void OutputDetailedTranslationReport(
      OutputCollector *collector,
      const search::Applied *applied,
      const Sentence &sentence,
      long translationId) const;
    void OutputTranslationOptions(std::ostream &out,
  		  ApplicationContext &applicationContext,
  		  const search::Applied *applied,
  		  const Sentence &sentence,
  		  long translationId) const;
    void OutputTranslationOption(std::ostream &out,
    		ApplicationContext &applicationContext,
    		const search::Applied *applied,
    		const Sentence &sentence,
    		long translationId) const;
    void ReconstructApplicationContext(const search::Applied *applied,
        const Sentence &sentence,
        ApplicationContext &context) const;
    void OutputTreeFragmentsTranslationOptions(std::ostream &out,
    		ApplicationContext &applicationContext,
    		const search::Applied *applied,
    		const Sentence &sentence,
    		long translationId) const;

};

// Just get the phrase.
void ToPhrase(const search::Applied final, Phrase &out);
// Get the phrase and the features.
void PhraseAndFeatures(const search::Applied final, Phrase &phrase, ScoreComponentCollection &features);


} // namespace Incremental
} // namespace Moses