Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/moses-smt/mosesdecoder.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorUlrich Germann <ugermann@inf.ed.ac.uk>2015-03-02 14:23:00 +0300
committerUlrich Germann <ugermann@inf.ed.ac.uk>2015-03-02 14:23:00 +0300
commite1c02ee57c4386d4bcb0923e1a413e1b26f90b2a (patch)
tree0e7a84c868cd0bb7aef8cf70dad57bb4e794be18 /moses/Sentence.h
parente2b1ac1e9d955c55cab5000eccc7b052f196a90b (diff)
Code reorganization.
Diffstat (limited to 'moses/Sentence.h')
-rw-r--r--moses/Sentence.h135
1 files changed, 81 insertions, 54 deletions
diff --git a/moses/Sentence.h b/moses/Sentence.h
index 4f206c0d4..a415dbd57 100644
--- a/moses/Sentence.h
+++ b/moses/Sentence.h
@@ -1,3 +1,4 @@
+// -*- c++ -*-
// $Id$
/***********************************************************************
@@ -31,80 +32,106 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
namespace Moses
{
-class WordsRange;
-class PhraseDictionary;
-class TranslationOption;
-class TranslationOptionCollection;
-class ChartTranslationOptions;
-struct XmlOption;
+ class WordsRange;
+ class PhraseDictionary;
+ class TranslationOption;
+ class TranslationOptionCollection;
+ class ChartTranslationOptions;
+ 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:
-
/**
- * 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
+ * A Phrase class with an ID. Used specifically as source input so contains functionality to read
+ * from IODevice and create trans opt
*/
- std::vector<XmlOption*> m_xmlOptions;
- std::vector <bool> m_xmlCoverageMap;
+ 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;
+
+ NonTerminalSet m_defaultLabelSet;
+
+ void ProcessPlaceholders(const std::vector< std::pair<size_t, std::string> > &placeholders);
+
+
+ public:
+ Sentence();
+ Sentence(size_t const transId, std::string const& stext);
+ ~Sentence();
+
+ InputTypeEnum GetType() const {
+ return SentenceInput;
+ }
+
+ //! Calls Phrase::GetSubString(). Implements abstract InputType::GetSubString()
+ Phrase GetSubString(const WordsRange& r) const {
+ return Phrase::GetSubString(r);
+ }
- NonTerminalSet m_defaultLabelSet;
+ //! Calls Phrase::GetWord(). Implements abstract InputType::GetWord()
+ const Word& GetWord(size_t pos) const {
+ return Phrase::GetWord(pos);
+ }
- void ProcessPlaceholders(const std::vector< std::pair<size_t, std::string> > &placeholders);
+ //! 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;
-public:
- Sentence();
- ~Sentence();
+ //! 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;
- InputTypeEnum GetType() const {
- return SentenceInput;
- }
+ virtual int Read(std::istream& in,const std::vector<FactorType>& factorOrder);
+ void Print(std::ostream& out) const;
- //! Calls Phrase::GetSubString(). Implements abstract InputType::GetSubString()
- Phrase GetSubString(const WordsRange& r) const {
- return Phrase::GetSubString(r);
- }
+ TranslationOptionCollection* CreateTranslationOptionCollection() const;
- //! Calls Phrase::GetWord(). Implements abstract InputType::GetWord()
- const Word& GetWord(size_t pos) const {
- return Phrase::GetWord(pos);
- }
+ virtual void
+ CreateFromString(std::vector<FactorType> const &factorOrder,
+ std::string const& phraseString);
- //! Calls Phrase::GetSize(). Implements abstract InputType::GetSize()
- size_t GetSize() const {
- return Phrase::GetSize();
- }
+ const NonTerminalSet&
+ GetLabelSet(size_t /*startPos*/, size_t /*endPos*/) const
+ { return m_defaultLabelSet; }
- //! 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;
+ void
+ init(std::string line, std::vector<FactorType> const& factorOrder);
- virtual int Read(std::istream& in,const std::vector<FactorType>& factorOrder);
- void Print(std::ostream& out) const;
+ 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);
- TranslationOptionCollection* CreateTranslationOptionCollection() const;
+ void
+ aux_interpret_sgml_markup(std::string& line);
- virtual void CreateFromString(const std::vector<FactorType> &factorOrder
- , const std::string &phraseString); // , const std::string &factorDelimiter);
+ void
+ aux_interpret_dlt(std::string& line);
- const NonTerminalSet &GetLabelSet(size_t /*startPos*/, size_t /*endPos*/) const {
- return m_defaultLabelSet;
- }
+ 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);
+ };
+
}