Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Class Members | File Members

chart.h

Go to the documentation of this file.
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 Lesser General Public
00010 //    License as published by the Free Software Foundation; either
00011 //    version 2.1 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 //    Lesser General Public License for more details.
00017 //
00018 //    You should have received a copy of the GNU Lesser 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 _CHART
00030 #define _CHART
00031 
00032 #include <list>
00033 #include <vector>
00034 #include <string>
00035 
00036 #include "tree.h"
00037 #include "language.h"
00038 #include "grammar.h"
00039 
00043 
00044 class edge : public rule {
00045 
00046  private:
00048   list<string> matched;
00049   // list of cells that matched the currently solved part of the edge.
00050   // (-1,-1) stands for unary rules producing cell self-references.
00051   list<pair<int,int> > backpath;
00052 
00053  public:
00055    edge(const string&, const list<string> &, const int posgov);
00056    edge();
00057    //  edge(const edge &e);
00058    // edge & operator=(const edge &e);
00059 
00061    const list<string> get_matched() const;
00063    const list<pair<int,int> > get_backpath() const;
00065    bool active() const;
00067    void shift(int,int);
00068    
00069 };
00070 
00074 
00075 class cell : public list<edge> {}; 
00076 
00077 
00082 
00083 class chart : vector<cell> {
00084 
00085  private:
00086 
00088    int size;
00089    const grammar *gram;
00090 
00092    bool better_edge(const edge &, const edge&) const;
00094    list<pair<int,int> > cover (int a, int b) const;
00096    int index(int i, int j) const;
00099    bool can_extend(const string &, int, int) const;
00102    void find_all_rules(const edge &, cell &, int, int) const;
00104    bool check_match(const string &, const string &) const;
00105 
00106    void dump() const;
00107 
00108  public:
00110    chart();
00111 
00113    int get_size() const;
00115    cell get_cell(int, int) const;
00116 
00118    void load_sentence(const sentence &);
00119 
00121    void set_grammar(const grammar &);
00122 
00124    void parse();
00125 
00127    parse_tree get_tree(int, int, const string & ="") const;
00128 };
00129 
00130 #endif
00131 
00132 
00133 
00134 
00135 

Generated on Wed Apr 26 12:55:30 2006 for FreeLing by  doxygen 1.4.4