|
#pragma once |
|
|
|
#include <map> |
|
#include <memory> |
|
#include <set> |
|
#include <string> |
|
#include <vector> |
|
|
|
#include "SyntaxNodeCollection.h" |
|
#include "SyntaxTree.h" |
|
|
|
namespace MosesTraining { |
|
namespace Syntax { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class XmlTreeParser { |
|
public: |
|
|
|
std::auto_ptr<SyntaxTree> Parse(const std::string &, bool unescape=false); |
|
|
|
|
|
const std::string &sentence() const { return sentence_; } |
|
|
|
|
|
const std::vector<std::string> &words() const { return words_; } |
|
|
|
|
|
const SyntaxNodeCollection &node_collection() const { |
|
return node_collection_; |
|
} |
|
|
|
|
|
const std::set<std::string> &label_set() const { return label_set_; } |
|
|
|
|
|
const std::map<std::string, int> &top_label_set() const { |
|
return top_label_set_; |
|
} |
|
|
|
private: |
|
void AttachWords(const std::vector<std::string> &, SyntaxTree &); |
|
|
|
std::string sentence_; |
|
SyntaxNodeCollection node_collection_; |
|
std::set<std::string> label_set_; |
|
std::map<std::string, int> top_label_set_; |
|
std::vector<std::string> words_; |
|
}; |
|
|
|
} |
|
} |
|
|