diff options
author | Hieu Hoang <hieuhoang@gmail.com> | 2015-05-02 13:45:24 +0300 |
---|---|---|
committer | Hieu Hoang <hieuhoang@gmail.com> | 2015-05-02 13:45:24 +0300 |
commit | cc8c6b7b10abd8118014635609f7658f6a7a1857 (patch) | |
tree | cab374bcbf73ff97782e9131380e4f32dbeb1e67 /moses/Sentence.h | |
parent | a4a7c14593766ab188e1d6ae1c29e67ed201d412 (diff) |
beautify
Diffstat (limited to 'moses/Sentence.h')
-rw-r--r-- | moses/Sentence.h | 157 |
1 files changed, 79 insertions, 78 deletions
diff --git a/moses/Sentence.h b/moses/Sentence.h index 8a870f76b..661280711 100644 --- a/moses/Sentence.h +++ b/moses/Sentence.h @@ -32,109 +32,110 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA namespace Moses { - class WordsRange; - class PhraseDictionary; - class TranslationOption; - class TranslationOptionCollection; - class ChartTranslationOptions; - class TranslationTask; - struct XmlOption; - +class WordsRange; +class PhraseDictionary; +class TranslationOption; +class TranslationOptionCollection; +class ChartTranslationOptions; +class TranslationTask; +struct XmlOption; + + +/** + * A Phrase class with an ID. Used specifically as source input so contains functionality to read + * from IODevice and create trans opt + */ +class Sentence : public Phrase, public InputType +{ +protected: /** - * A Phrase class with an ID. Used specifically as source input so contains functionality to read - * from IODevice and create trans opt + * Utility method that takes in a string representing an XML tag and the name of the attribute, + * and returns the value of that tag if present, empty string otherwise */ - class Sentence : public Phrase, public InputType - { - protected: - - /** - * Utility method that takes in a string representing an XML tag and the name of the attribute, - * and returns the value of that tag if present, empty string otherwise - */ - std::vector<XmlOption*> m_xmlOptions; - std::vector <bool> m_xmlCoverageMap; + std::vector<XmlOption*> m_xmlOptions; + std::vector <bool> m_xmlCoverageMap; - NonTerminalSet m_defaultLabelSet; + NonTerminalSet m_defaultLabelSet; - void ProcessPlaceholders(const std::vector< std::pair<size_t, std::string> > &placeholders); + void ProcessPlaceholders(const std::vector< std::pair<size_t, std::string> > &placeholders); - public: - Sentence(); - Sentence(size_t const transId, std::string const& stext, - std::vector<FactorType> const* IFO = NULL); - // Sentence(size_t const transId, std::string const& stext); - ~Sentence(); +public: + Sentence(); + Sentence(size_t const transId, std::string const& stext, + std::vector<FactorType> const* IFO = NULL); + // Sentence(size_t const transId, std::string const& stext); + ~Sentence(); - InputTypeEnum GetType() const { - return SentenceInput; - } + InputTypeEnum GetType() const { + return SentenceInput; + } - //! Calls Phrase::GetSubString(). Implements abstract InputType::GetSubString() - Phrase GetSubString(const WordsRange& r) const { - return Phrase::GetSubString(r); - } + //! Calls Phrase::GetSubString(). Implements abstract InputType::GetSubString() + Phrase GetSubString(const WordsRange& r) const { + return Phrase::GetSubString(r); + } - //! Calls Phrase::GetWord(). Implements abstract InputType::GetWord() - const Word& GetWord(size_t pos) const { - return Phrase::GetWord(pos); - } + //! Calls Phrase::GetWord(). Implements abstract InputType::GetWord() + const Word& GetWord(size_t pos) const { + return Phrase::GetWord(pos); + } - //! Calls Phrase::GetSize(). Implements abstract InputType::GetSize() - size_t GetSize() const { - return Phrase::GetSize(); - } + //! Calls Phrase::GetSize(). Implements abstract InputType::GetSize() + size_t GetSize() const { + return Phrase::GetSize(); + } - //! Returns true if there were any XML tags parsed that at least partially covered the range passed - bool XmlOverlap(size_t startPos, size_t endPos) const; + //! Returns true if there were any XML tags parsed that at least partially covered the range passed + bool XmlOverlap(size_t startPos, size_t endPos) const; - //! populates vector argument with XML force translation options for the specific range passed - void GetXmlTranslationOptions(std::vector<TranslationOption*> &list) const; - void GetXmlTranslationOptions(std::vector<TranslationOption*> &list, size_t startPos, size_t endPos) const; - std::vector<ChartTranslationOptions*> GetXmlChartTranslationOptions() const; + //! populates vector argument with XML force translation options for the specific range passed + void GetXmlTranslationOptions(std::vector<TranslationOption*> &list) const; + void GetXmlTranslationOptions(std::vector<TranslationOption*> &list, size_t startPos, size_t endPos) const; + std::vector<ChartTranslationOptions*> GetXmlChartTranslationOptions() const; - virtual int Read(std::istream& in,const std::vector<FactorType>& factorOrder); - void Print(std::ostream& out) const; + virtual int Read(std::istream& in,const std::vector<FactorType>& factorOrder); + void Print(std::ostream& out) const; - TranslationOptionCollection* - CreateTranslationOptionCollection(ttasksptr const& ttask) const; + TranslationOptionCollection* + CreateTranslationOptionCollection(ttasksptr const& ttask) const; - virtual void - CreateFromString(std::vector<FactorType> const &factorOrder, - std::string const& phraseString); + virtual void + CreateFromString(std::vector<FactorType> const &factorOrder, + std::string const& phraseString); - const NonTerminalSet& - GetLabelSet(size_t /*startPos*/, size_t /*endPos*/) const - { return m_defaultLabelSet; } + const NonTerminalSet& + GetLabelSet(size_t /*startPos*/, size_t /*endPos*/) const { + return m_defaultLabelSet; + } - void - init(std::string line, std::vector<FactorType> const& factorOrder); + void + init(std::string line, std::vector<FactorType> const& factorOrder); - private: - // auxliliary functions for Sentence initialization - // void aux_interpret_sgml_markup(std::string& line); - // void aux_interpret_dlt(std::string& line); - // void aux_interpret_xml (std::string& line, std::vector<size_t> & xmlWalls, - // std::vector<std::pair<size_t, std::string> >& placeholders); +private: + // auxliliary functions for Sentence initialization + // void aux_interpret_sgml_markup(std::string& line); + // void aux_interpret_dlt(std::string& line); + // void aux_interpret_xml (std::string& line, std::vector<size_t> & xmlWalls, + // std::vector<std::pair<size_t, std::string> >& placeholders); - void - aux_interpret_sgml_markup(std::string& line); + void + aux_interpret_sgml_markup(std::string& line); - void - aux_interpret_dlt(std::string& line); + void + aux_interpret_dlt(std::string& line); - void - aux_interpret_xml - (std::string& line, std::vector<size_t> & xmlWalls, - std::vector<std::pair<size_t, std::string> >& placeholders); + void + aux_interpret_xml + (std::string& line, std::vector<size_t> & xmlWalls, + std::vector<std::pair<size_t, std::string> >& placeholders); - void - aux_init_partial_translation(std::string& line); + void + aux_init_partial_translation(std::string& line); - }; +}; } |