source: app/src/dgp/grammar.hh @ 0214596

help
Last change on this file since 0214596 was 0214596, checked in by pawelk <pawelk@…>, 16 years ago

Dodalismy do pakietu utt komponent dgp (brak configow i innych bajerow).

git-svn-id: svn://atos.wmid.amu.edu.pl/utt@24 e293616e-ec6a-49c2-aa92-f4a8b91c5d16

  • Property mode set to 100644
File size: 1.4 KB
Line 
1#ifndef _GRAMMAR_HH
2#define _GRAMMAR_HH
3
4#include <bitset>
5#include <vector>
6#include <list>
7#include <set>
8
9#include "const.hh"
10#include "thesymbols.hh"
11#include "sgraph.hh"
12
13class Grammar
14{
15
16 public:
17
18  //  enum CONSTR { SGL, OBL, LEFT, RIGHT, INIT, NONINIT, FIN, NONFIN };
19
20  Grammar() : types_sz(0), cats_sz(0) { } ;
21 
22  int types_sz;
23  int cats_sz;
24
25  vector< vector< Roles > >    connect;
26  RoleSet                      sgl;
27  vector< RoleSet >            obl;
28  RoleSet                      left;
29  RoleSet                      right;
30  vector< RoleSet >            lt;
31  vector< RoleSet >            gt;
32
33  bool read(FILE* f);
34  void write(FILE* f);
35
36  void add_category(const char* s);
37  void add_type(const char* s);
38
39  void set_sgl(Role r)           { sgl.set(r); }
40  void set_obl(Cat c, Role r)    { obl[c].set(r); }
41  void set_left(Role r)          { left.set(r); }
42  void set_right(Role r)         { right.set(r); }
43  void set_order(Role r, Role s) { lt[s].set(r); }
44  void set_connect(Cat c, Cat d, Role r)   { connect[c][d].insert(r); }
45  void set_lt(Role r, Role s);
46  void compute_gt();
47
48
49  bool check_constr(NodeProp& hprop, NodeProp& dprop, int dir, Role role);
50
51};
52
53inline bool Grammar::check_constr(NodeProp& hprop, NodeProp& dprop, int dir, Role role)
54{
55  return 
56    !hprop.forbidden[role] &&
57    ( !right[role] || dir==1 ) &&
58    ( !left[role] || dir==0 )
59    ;
60}
61
62
63#endif
Note: See TracBrowser for help on using the repository browser.