2010-06-10 19:19:07 +04:00
|
|
|
#ifndef moses_TreeInput_h
|
|
|
|
#define moses_TreeInput_h
|
|
|
|
|
2010-04-08 21:16:10 +04:00
|
|
|
|
|
|
|
#include <vector>
|
|
|
|
#include "Sentence.h"
|
|
|
|
|
|
|
|
namespace Moses
|
|
|
|
{
|
2012-06-29 02:29:46 +04:00
|
|
|
//! @todo what is this?
|
2010-04-08 21:16:10 +04:00
|
|
|
class XMLParseOutput
|
|
|
|
{
|
|
|
|
public:
|
2011-02-24 16:14:42 +03:00
|
|
|
std::string m_label;
|
|
|
|
WordsRange m_range;
|
|
|
|
|
|
|
|
XMLParseOutput(const std::string &label, const WordsRange &range)
|
|
|
|
: m_label(label)
|
2013-06-10 21:11:55 +04:00
|
|
|
, m_range(range) {
|
|
|
|
}
|
2010-04-08 21:16:10 +04:00
|
|
|
};
|
2011-02-24 16:14:42 +03:00
|
|
|
|
2012-06-29 02:29:46 +04:00
|
|
|
/** An input to the decoder that represent a parse tree.
|
|
|
|
* Implemented as a sentence with non-terminal labels over certain ranges.
|
|
|
|
* This representation doesn't necessarily have to form a tree, it's up to the user to make sure it does if they really want a tree.
|
|
|
|
* @todo Need to rewrite if you want packed forest, or packed forest over lattice - not sure if can inherit from this
|
|
|
|
*/
|
2010-04-08 21:16:10 +04:00
|
|
|
class TreeInput : public Sentence
|
|
|
|
{
|
2011-02-24 16:14:42 +03:00
|
|
|
friend std::ostream& operator<<(std::ostream&, const TreeInput&);
|
2010-04-08 21:16:10 +04:00
|
|
|
|
|
|
|
protected:
|
2011-02-24 16:14:42 +03:00
|
|
|
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];
|
|
|
|
}
|
|
|
|
|
2012-03-28 07:29:24 +04:00
|
|
|
bool ProcessAndStripXMLTags(std::string &line, std::vector<XMLParseOutput> &sourceLabels, std::vector<XmlOption*> &res);
|
2010-04-08 21:16:10 +04:00
|
|
|
|
|
|
|
public:
|
2013-06-10 21:11:55 +04:00
|
|
|
TreeInput() {
|
|
|
|
}
|
2011-02-24 16:14:42 +03:00
|
|
|
|
|
|
|
InputTypeEnum GetType() const {
|
|
|
|
return TreeInputType;
|
|
|
|
}
|
2010-04-08 21:16:10 +04:00
|
|
|
|
2011-02-24 16:14:42 +03:00
|
|
|
//! populate this InputType with data from in stream
|
|
|
|
virtual int Read(std::istream& in,const std::vector<FactorType>& factorOrder);
|
2010-04-08 21:16:10 +04:00
|
|
|
|
2011-02-24 16:14:42 +03:00
|
|
|
//! Output debugging info to stream out
|
|
|
|
virtual void Print(std::ostream&) const;
|
2010-04-08 21:16:10 +04:00
|
|
|
|
2011-02-24 16:14:42 +03:00
|
|
|
//! create trans options specific to this InputType
|
|
|
|
virtual TranslationOptionCollection* CreateTranslationOptionCollection() const;
|
2010-04-08 21:16:10 +04:00
|
|
|
|
2011-02-24 16:14:42 +03:00
|
|
|
virtual const NonTerminalSet &GetLabelSet(size_t startPos, size_t endPos) const {
|
|
|
|
return m_sourceChart[startPos][endPos - startPos];
|
|
|
|
}
|
2010-04-08 21:16:10 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2010-06-10 19:19:07 +04:00
|
|
|
#endif
|