2008-06-11 14:52:57 +04:00
|
|
|
// $Id$
|
|
|
|
|
2010-02-24 14:15:44 +03:00
|
|
|
#ifndef moses_ConfusionNet_h
|
|
|
|
#define moses_ConfusionNet_h
|
|
|
|
|
2008-06-11 14:52:57 +04:00
|
|
|
#include <vector>
|
|
|
|
#include <iostream>
|
|
|
|
#include "Word.h"
|
|
|
|
#include "InputType.h"
|
|
|
|
|
2008-10-09 03:51:26 +04:00
|
|
|
namespace Moses
|
|
|
|
{
|
|
|
|
|
2008-06-11 14:52:57 +04:00
|
|
|
class FactorCollection;
|
|
|
|
class TranslationOptionCollection;
|
|
|
|
class Sentence;
|
|
|
|
|
|
|
|
class ConfusionNet : public InputType {
|
|
|
|
public:
|
2009-02-05 20:37:09 +03:00
|
|
|
typedef std::vector<std::pair<Word,std::vector<float> > > Column;
|
2008-06-11 14:52:57 +04:00
|
|
|
|
|
|
|
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 {assert(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;
|
|
|
|
};
|
|
|
|
|
|
|
|
std::ostream& operator<<(std::ostream& out,const ConfusionNet& cn);
|
2008-10-09 03:51:26 +04:00
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2008-06-11 14:52:57 +04:00
|
|
|
#endif
|