dep_rules.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 _DEPRULES
00031 #define _DEPRULES
00032
00033 #include <sstream>
00034 #include <iostream>
00035 #include <set>
00036 #include <list>
00037
00038 #include "fries/language.h"
00039 #include "freeling/semdb.h"
00040 #include "regexp-pcre++.h"
00041
00048
00049 class completerRule {
00050
00051 public:
00053 std::string leftChk;
00054 std::string rightChk;
00056 std::list<std::string> leftConds;
00057 std::list<std::string> rightConds;
00059 RegEx leftRE;
00060 RegEx rightRE;
00062 std::string newNode1;
00063 std::string newNode2;
00065 std::string operation;
00067 std::string context;
00069 bool context_neg;
00071 int weight;
00073 parse_tree::iterator last;
00074
00076 std::set<std::string> enabling_flags;
00078 std::set<std::string> flags_toggle_on;
00080 std::set<std::string> flags_toggle_off;
00081
00083 int line;
00084
00086 completerRule();
00087 completerRule(const std::string &, const std::string &, const std::string&);
00088 completerRule( const completerRule &);
00090 completerRule & operator=( const completerRule &);
00091
00093 int operator<(const completerRule & a ) const;
00094 };
00095
00096
00104 class rule_expression {
00105
00106 private:
00107 dep_tree::iterator parse_node_ref(std::string, dep_tree::iterator) const;
00108
00109 protected:
00110
00111 std::string node;
00112
00113 std::set<std::string> valueList;
00114
00115
00116 bool nodes_to_check(dep_tree::iterator, dep_tree::iterator, std::list<dep_tree::iterator> &) const;
00117
00118 virtual bool eval(dep_tree::iterator) const;
00119
00120 public:
00121
00122 rule_expression();
00123 rule_expression(const std::string &,const std::string &);
00124 virtual ~rule_expression() {}
00125
00126 bool find(const std::string &) const;
00127 bool find_match(const std::string &) const;
00128 bool match(const std::string &) const;
00129 bool find_any(const std::list<std::string> &) const;
00130 bool find_any_match(const std::list<std::string> &) const;
00131
00132 virtual bool check(dep_tree::iterator, dep_tree::iterator) const;
00133 };
00134
00135
00149
00153
00154 class check_and : public rule_expression {
00155 private:
00156 std::list<rule_expression *> check_list;
00157 public:
00158 void add(rule_expression *);
00159 bool check(dep_tree::iterator, dep_tree::iterator) const;
00160 };
00161
00162
00166
00167 class check_not : public rule_expression {
00168 private:
00169 rule_expression * check_op;
00170 public:
00171 check_not(rule_expression *);
00172 bool check(dep_tree::iterator, dep_tree::iterator) const;
00173 };
00174
00175
00179
00180 class check_side : public rule_expression {
00181 public:
00182 check_side(const std::string &,const std::string &);
00183 bool check(dep_tree::iterator, dep_tree::iterator) const;
00184 };
00185
00186
00190
00191 class check_lemma : public rule_expression {
00192 public:
00193 check_lemma(const std::string &,const std::string &);
00194 bool eval(dep_tree::iterator) const;
00195 };
00196
00200
00201 class check_pos : public rule_expression {
00202 public:
00203 check_pos(const std::string &,const std::string &);
00204 bool eval(dep_tree::iterator) const;
00205 };
00206
00207
00211
00212 class check_category :public rule_expression {
00213 public:
00214 check_category(const std::string &,const std::string &);
00215 bool eval(dep_tree::iterator) const;
00216 };
00217
00218
00222
00223 class check_wordclass : public rule_expression {
00224 public:
00225 static std::set<std::string> wordclasses;
00226 check_wordclass(const std::string &, const std::string &);
00227 bool eval(dep_tree::iterator) const;
00228 };
00229
00233
00234 class check_tonto : public rule_expression {
00235 private:
00236 semanticDB &semdb;
00237 public:
00238 check_tonto(semanticDB &, const std::string &, const std::string &);
00239 bool eval(dep_tree::iterator) const;
00240 };
00241
00245
00246 class check_semfile : public rule_expression {
00247 private:
00248 semanticDB &semdb;
00249 public:
00250 check_semfile(semanticDB &, const std::string &, const std::string &);
00251 bool eval(dep_tree::iterator) const;
00252 };
00253
00257
00258 class check_synon : public rule_expression {
00259 private:
00260 semanticDB &semdb;
00261 public:
00262 check_synon(semanticDB &, const std::string &, const std::string &);
00263 bool eval(dep_tree::iterator) const;
00264 };
00265
00269
00270 class check_asynon : public rule_expression {
00271 private:
00272 semanticDB &semdb;
00273 public:
00274 check_asynon(semanticDB &, const std::string &, const std::string &);
00275 bool eval(dep_tree::iterator) const;
00276 };
00277
00278
00282
00283 class ruleLabeler {
00284
00285 public:
00286 std::string label;
00287 rule_expression * re;
00288 std::string ancestorLabel;
00290 int line;
00291
00292 ruleLabeler(void);
00293 ruleLabeler(const std::string &, rule_expression *);
00294 bool check(dep_tree::iterator, dep_tree::iterator) const;
00295 };
00296
00297
00298 #endif