diff options
author | Hieu Hoang <hieuhoang@gmail.com> | 2012-11-12 23:56:18 +0400 |
---|---|---|
committer | Hieu Hoang <hieuhoang@gmail.com> | 2012-11-12 23:56:18 +0400 |
commit | 5e3ef23cef6101d2c098eb3445f562e8f595655b (patch) | |
tree | b8c332b6fa82bae84ea4910967a10ba1b08a7107 /moses/ConfusionNet.h | |
parent | 8c785cff2b1be3cccd76ea9026f71b649762dfc3 (diff) |
move moses/src/* to moses/
Diffstat (limited to 'moses/ConfusionNet.h')
-rw-r--r-- | moses/ConfusionNet.h | 86 |
1 files changed, 86 insertions, 0 deletions
diff --git a/moses/ConfusionNet.h b/moses/ConfusionNet.h new file mode 100644 index 000000000..fdb97a423 --- /dev/null +++ b/moses/ConfusionNet.h @@ -0,0 +1,86 @@ +// $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; + +/** An input to the decoder where each position can be 1 of a number of words, + * each with an associated probability. Compared with a sentence, where each position is a word + */ +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 |