blob: a8ae9466c4ac5ca0a59b092a895d762e49b7bcca (
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
|
#ifndef moses_WordLattice_h
#define moses_WordLattice_h
#include <iostream>
#include <vector>
#include "ConfusionNet.h"
#include "PCNTools.h"
namespace Moses
{
class TranslationTask;
/** An input to the decoder that represent a word lattice.
* @todo why is this inherited from confusion net?
*/
class WordLattice: public ConfusionNet
{
friend std::ostream& operator<<(std::ostream &out, const WordLattice &obj);
private:
std::vector<std::vector<size_t> > next_nodes;
std::vector<std::vector<int> > distances;
public:
WordLattice(TranslationTask const* ttask);
InputTypeEnum GetType() const {
return WordLatticeInput;
}
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;
const std::vector<size_t> &GetNextNodes(size_t pos) const {
return next_nodes[pos];
}
TranslationOptionCollection *CreateTranslationOptionCollection() const;
};
}
#endif
|