00001 // -*- c++ -*- 00002 #ifndef moses_WordLattice_h 00003 #define moses_WordLattice_h 00004 00005 #include <iostream> 00006 #include <vector> 00007 #include "ConfusionNet.h" 00008 #include "PCNTools.h" 00009 00010 namespace Moses 00011 { 00012 00013 class TranslationTask; 00014 00018 class WordLattice: public ConfusionNet 00019 { 00020 friend std::ostream& operator<<(std::ostream &out, const WordLattice &obj); 00021 private: 00022 std::vector<std::vector<size_t> > next_nodes; 00023 std::vector<std::vector<int> > distances; 00024 00025 public: 00026 WordLattice(AllOptions::ptr const& opts); 00027 00028 InputTypeEnum GetType() const { 00029 return WordLatticeInput; 00030 } 00031 00032 size_t GetColumnIncrement(size_t ic, size_t j) const; 00033 void Print(std::ostream&) const; 00036 virtual int ComputeDistortionDistance(const Range& prev, const Range& current) const; 00037 // is it possible to get from the edge of the previous word range to the current word range 00038 virtual bool CanIGetFromAToB(size_t start, size_t end) const; 00039 00043 int InitializeFromPCNDataType(const PCN::CN& cn, const std::string& debug_line = ""); 00044 00047 int Read(std::istream& in); 00048 00052 void GetAsEdgeMatrix(std::vector<std::vector<bool> >& edges) const; 00053 00054 const std::vector<size_t> &GetNextNodes(size_t pos) const { 00055 return next_nodes[pos]; 00056 } 00057 00058 TranslationOptionCollection* 00059 CreateTranslationOptionCollection(ttasksptr const& ttask) const; 00060 }; 00061 00062 } 00063 00064 #endif