chart.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 #ifndef _CHART
00030 #define _CHART
00031
00032 #include <list>
00033 #include <vector>
00034 #include <string>
00035
00036 #include "fries/language.h"
00037 #include "freeling/grammar.h"
00038
00042
00043 class edge : public rule {
00044
00045 private:
00047 std::list<std::string> matched;
00048
00049
00050 std::list<std::pair<int,int> > backpath;
00051
00052 public:
00054 edge(const std::string&, const std::list<std::string> &, const int posgov);
00055 edge();
00056
00057
00058
00060 const std::list<std::string> get_matched() const;
00062 const std::list<std::pair<int,int> > get_backpath() const;
00064 bool active() const;
00066 void shift(int,int);
00067
00068 };
00069
00073
00074 class cell : public std::list<edge> {};
00075
00076
00081
00082 class chart : std::vector<cell> {
00083
00084 private:
00085
00087 int size;
00088 const grammar *gram;
00089
00091 bool better_edge(const edge &, const edge&) const;
00093 std::list<std::pair<int,int> > cover (int a, int b) const;
00095 int index(int i, int j) const;
00098 bool can_extend(const std::string &, int, int) const;
00101 void find_all_rules(const edge &, cell &, int, int) const;
00103 bool check_match(const std::string &, const std::string &) const;
00104
00105 void dump() const;
00106
00107 public:
00109 chart();
00110
00112 int get_size() const;
00114 cell get_cell(int, int) const;
00115
00117 void load_sentence(const sentence &);
00118
00120 void set_grammar(const grammar &);
00121
00123 void parse();
00124
00126 parse_tree get_tree(int, int, const std::string & ="") const;
00127 };
00128
00129 #endif
00130
00131
00132
00133
00134