00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #ifndef moses_Sentence_h
00022 #define moses_Sentence_h
00023
00024 #include <vector>
00025 #include <string>
00026 #include "Word.h"
00027 #include "Phrase.h"
00028 #include "InputType.h"
00029 #include "parameters/AllOptions.h"
00030
00031 namespace Moses
00032 {
00033
00034 class Range;
00035 class PhraseDictionary;
00036 class TranslationOption;
00037 class TranslationOptionCollection;
00038 class ChartTranslationOptions;
00039 class TranslationTask;
00040 struct XmlOption;
00041
00042
00047 class Sentence : public Phrase, public InputType
00048 {
00049 protected:
00050
00055 std::vector<XmlOption const*> m_xmlOptions;
00056 std::vector <bool> m_xmlCoverageMap;
00057
00058 NonTerminalSet m_defaultLabelSet;
00059
00060 void ProcessPlaceholders(const std::vector< std::pair<size_t, std::string> > &placeholders);
00061
00062
00063 std::vector<std::map<std::string,std::string> > m_dlt_meta;
00064
00065 public:
00066 Sentence(AllOptions::ptr const& opts);
00067 Sentence(AllOptions::ptr const& opts, size_t const transId, std::string stext);
00068
00069
00070 ~Sentence();
00071
00072 InputTypeEnum GetType() const {
00073 return SentenceInput;
00074 }
00075
00077 Phrase GetSubString(const Range& r) const {
00078 return Phrase::GetSubString(r);
00079 }
00080
00082 const Word& GetWord(size_t pos) const {
00083 return Phrase::GetWord(pos);
00084 }
00085
00087 size_t GetSize() const {
00088 return Phrase::GetSize();
00089 }
00090
00092 bool XmlOverlap(size_t startPos, size_t endPos) const;
00093
00095 void GetXmlTranslationOptions(std::vector<TranslationOption*> &list) const;
00096 void GetXmlTranslationOptions(std::vector<TranslationOption*> &list, size_t startPos, size_t endPos) const;
00097 std::vector<ChartTranslationOptions*> GetXmlChartTranslationOptions() const;
00098
00099 virtual int
00100 Read(std::istream& in);
00101
00102
00103 void Print(std::ostream& out) const;
00104
00105 TranslationOptionCollection*
00106 CreateTranslationOptionCollection(ttasksptr const& ttask) const;
00107
00108 virtual void
00109 CreateFromString(std::vector<FactorType> const &factorOrder,
00110 std::string const& phraseString);
00111
00112 const NonTerminalSet&
00113 GetLabelSet(size_t , size_t ) const {
00114 return m_defaultLabelSet;
00115 }
00116
00117
00118 void init(std::string line);
00119
00120 std::vector<std::map<std::string,std::string> > const&
00121 GetDltMeta() const {
00122 return m_dlt_meta;
00123 }
00124
00125 private:
00126
00127
00128
00129
00130
00131
00132 void
00133 aux_interpret_sgml_markup(std::string& line);
00134
00135 void
00136 aux_interpret_dlt(std::string& line);
00137
00138 void
00139 aux_interpret_xml
00140 (std::string& line, std::vector<size_t> & xmlWalls,
00141 std::vector<std::pair<size_t, std::string> >& placeholders);
00142
00143 void
00144 aux_init_partial_translation(std::string& line);
00145
00146 };
00147
00148
00149 }
00150
00151 #endif