dependencies.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00028
00029
00030 #ifndef _DEP_TXALA
00031 #define _DEP_TXALA
00032
00033 #include "fries/language.h"
00034 #include "freeling/dep_rules.h"
00035 #include "freeling/semdb.h"
00036 #include "freeling/dependency_parser.h"
00037
00038 #include <string>
00039 #include <map>
00040 #include <set>
00041 #include <vector>
00042
00043
00051
00052 class completer {
00053 private:
00055 std::map<std::pair<std::string,std::string>,std::list<completerRule> > chgram;
00057 std::set<std::string> active_flags;
00059 completerRule find_grammar_rule(const std::vector<parse_tree *> &, const size_t);
00061 parse_tree * applyRule(const completerRule &, parse_tree *, parse_tree *);
00063 bool matching_condition(parse_tree::iterator, const std::list<std::string> &, RegEx &) const;
00065 bool matching_context(const std::vector<parse_tree *> &, const size_t, const completerRule &) const;
00067 bool matching_operation(const std::vector<parse_tree *> &, const size_t, completerRule &) const;
00069 bool match_side(const int, const std::vector<parse_tree *> &, const size_t, const std::vector<std::string> &, const size_t) const;
00071 void extract_conds(std::string &, std::list<std::string> &, RegEx &) const;
00073 bool match_pattern(parse_tree::iterator, const std::string &) const;
00075 bool enabled_rule(const completerRule &) const;
00076
00077 public:
00079 completer(const std::string &);
00081 parse_tree complete(parse_tree &, const std::string &);
00082
00083 };
00084
00085
00091
00092 class depLabeler {
00093
00094 private:
00095
00096 std::map<std::string, std::list<ruleLabeler> > rules;
00097
00098 std::set<std::string> unique;
00099
00100 semanticDB * semdb;
00101
00102 rule_expression* build_expression(const std::string &);
00103
00104 public:
00106 depLabeler(const std::string &);
00108 ~depLabeler();
00110 void label(dep_tree*);
00112 void label(dep_tree*, dep_tree::iterator);
00113 };
00114
00115
00116
00125
00126 class dep_txala : public dependency_parser {
00127
00128 private:
00130 completer comp;
00132 depLabeler labeler;
00133
00134 std::string start;
00136 dep_tree* dependencies(parse_tree::iterator, parse_tree::iterator);
00137
00138 public:
00140 dep_txala(const std::string &, const std::string &);
00142 void analyze(std::list<sentence> &);
00144 std::list<sentence> analyze(const std::list<sentence> &);
00145 };
00146
00147 #endif
00148