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

ConfusionNet.h « src « moses - github.com/moses-smt/mosesdecoder.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 25b5a021da72c6968bbc52a088e9905c54e026b0 (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
// $Id$

#ifndef moses_ConfusionNet_h
#define moses_ConfusionNet_h

#include <vector>
#include <iostream>
#include "Word.h"
#include "InputType.h"

namespace Moses
{

class FactorCollection;
class TranslationOptionCollection;
class Sentence;
class TranslationSystem;

class ConfusionNet : public InputType
{
public:
  typedef std::vector<std::pair<Word,std::vector<float> > > Column;

protected:
  std::vector<Column> data;

  bool ReadFormat0(std::istream&,const std::vector<FactorType>& factorOrder);
  bool ReadFormat1(std::istream&,const std::vector<FactorType>& factorOrder);
  void String2Word(const std::string& s,Word& w,const std::vector<FactorType>& factorOrder);

public:
  ConfusionNet();
  virtual ~ConfusionNet();

  ConfusionNet(Sentence const& s);

  InputTypeEnum GetType() const {
    return ConfusionNetworkInput;
  }

  const Column& GetColumn(size_t i) const {
    CHECK(i<data.size());
    return data[i];
  }
  const Column& operator[](size_t i) const {
    return GetColumn(i);
  }
  virtual size_t GetColumnIncrement(size_t i, size_t j) const; //! returns 1 for CNs

  bool Empty() const {
    return data.empty();
  }
  size_t GetSize() const {
    return data.size();
  }
  void Clear() {
    data.clear();
  }

  bool ReadF(std::istream&,const std::vector<FactorType>& factorOrder,int format=0);
  virtual void Print(std::ostream&) const;

  int Read(std::istream& in,const std::vector<FactorType>& factorOrder);

  Phrase GetSubString(const WordsRange&) const; //TODO not defined
  std::string GetStringRep(const std::vector<FactorType> factorsToPrint) const; //TODO not defined
  const Word& GetWord(size_t pos) const;

  TranslationOptionCollection* CreateTranslationOptionCollection(const TranslationSystem* system) const;

  const NonTerminalSet &GetLabelSet(size_t /*startPos*/, size_t /*endPos*/) const {
    CHECK(false);
    return *(new NonTerminalSet());
  }

};

std::ostream& operator<<(std::ostream& out,const ConfusionNet& cn);


}

#endif