Changeset e7de6cc for src/dgp/dgp0.cc


Ignore:
Timestamp:
02/21/12 20:02:51 (13 years ago)
Author:
Tomasz Obrebski <to@…>
Branches:
master
Children:
b242df2
Parents:
354ba3d
git-author:
Tomasz Obrebski <to@…> (02/21/12 20:02:51)
git-committer:
Tomasz Obrebski <to@…> (02/21/12 20:02:51)
Message:

new version of dgp
added dgc, tre and compdic components
compiledic renamed to compdic_utf8
./configure updated

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/dgp/dgp0.cc

    r5f4d9c3 re7de6cc  
    66extern SGraph sgraph; 
    77 
    8 SNode* snodes; 
    9  
    108extern bool debug; 
    119 
     
    1614void set_initial_constraints(int node) 
    1715{ 
    18   snodes[node].prop.forbidden.reset(); 
    19   snodes[node].prop.required=grammar.obl[snodes[node].mnode->cat]; 
     16  sgraph[node].prop.forbidden.reset(); 
     17  sgraph[node].prop.required=grammar.is_obl(mgraph[sgraph[node].mnode].cat); 
    2018} 
    2119 
     
    2321bool changing_constraints(int head, Role role) 
    2422{ 
    25   return grammar.sgl[role] || snodes[head].prop.required[role]; 
     23  return grammar.is_sgl(role) || sgraph[head].prop.required[role]; 
    2624} 
    2725 
    2826void apply_constraints(int head, Role role) 
    2927{ 
    30   if(grammar.sgl[role]) snodes[head].prop.forbidden.set(role); 
    31   snodes[head].prop.required.reset(role); 
     28  if(grammar.is_sgl(role)) sgraph[head].prop.forbidden.set(role); 
     29  sgraph[head].prop.required.reset(role); 
    3230} 
    3331 
     
    3533{ 
    3634  NodeProp ret=headprop; 
    37   if(grammar.sgl[role]) ret.forbidden.set(role); 
     35  if(grammar.is_sgl(role)) ret.forbidden.set(role); 
    3836  ret.required.reset(role); 
    3937  return ret; 
     
    4442  NodeProp ret=headprop; 
    4543 
    46   if(grammar.sgl[role]) ret.forbidden.set(role); 
     44  if(grammar.is_sgl(role)) ret.forbidden.set(role); 
    4745  ret.required.reset(role); 
    4846  return ret; 
     
    5250{ 
    5351  for(vector<int>::iterator ps=mnode.snodes.begin(); ps!=mnode.snodes.end(); ++ps) 
    54     if(snodes[*ps].prop==p && snodes[*ps].LH==newheadLH && snodes[*ps].LV==newheadLV) 
     52    if(sgraph[*ps].prop==p && sgraph[*ps].LH==newheadLH && sgraph[*ps].LV==newheadLV) 
    5553      return *ps; 
    5654  return -1; 
     
    5957void connect_left(list<int>::iterator h, list<int>::iterator d, Role r) 
    6058{ 
    61   NodeProp &oldheadprop = snodes[*h].prop; 
    62   NodeProp newheadprop; 
    63   bitset<MAXNODES> newheadLV; 
    64   bitset<MAXNODES> newheadLH; 
    65   bitset<MAXNODES> newheadLD; 
    66    
    67   newheadprop=compute_prop_left(oldheadprop,r); 
     59  NodeProp &oldheadprop = sgraph[*h].prop; 
     60  NodeProp newheadprop  = compute_prop_left(oldheadprop,r); 
    6861   
    6962  int newheadind; 
     
    7265  else 
    7366  { 
    74     newheadLH = snodes[*h].LH; 
    75     newheadLV = snodes[*d].LV; 
    76     newheadLD = snodes[*h].LD; 
    77  
    78     newheadind = get_node(*(snodes[*h].mnode), newheadprop, newheadLH, newheadLV); 
     67    bitset<MAXNODES> newheadLH = sgraph[*h].LH; 
     68    bitset<MAXNODES> newheadLV = sgraph[*d].LV; 
     69    bitset<MAXNODES> newheadLD = sgraph[*h].LD; 
     70 
     71    newheadind = get_node(mgraph[sgraph[*h].mnode], newheadprop, newheadLH, newheadLV); 
    7972    if( newheadind < 0 ) 
    8073    { 
     
    8275      list<int>::iterator nextit=h; ++nextit; 
    8376      nodelist.insert(nextit,newheadind); 
    84       snodes[newheadind].LH=newheadLH; 
    85       snodes[newheadind].in_LH=true; 
    86       snodes[newheadind].LV.reset(); 
    87       snodes[newheadind].LD = newheadLD; 
     77      sgraph[newheadind].LH=newheadLH; 
     78      sgraph[newheadind].LD = newheadLD; 
     79      sgraph[newheadind].in_LH=true; 
     80      sgraph[newheadind].LV.reset(); 
    8881       
    8982      if(debug) sgraph.print_node_debug(stderr," C ",newheadind); 
    9083    } 
    9184    else 
    92       snodes[newheadind].LD |= newheadLD; // TYLKO DLA LD 
     85      sgraph[newheadind].LD |= newheadLD; // TYLKO DLA LD 
    9386  } 
    9487 
    95   snodes[newheadind].deps.push_back(Arc(*d,r,*h)); 
    96    
    97   if(snodes[*d].saturated()) snodes[newheadind].LV |= snodes[*d].LV; 
    98   snodes[newheadind].LD.set(*d); 
    99   if(snodes[*d].saturated()) snodes[newheadind].LD |= snodes[*d].LD; 
    100    
    101   if(debug) 
    102     sgraph.print_arc(stderr,*d,newheadind,r,0), sgraph.print_node_debug(stderr," U ",newheadind); 
    103 } 
    104  
     88  sgraph[newheadind].deps.push_back(Arc(*d,r,*h)); 
     89   
     90  if(sgraph[*d].saturated()) sgraph[newheadind].LV |= sgraph[*d].LV; 
     91 
     92  sgraph[newheadind].LD.set(*d); 
     93  if(sgraph[*d].saturated()) sgraph[newheadind].LD |= sgraph[*d].LD; 
     94   
     95  if(debug) sgraph.print_arc(stderr,*d,newheadind,r,0), sgraph.print_node_debug(stderr," U ",newheadind); 
     96} 
    10597 
    10698void connect_right(list<int>::iterator h, list<int>::iterator d, Role r) 
    10799{ 
    108   NodeProp &oldheadprop = snodes[*h].prop; 
    109   NodeProp newheadprop; 
    110   bitset<MAXNODES> newheadLV; 
    111   bitset<MAXNODES> newheadLH; 
    112   bitset<MAXNODES> newheadLD; 
     100  NodeProp &oldheadprop = sgraph[*h].prop; 
     101  NodeProp newheadprop = compute_prop_right(oldheadprop,r); 
    113102  int newheadind; 
    114103   
    115   newheadprop = compute_prop_right(oldheadprop,r); 
    116104  if(oldheadprop==newheadprop) 
    117105    newheadind = *h; 
    118106  else 
    119107  { 
    120     newheadLH = snodes[*h].LH; 
    121     newheadLV = snodes[*h].LV; 
    122     newheadLD = snodes[*h].LD; 
    123  
    124     newheadind = get_node(*(snodes[*h].mnode), newheadprop, newheadLH, newheadLV); 
     108    bitset<MAXNODES> newheadLH = sgraph[*h].LH; 
     109    bitset<MAXNODES> newheadLV = sgraph[*h].LV; 
     110    bitset<MAXNODES> newheadLD = sgraph[*h].LD; 
     111 
     112    newheadind = get_node(mgraph[sgraph[*h].mnode], newheadprop, newheadLH, newheadLV); 
    125113    if( newheadind < 0 ) 
    126114    { 
    127115      newheadind = sgraph.clone(*h,newheadprop); 
    128       snodes[newheadind].LH=newheadLH; 
    129       snodes[newheadind].in_LH=false; 
    130       snodes[newheadind].LV=newheadLV; 
    131       snodes[newheadind].LD=newheadLD; 
    132116      list<int>::iterator nextit=h; ++nextit; 
    133117      nodelist.insert(nextit,newheadind); 
     118      sgraph[newheadind].LH=newheadLH; 
     119      sgraph[newheadind].LD=newheadLD; 
     120      sgraph[newheadind].in_LH=false; 
     121      sgraph[newheadind].LV=newheadLV; 
    134122       
    135123      if(debug) sgraph.print_node_debug(stderr," C ",newheadind); 
    136124    } 
    137125    else 
    138       snodes[newheadind].LD |= newheadLD; // TYLKO DLA LD 
     126      sgraph[newheadind].LD |= newheadLD; // TYLKO DLA LD 
    139127  } 
    140128   
    141   snodes[*d].heads.push_back(Arc(newheadind,r,*h)); 
    142  
    143   snodes[*d].LH.set(newheadind); 
    144  
    145   if(snodes[newheadind].saturated()) snodes[*d].LH |= snodes[newheadind].LH; 
    146  
    147   if(debug) 
    148     sgraph.print_arc(stderr,newheadind,*d,r,1), sgraph.print_node_debug(stderr," U ",*d); 
     129  sgraph[*d].heads.push_back(Arc(newheadind,r,*h)); 
     130 
     131  sgraph[*d].LH.set(newheadind); 
     132 
     133  if(sgraph[newheadind].saturated()) sgraph[*d].LH |= sgraph[newheadind].LH; 
     134 
     135  if(debug) sgraph.print_arc(stderr,newheadind,*d,r,1), sgraph.print_node_debug(stderr," U ",*d); 
    149136   
    150137} 
     
    156143    if(sgraph.visible(*i,*j) && sgraph.saturated(*i)) 
    157144    { 
    158       Roles& ji_roles = grammar.connect[snodes[*j].mnode->cat][snodes[*i].mnode->cat]; 
     145      Roles& ji_roles = grammar.connectable( mgraph[sgraph[*j].mnode].cat, mgraph[sgraph[*i].mnode].cat ); 
    159146      for(RolesIter r=ji_roles.begin(); r!=ji_roles.end();++r) 
    160         if(grammar.check_constr(snodes[*j].prop,snodes[*i].prop,0,*r)) 
     147        if(grammar.check_constr(sgraph[*j].prop,sgraph[*i].prop,0,*r)) 
    161148          connect_left(j,i,*r); 
    162149    } 
     
    169156    if(sgraph.visible(*i,*j)) 
    170157    { 
    171       Roles& ij_roles = grammar.connect[snodes[*i].mnode->cat][snodes[*j].mnode->cat]; 
     158      Roles& ij_roles = grammar.connectable( mgraph[sgraph[*i].mnode].cat, mgraph[sgraph[*j].mnode].cat ); 
    172159      for(RolesIter r=ij_roles.begin(); r!=ij_roles.end();++r) 
    173         if(grammar.check_constr(snodes[*i].prop,snodes[*j].prop,1,*r)) 
     160        if(grammar.check_constr(sgraph[*i].prop,sgraph[*j].prop,1,*r)) 
    174161          connect_right(i,j,*r); 
    175162    } 
     
    182169  for(++i; i!=nodelist.end(); ++i) 
    183170    { 
    184       for(vector<Arc>::iterator da=sgraph.nodes[*i].deps.begin()--; da!=sgraph.nodes[*i].deps.end(); ++da) 
    185         sgraph.nodes[da->dst].heads.push_back(Arc(*i,da->role,da->anc)); 
    186       for(vector<Arc>::iterator ha=sgraph.nodes[*i].heads.begin(); ha!=sgraph.nodes[*i].heads.end(); ++ha) 
    187         sgraph.nodes[ha->dst].deps.push_back(Arc(*i,ha->role,ha->anc)); 
     171      for(vector<Arc>::iterator da=sgraph[*i].deps.begin()--; da!=sgraph[*i].deps.end(); ++da) 
     172        sgraph[da->dst].heads.push_back(Arc(*i,da->role,da->anc)); 
     173      for(vector<Arc>::iterator ha=sgraph[*i].heads.begin(); ha!=sgraph[*i].heads.end(); ++ha) 
     174        sgraph[ha->dst].deps.push_back(Arc(*i,ha->role,ha->anc)); 
    188175    } 
    189176} 
     
    192179void dgp0() 
    193180{ 
    194   snodes=sgraph.nodes; 
    195181 
    196182  nodelist.clear(); 
     
    198184  processed=nodelist.begin(); 
    199185 
    200   for(int m=0; m<mgraph.n ; ++m) 
     186  for(int m=0; m<mgraph.size() ; ++m) 
    201187  { 
    202     int basenode = sgraph.add_base_snode(mgraph.nodes+m); // ma zwracaæ SNode* 
     188    int basenode = sgraph.add_base_snode(m); // ma zwracaæ SNode* 
     189 
    203190    set_initial_constraints(basenode); 
    204191    nodelist.push_back(basenode); 
     
    213200      processed=cursor; 
    214201    } 
     202 
    215203  } 
    216204  reverse_links(); 
Note: See TracChangeset for help on using the changeset viewer.