2010-04-08 21:16:10 +04:00
|
|
|
#ifndef moses_WordLattice_h
|
|
|
|
#define moses_WordLattice_h
|
|
|
|
|
2013-10-02 20:43:59 +04:00
|
|
|
#include <iostream>
|
2010-04-08 21:16:10 +04:00
|
|
|
#include <vector>
|
|
|
|
#include "ConfusionNet.h"
|
2011-01-25 23:08:29 +03:00
|
|
|
#include "PCNTools.h"
|
2010-04-08 21:16:10 +04:00
|
|
|
|
|
|
|
namespace Moses
|
|
|
|
{
|
|
|
|
|
2012-06-29 02:29:46 +04:00
|
|
|
/** An input to the decoder that represent a word lattice.
|
|
|
|
* @todo why is this inherited from confusion net?
|
|
|
|
*/
|
2011-02-24 16:14:42 +03:00
|
|
|
class WordLattice: public ConfusionNet
|
|
|
|
{
|
2013-10-02 20:43:59 +04:00
|
|
|
friend std::ostream& operator<<(std::ostream &out, const WordLattice &obj);
|
2010-04-08 21:16:10 +04:00
|
|
|
private:
|
2011-02-24 16:14:42 +03:00
|
|
|
std::vector<std::vector<size_t> > next_nodes;
|
|
|
|
std::vector<std::vector<int> > distances;
|
|
|
|
|
2010-04-08 21:16:10 +04:00
|
|
|
public:
|
2011-02-24 16:14:42 +03:00
|
|
|
WordLattice();
|
|
|
|
size_t GetColumnIncrement(size_t ic, size_t j) const;
|
|
|
|
void Print(std::ostream&) const;
|
|
|
|
/** Get shortest path between two nodes
|
|
|
|
*/
|
|
|
|
virtual int ComputeDistortionDistance(const WordsRange& prev, const WordsRange& current) const;
|
|
|
|
// is it possible to get from the edge of the previous word range to the current word range
|
|
|
|
virtual bool CanIGetFromAToB(size_t start, size_t end) const;
|
|
|
|
|
|
|
|
/** Given a lattice represented using the PCN::CN data type (topologically sorted agency list
|
|
|
|
* representation), initialize the WordLattice object
|
|
|
|
*/
|
|
|
|
int InitializeFromPCNDataType(const PCN::CN& cn, const std::vector<FactorType>& factorOrder, const std::string& debug_line = "");
|
|
|
|
/** Read from PLF format (1 lattice per line)
|
|
|
|
*/
|
|
|
|
int Read(std::istream& in,const std::vector<FactorType>& factorOrder);
|
|
|
|
|
|
|
|
/** Convert internal representation into an edge matrix
|
|
|
|
* @note edges[1][2] means there is an edge from 1 to 2
|
|
|
|
*/
|
|
|
|
void GetAsEdgeMatrix(std::vector<std::vector<bool> >& edges) const;
|
|
|
|
|
2013-10-03 14:33:48 +04:00
|
|
|
const std::vector<size_t> &GetNextNodes(size_t pos) const {
|
|
|
|
return next_nodes[pos];
|
|
|
|
}
|
2013-10-02 20:43:59 +04:00
|
|
|
|
2013-10-02 21:42:56 +04:00
|
|
|
TranslationOptionCollection *CreateTranslationOptionCollection() const;
|
2010-04-08 21:16:10 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|