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
62
63
64
65
|
#ifndef moses_TreeInput_h
#define moses_TreeInput_h
#include <vector>
#include "Sentence.h"
namespace Moses
{
class XMLParseOutput
{
public:
std::string m_label;
WordsRange m_range;
XMLParseOutput(const std::string &label, const WordsRange &range)
: m_label(label)
, m_range(range)
{}
};
class TreeInput : public Sentence
{
friend std::ostream& operator<<(std::ostream&, const TreeInput&);
protected:
std::vector<std::vector<NonTerminalSet> > m_sourceChart;
void AddChartLabel(size_t startPos, size_t endPos, const std::string &label
,const std::vector<FactorType>& factorOrder);
void AddChartLabel(size_t startPos, size_t endPos, const Word &label
,const std::vector<FactorType>& factorOrder);
NonTerminalSet &GetLabelSet(size_t startPos, size_t endPos) {
return m_sourceChart[startPos][endPos - startPos];
}
bool ProcessAndStripXMLTags(std::string &line, std::vector<XMLParseOutput> &sourceLabels);
public:
TreeInput(FactorDirection direction)
: Sentence(direction)
{}
InputTypeEnum GetType() const {
return TreeInputType;
}
//! populate this InputType with data from in stream
virtual int Read(std::istream& in,const std::vector<FactorType>& factorOrder);
//! Output debugging info to stream out
virtual void Print(std::ostream&) const;
//! create trans options specific to this InputType
virtual TranslationOptionCollection* CreateTranslationOptionCollection() const;
virtual const NonTerminalSet &GetLabelSet(size_t startPos, size_t endPos) const {
return m_sourceChart[startPos][endPos - startPos];
}
};
}
#endif
|