00001
00002 #ifndef moses_TreeInput_h
00003 #define moses_TreeInput_h
00004
00005
00006 #include <vector>
00007 #include "Sentence.h"
00008
00009 namespace Moses
00010 {
00011 class TranslationTask;
00013 class XMLParseOutput
00014 {
00015 public:
00016 std::string m_label;
00017 Range m_range;
00018
00019 XMLParseOutput(const std::string &label, const Range &range)
00020 : m_label(label)
00021 , m_range(range) {
00022 }
00023 };
00024
00030 class TreeInput : public Sentence
00031 {
00032 friend std::ostream& operator<<(std::ostream&, const TreeInput&);
00033
00034 protected:
00035 std::vector<std::vector<NonTerminalSet> > m_sourceChart;
00036 std::vector<XMLParseOutput> m_labelledSpans;
00037
00038 void AddChartLabel(size_t startPos, size_t endPos, const std::string &label);
00039 void AddChartLabel(size_t startPos, size_t endPos, const Word &label);
00040
00041 NonTerminalSet &GetLabelSet(size_t startPos, size_t endPos) {
00042 return m_sourceChart[startPos][endPos - startPos];
00043 }
00044
00045 bool ProcessAndStripXMLTags(AllOptions const& opts, std::string &line,
00046 std::vector<XMLParseOutput> &sourceLabels,
00047 std::vector<XmlOption const*> &res);
00048
00049 public:
00050 TreeInput(AllOptions::ptr const& opts) : Sentence(opts) { }
00051
00052 InputTypeEnum GetType() const {
00053 return TreeInputType;
00054 }
00055
00057 virtual int
00058 Read(std::istream& in);
00059
00061 virtual void Print(std::ostream&) const;
00062
00064 virtual TranslationOptionCollection* CreateTranslationOptionCollection() const;
00065
00066 virtual const NonTerminalSet &GetLabelSet(size_t startPos, size_t endPos) const {
00067 return m_sourceChart[startPos][endPos - startPos];
00068 }
00069
00071 const std::vector<XMLParseOutput> &GetLabelledSpans() const {
00072 return m_labelledSpans;
00073 }
00074 };
00075
00076 }
00077
00078 #endif