|
FreeLing
3.0
|
00001 00002 // 00003 // FreeLing - Open Source Language Analyzers 00004 // 00005 // Copyright (C) 2004 TALP Research Center 00006 // Universitat Politecnica de Catalunya 00007 // 00008 // This library is free software; you can redistribute it and/or 00009 // modify it under the terms of the GNU General Public 00010 // License as published by the Free Software Foundation; either 00011 // version 3 of the License, or (at your option) any later version. 00012 // 00013 // This library is distributed in the hope that it will be useful, 00014 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00015 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00016 // General Public License for more details. 00017 // 00018 // You should have received a copy of the GNU General Public 00019 // License along with this library; if not, write to the Free Software 00020 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00021 // 00022 // contact: Lluis Padro (padro@lsi.upc.es) 00023 // TALP Research Center 00024 // despatx C6.212 - Campus Nord UPC 00025 // 08034 Barcelona. SPAIN 00026 // 00028 00029 #ifndef _CONSTR_GRAMMAR 00030 #define _CONSTR_GRAMMAR 00031 00032 #include <string> 00033 #include <list> 00034 #include <map> 00035 #include <set> 00036 00040 00041 class condition { 00042 private: 00044 bool neg; 00046 int pos; 00048 bool starpos; 00050 std::list<std::wstring> terms; 00052 std::list <std::wstring> barrier; 00053 00054 public: 00056 condition(); 00057 00059 void clear(); 00061 void set_neg(bool); 00063 void set_pos(int,bool); 00065 void set_terms(const std::list<std::wstring>&); 00067 void set_barrier(const std::list<std::wstring>&); 00069 bool is_neg() const; 00071 int get_pos() const; 00073 bool has_star() const; 00075 std::list<std::wstring> get_terms() const; 00077 bool has_barrier() const; 00079 std::list<std::wstring> get_barrier() const; 00080 }; 00081 00082 00086 00087 class ruleCG : public std::list<condition> { 00088 protected: 00090 double weight; 00092 std::wstring head; 00093 00094 public: 00096 ruleCG(); 00097 00099 void set_head(const std::wstring &); 00101 void set_weight(double); 00103 std::wstring get_head() const; 00105 double get_weight() const; 00106 }; 00107 00111 00112 class setCG : public std::set<std::wstring> { 00113 public: 00114 int type; 00115 }; 00116 00117 00118 00123 00124 class constraint_grammar : public std::multimap<std::wstring,ruleCG> { 00125 public: 00127 bool senses_used; 00128 00130 std::map<std::wstring,setCG> sets; 00131 00133 constraint_grammar(const std::wstring &); 00134 00136 void get_rules_head(const std::wstring &, std::list<ruleCG> &) const; 00137 }; 00138 00139 00140 //---- TOKENS used to parse constraint_grammar files. 00141 00142 #define CATEGORY 1 00143 #define FORM 2 00144 #define LEMMA 3 00145 #define COMMENT 4 00146 #define ERROR 5 00147 #define BARRIER 6 00148 #define CPAR 7 00149 #define FLOATNUM 8 00150 #define NOT 9 00151 #define OR 10 00152 #define OPAR 11 00153 #define OUTBOUNDS 12 00154 #define POSITION 13 00155 #define SEMICOLON 14 00156 #define USER 15 00157 #define SETS 16 00158 #define CONSTRAINTS 17 00159 #define IS 18 00160 #define SETREF 19 00161 #define SENSE 20 00162 00163 #endif 00164 00165 00166 00167 00168
1.7.6.1