Changeset 3b02b04 for src/dgp/dgp1.cc


Ignore:
Timestamp:
01/17/13 20:50:41 (11 years ago)
Author:
Tomasz Obrebski <to@…>
Branches:
master
Children:
d2f119e
Parents:
555c7f8
git-author:
Tomasz Obrebski <to@…> (01/17/13 20:50:41)
git-committer:
Tomasz Obrebski <to@…> (01/17/13 20:50:41)
Message:

prawie ca�kiem nowe dgc, du�e zmiany w dgp, pomniejsze poprawki

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/dgp/dgp1.cc

    ra15e59b r3b02b04  
    1010list<int> nodelist; 
    1111list<int>::iterator processed; 
     12 
     13 
     14void print_sets(int n); 
     15 
    1216 
    1317//==================================================================================================== 
     
    4448  ret.forbidden |= grammar.constr_exclude(link.role); 
    4549 
    46   ret.boubbles=bs; 
     50  ret.boubbles.merge(bs); //DOBRZE 
    4751  ret.flags |= ( depflags & grammar.pass_flags(link.role) ); 
    4852 
     
    5862{ 
    5963  NodeProp ret=depprop; 
    60   ret.boubbles=bs; 
     64  ret.boubbles.merge(bs); //DOBRZE 
    6165  return ret; 
    6266} 
     
    6771{ 
    6872  MNode& mnode = mgraph[mnodeind]; 
     73  int ret=-1; 
    6974  for(vector<int>::iterator ps=mnode.snodes.begin(); ps!=mnode.snodes.end(); ++ps) 
    70     if(sgraph[*ps].prop==p && sgraph[*ps].LH==newheadLH && sgraph[*ps].LV==newheadLV)      return *ps; 
    71   return -1; 
     75    { 
     76      if(debug) fprintf(stderr,"#find existing node: checking %d ... \n", *ps); 
     77      if(sgraph[*ps].prop==p) 
     78        if(sgraph[*ps].LH==newheadLH && sgraph[*ps].LV==newheadLV) 
     79          { 
     80            ret = *ps; 
     81            // fprintf(stderr,"FIND EXISTING NODE SUCCEEDED BEACAUSE OF LH/LV equality ()\n"); 
     82          } 
     83        else 
     84          { 
     85            // fprintf(stderr,"FIND EXISTING NODE FAILED BEACAUSE OF LH/LV inequality\n"); 
     86          } 
     87    } 
     88 
     89  if(debug) fprintf(stderr,"\n"); 
     90  return ret; 
    7291} 
    7392 
     
    83102        ret.push_back(new_boubble); 
    84103    } 
     104 
    85105  return ret; 
    86106} 
     
    120140//==================================================================================================== 
    121141 
    122 int create_new_head_node_left(list<int>::iterator h, NodeProp& newheadprop, bitset<MAXNODES>& newheadLH, bitset<MAXNODES>& newheadLD, bitset<MAXNODES>& newheadLV) 
    123 { 
    124   int newheadind = sgraph.clone(*h,newheadprop); 
    125   list<int>::iterator nextit=h; ++nextit; 
    126   nodelist.insert(nextit,newheadind); 
     142void copy_links(int i, int j) 
     143{ 
     144  sgraph[j].heads = sgraph[i].heads; 
     145  sgraph[j].deps = sgraph[i].deps; 
     146} 
     147 
     148 
     149void create_reverse_links(int n) 
     150{ 
     151  for(vector<Arc>::iterator a=sgraph[n].heads.begin(); a != sgraph[n].heads.end(); a++) 
     152    sgraph[a->dst].deps.push_back(Arc(n,a->role,a->headanc,a->depanc)); 
     153 
     154  for(vector<Arc>::iterator a=sgraph[n].deps.begin(); a != sgraph[n].deps.end(); a++) 
     155    sgraph[a->dst].heads.push_back(Arc(n,a->role,a->headanc,a->depanc)); 
     156} 
     157 
     158//==================================================================================================== 
     159 
     160int create_new_head_node_left(int h, NodeProp& newheadprop, bitset<MAXNODES>& newheadLH, bitset<MAXNODES>& newheadLD, bitset<MAXNODES>& newheadLV) 
     161{ 
     162  int newheadind = sgraph.clone(h,newheadprop); 
     163  // list<int>::iterator nextit=h; ++nextit; 
     164  // nodelist.insert(nextit,newheadind); 
     165  nodelist.push_back(newheadind); 
    127166  sgraph[newheadind].LH=newheadLH; 
    128167  sgraph[newheadind].LD = newheadLD; 
    129168  sgraph[newheadind].in_LH=true; 
    130169  sgraph[newheadind].LV.reset(); 
    131    
    132   if(debug) sgraph.print_node_debug(stderr,"C ",newheadind,*h); 
    133    
     170 
     171  copy_links(h,newheadind); 
     172  create_reverse_links(newheadind); 
     173   
     174  if(debug) sgraph.print_node_debug(stderr,"C ",newheadind,h); 
     175  if(debug) print_sets(newheadind); 
    134176  return newheadind; 
    135177} 
    136178 
    137 int create_new_dep_node_left(list<int>::iterator d, NodeProp& prop, bitset<MAXNODES>& LH, bitset<MAXNODES>& LD, bitset<MAXNODES>& LV) 
    138 { 
    139   int newind = sgraph.clone(*d,prop); 
    140   list<int>::iterator nextit=d; ++nextit; 
    141   nodelist.insert(nextit,newind); 
     179int create_new_dep_node_left(int d, NodeProp& prop, bitset<MAXNODES>& LH, bitset<MAXNODES>& LD, bitset<MAXNODES>& LV) 
     180{ 
     181  int newind = sgraph.clone(d,prop); 
     182  // list<int>::iterator nextit=d; ++nextit; 
     183  // nodelist.insert(nextit,newind); 
     184  nodelist.push_back(newind); 
    142185  sgraph[newind].LH.reset(); 
    143186  sgraph[newind].LD=LD; 
    144187  sgraph[newind].in_LH=false; //??????? 
    145188  sgraph[newind].LV.reset(); 
    146    
    147   if(debug) sgraph.print_node_debug(stderr,"C ",newind,*d); 
     189 
     190  copy_links(d,newind); 
     191  create_reverse_links(newind); 
     192   
     193  if(debug) sgraph.print_node_debug(stderr,"C ",newind,d); 
     194  if(debug) print_sets(newind); 
    148195   
    149196  return newind; 
    150197} 
    151198 
    152 int create_new_head_node_right(list<int>::iterator h, NodeProp& newheadprop, bitset<MAXNODES>& newheadLH, bitset<MAXNODES>& newheadLD, bitset<MAXNODES>& newheadLV) 
    153 { 
    154   int newheadind = sgraph.clone(*h,newheadprop); 
    155   list<int>::iterator nextit=h; ++nextit; 
    156   nodelist.insert(nextit,newheadind); 
     199int create_new_head_node_right(int h, NodeProp& newheadprop, bitset<MAXNODES>& newheadLH, bitset<MAXNODES>& newheadLD, bitset<MAXNODES>& newheadLV) 
     200{ 
     201  int newheadind = sgraph.clone(h,newheadprop); 
     202  // list<int>::iterator nextit=h; ++nextit; 
     203  // nodelist.insert(nextit,newheadind); 
     204  nodelist.push_back(newheadind); 
    157205  sgraph[newheadind].LH=newheadLH; 
    158206  sgraph[newheadind].LD=newheadLD; 
     
    160208  sgraph[newheadind].LV=newheadLV; 
    161209   
    162   if(debug) sgraph.print_node_debug(stderr,"C ",newheadind,*h); 
     210  copy_links(h,newheadind); 
     211  create_reverse_links(newheadind); 
     212 
     213  if(debug) sgraph.print_node_debug(stderr,"C ",newheadind,h); 
     214  if(debug) print_sets(newheadind); 
    163215   
    164216  return newheadind; 
    165217} 
    166218 
    167 int create_new_dep_node_right(list<int>::iterator d, NodeProp& prop, bitset<MAXNODES>& LH, bitset<MAXNODES>& LD, bitset<MAXNODES>& LV) 
    168 { 
    169   int newind = sgraph.clone(*d,prop); 
    170   list<int>::iterator nextit=d; ++nextit; 
    171   nodelist.insert(nextit,newind); 
     219int create_new_dep_node_right(int d, NodeProp& prop, bitset<MAXNODES>& LH, bitset<MAXNODES>& LD, bitset<MAXNODES>& LV) 
     220{ 
     221  int newind = sgraph.clone(d,prop); 
     222  nodelist.push_back(newind); 
    172223  sgraph[newind].LH=LH; 
    173224  sgraph[newind].LD=LD; 
     
    175226  sgraph[newind].LV.reset(); 
    176227   
    177   if(debug) sgraph.print_node_debug(stderr,"C ",newind,*d); 
     228  copy_links(d,newind); 
     229  create_reverse_links(newind); 
     230 
     231  if(debug) sgraph.print_node_debug(stderr,"C ",newind,d); 
     232  if(debug) print_sets(newind); 
    178233   
    179234  return newind; 
     
    182237//==================================================================================================== 
    183238 
    184 void connect_left(list<int>::iterator h, list<int>::iterator d, const Link& l, list<Boubble*>& new_head_boubbles, list<Boubble*>& new_dep_boubbles) 
    185 { 
    186  
    187   NodeProp &oldheadprop = sgraph[*h].prop; 
    188   NodeProp &olddepprop = sgraph[*d].prop; 
     239void connect_left(int h, int d, const Link& l, list<Boubble*>& new_head_boubbles, list<Boubble*>& new_dep_boubbles) 
     240{ 
     241 
     242  NodeProp &oldheadprop = sgraph[h].prop; 
     243  NodeProp &olddepprop = sgraph[d].prop; 
    189244 
    190245  NodeProp newheadprop  = compute_head_prop(oldheadprop,l,new_head_boubbles,olddepprop.flags); 
     
    192247  int newheadind; 
    193248  if(oldheadprop==newheadprop) 
    194     newheadind = *h; 
     249    newheadind = h; 
    195250  else 
    196251  { 
    197     bitset<MAXNODES> newheadLH = sgraph[*h].LH; 
    198     bitset<MAXNODES> newheadLV = sgraph[*d].LV; 
    199     bitset<MAXNODES> newheadLD = sgraph[*h].LD; 
    200  
    201     newheadind = find_existing_node(sgraph[*h].mnode, newheadprop, newheadLH, newheadLV); 
    202     if( newheadind >= 0 ) 
     252    bitset<MAXNODES> newheadLH = sgraph[h].LH; 
     253    bitset<MAXNODES> newheadLV = sgraph[d].LV; 
     254    bitset<MAXNODES> newheadLD = sgraph[h].LD; 
     255 
     256    //    vector<int> newedge; 
     257 
     258    newheadind = find_existing_node(sgraph[h].mnode, newheadprop, newheadLH, newheadLV); 
     259    if( newheadind >= 0) // W£¡CZONE 
    203260      sgraph[newheadind].LD |= newheadLD; 
    204261    else 
    205       newheadind = create_new_head_node_left(h,newheadprop,newheadLH,newheadLD,newheadLV); 
     262      { 
     263        newheadind = create_new_head_node_left(h,newheadprop,newheadLH,newheadLD,newheadLV); 
     264        sgraph[newheadind].edge.clear(); 
     265        sgraph[newheadind].edge_contains_self = false; 
     266      } 
     267     
    206268  } 
    207269 
    208  
    209  
    210270  NodeProp newdepprop = compute_dep_prop(olddepprop,l,new_dep_boubbles); 
    211271 
     
    213273   
    214274  if(olddepprop==newdepprop) 
    215     newdepind = *d; 
     275    newdepind = d; 
    216276  else 
    217277  { 
    218     bitset<MAXNODES> newdepLH = sgraph[*d].LH; 
    219     bitset<MAXNODES> newdepLV = sgraph[*d].LV; 
    220     bitset<MAXNODES> newdepLD = sgraph[*d].LD; 
    221  
    222     newdepind = find_existing_node(sgraph[*d].mnode, newdepprop, newdepLH, newdepLV); 
    223     if( newdepind >= 0 ) 
     278    bitset<MAXNODES> newdepLH = sgraph[d].LH; 
     279    bitset<MAXNODES> newdepLV = sgraph[d].LV; 
     280    bitset<MAXNODES> newdepLD = sgraph[d].LD; 
     281 
     282    newdepind = find_existing_node(sgraph[d].mnode, newdepprop, newdepLH, newdepLV); 
     283    if( newdepind >= 0) // W£¡CZONE 
    224284      sgraph[newdepind].LD |= newdepLD; // TYLKO DLA LD 
    225285    else 
    226       newdepind = create_new_dep_node_left(d,newdepprop,newdepLH,newdepLD,newdepLV); 
     286      { 
     287        newdepind = create_new_dep_node_left(d,newdepprop,newdepLH,newdepLD,newdepLV); 
     288        sgraph[newdepind].edge.clear(); 
     289        //sgraph[newdepind].edge.push_back(newdepind); // TO 
     290        sgraph[newdepind].edge_contains_self = true; // LUB TO 
     291      } 
    227292  } 
    228  
    229   sgraph[newheadind].deps.push_back(Arc(newdepind,l.role,*h,*d)); 
    230    
    231   if(sgraph[*d].saturated()) sgraph[newheadind].LV |= sgraph[*d].LV; 
    232  
    233   sgraph[newheadind].LD.set(*d); 
    234   if(sgraph[*d].saturated()) sgraph[newheadind].LD |= sgraph[*d].LD; 
    235    
    236   if(debug) sgraph.print_arc(stderr,newheadind,*d,l.role,0); 
    237   if(debug) sgraph.print_node_debug(stderr,"U ",newheadind,*h); 
    238   if(debug) sgraph.print_node_debug(stderr,"U ",*d,*d); 
     293   
     294 
     295  sgraph[newheadind].deps.push_back(Arc(newdepind,l.role,h,d)); 
     296  sgraph[newdepind].heads.push_back(Arc(newheadind,l.role,h,d)); 
     297  sgraph[newheadind].edge.push_back(newdepind); 
     298   
     299  if(sgraph[d].saturated()) sgraph[newheadind].LV |= sgraph[d].LV; 
     300 
     301  sgraph[newheadind].LD.set(d); 
     302  if(sgraph[d].saturated()) sgraph[newheadind].LD |= sgraph[d].LD; 
     303   
     304  if(debug) sgraph.print_arc(stderr,newheadind,d,l.role,0); 
     305  if(debug) sgraph.print_node_debug(stderr,"U ",newheadind,h); 
     306  if(debug) print_sets(newheadind); 
     307  if(debug) sgraph.print_node_debug(stderr,"U ",newdepind,d); 
     308  if(debug) print_sets(newdepind); 
    239309} 
    240310 
    241311//---------------------------------------------------------------------------------------------------- 
    242312 
    243 void connect_right(list<int>::iterator h, list<int>::iterator d, const Link& l, list<Boubble*>& new_head_boubbles, list<Boubble*>& new_dep_boubbles) 
    244 { 
    245   NodeProp &oldheadprop = sgraph[*h].prop; 
    246  
    247   NodeProp newheadprop = compute_head_prop(oldheadprop,l,new_head_boubbles, sgraph[*d].prop.flags); 
     313void connect_right(int h, int d, const Link& l, list<Boubble*>& new_head_boubbles, list<Boubble*>& new_dep_boubbles) 
     314{ 
     315  NodeProp &oldheadprop = sgraph[h].prop; 
     316 
     317  NodeProp newheadprop = compute_head_prop(oldheadprop,l,new_head_boubbles, sgraph[d].prop.flags); 
    248318 
    249319  int newheadind; 
    250320   
    251321  if(oldheadprop==newheadprop) 
    252     newheadind = *h; 
     322    newheadind = h; 
    253323  else 
    254324  { 
    255     bitset<MAXNODES> newheadLH = sgraph[*h].LH; 
    256     bitset<MAXNODES> newheadLV = sgraph[*h].LV; 
    257     bitset<MAXNODES> newheadLD = sgraph[*h].LD; 
    258  
    259     newheadind = find_existing_node(sgraph[*h].mnode, newheadprop, newheadLH, newheadLV); 
    260     if( newheadind >= 0 ) 
     325    bitset<MAXNODES> newheadLH = sgraph[h].LH; 
     326    bitset<MAXNODES> newheadLV = sgraph[h].LV; 
     327    bitset<MAXNODES> newheadLD = sgraph[h].LD; 
     328 
     329    newheadind = find_existing_node(sgraph[h].mnode, newheadprop, newheadLH, newheadLV); 
     330 
     331    if(debug) fprintf(stderr,"#HEAD EXISTS %d\n",newheadind); 
     332 
     333    if( newheadind >= 0) // W£¡CZONE 
    261334      sgraph[newheadind].LD |= newheadLD; // TYLKO DLA LD 
    262335    else 
    263       newheadind = create_new_head_node_right(h,newheadprop,newheadLH,newheadLD,newheadLV); 
     336      { 
     337        newheadind = create_new_head_node_right(h,newheadprop,newheadLH,newheadLD,newheadLV); 
     338        //if(!sgraph[h].edge.empty()) sgraph[newheadind].edge.push_back(newheadind); // TO 
     339        sgraph[newheadind].edge_contains_self = sgraph[h].edge_contains_self;      // LUB TO 
     340        sgraph[newheadind].visible_as_neighbour = false; 
     341      } 
    264342  } 
    265343 
    266   NodeProp &olddepprop = sgraph[*d].prop; 
     344  NodeProp &olddepprop = sgraph[d].prop; 
    267345  NodeProp newdepprop = compute_dep_prop(olddepprop,l,new_dep_boubbles); 
    268346 
     
    270348   
    271349  if(olddepprop==newdepprop) 
    272     newdepind = *d; 
     350    newdepind = d; 
    273351  else 
    274352  { 
    275     bitset<MAXNODES> newdepLH = sgraph[*d].LH; 
    276     bitset<MAXNODES> newdepLV = sgraph[*d].LV; 
    277     bitset<MAXNODES> newdepLD = sgraph[*d].LD; 
    278  
    279     newdepind = find_existing_node(sgraph[*d].mnode, newdepprop, newdepLH, newdepLV); 
    280     if( newdepind >= 0 ) 
     353    bitset<MAXNODES> newdepLH = sgraph[d].LH; 
     354    bitset<MAXNODES> newdepLV = sgraph[d].LV; 
     355    bitset<MAXNODES> newdepLD = sgraph[d].LD; 
     356 
     357    newdepind = find_existing_node(sgraph[d].mnode, newdepprop, newdepLH, newdepLV); 
     358 
     359    if(debug) fprintf(stderr,"#DEP EXISTS %d\n",newdepind); 
     360 
     361    if( newdepind >= 0) // W£¡CZONE 
    281362      sgraph[newdepind].LD |= newdepLD; // TYLKO DLA LD 
    282363    else 
    283       newdepind = create_new_dep_node_right(d,newdepprop,newdepLH,newdepLD,newdepLV); 
     364      { 
     365        newdepind = create_new_dep_node_right(d,newdepprop,newdepLH,newdepLD,newdepLV); 
     366        sgraph[newdepind].edge.clear(); 
     367        sgraph[newdepind].edge_contains_self = false; 
     368      } 
    284369  } 
    285370 
    286371 
    287  
    288    
    289   sgraph[newdepind].heads.push_back(Arc(newheadind,l.role,*h,*d)); 
     372  sgraph[newdepind].heads.push_back(Arc(newheadind,l.role,h,d)); 
     373  sgraph[newheadind].deps.push_back(Arc(newdepind,l.role,h,d)); 
     374  //sgraph[newdepind].edge.push_back(newheadind); 
    290375 
    291376  sgraph[newdepind].LH.set(newheadind); 
     
    296381 
    297382  if(debug) sgraph.print_arc(stderr,newheadind,newdepind,l.role,1); 
    298   if(debug) sgraph.print_node_debug(stderr,"U ",newheadind,*h); 
    299   if(debug) sgraph.print_node_debug(stderr,"U ",newdepind,*d); 
     383  if(debug) sgraph.print_node_debug(stderr,"U ",newheadind,h); 
     384  if(debug) sgraph.print_node_debug(stderr,"U ",newdepind,d); 
    300385   
    301386} 
     
    323408} 
    324409 
    325 // bool check_boubbles_at_target(list<Boubble*> boubbles, int node) 
    326 // { 
    327 //   for(list<Boubble*>::iterator b = boubbles.begin(); b != boubbles.end(); ++b ) 
    328 //     if( (*b)->is_at_target() && !grammar.check_longrel(sgraph.cat((*b)->src()), sgraph.cat(node), (*b)->rel()) ) 
    329 //       return false; 
    330 //   return true; 
    331 // } 
    332  
    333 //==================================================================================================== 
    334  
    335 void try_connect_dependents(list<int>::iterator j) 
    336 { 
    337   for(list<int>::iterator i(j); i!=nodelist.begin(); --i) 
    338     if(sgraph.visible(*i,*j) && sgraph.saturated(*i)) 
    339     { 
    340       if(debug) {fprintf(stderr,"## %d <-- %d ... ",*i,*j); } 
    341  
    342       list<const Link*> ji_links = grammar.connectable2( sgraph.cat(*j), sgraph.cat(*i), sgraph[*j].prop.flags, sgraph[*i].prop.flags); // ref do Roles!!! 
     410//==================================================================================================== 
     411 
     412void try_connect_dependents(int j) 
     413{ 
     414  // for(list<int>::iterator i(j); i!=nodelist.begin(); --i) 
     415  //   if(sgraph.visible(*i,*j) && sgraph.saturated(*i)) 
     416  LViterator lvi(sgraph,j); 
     417  int i; 
     418  while((i=lvi.next()) >= 0) 
     419    if(sgraph.saturated(i)) 
     420      { 
     421      if(debug) {fprintf(stderr,"## %d <-- %d ... ",i,j); } 
     422 
     423      list<const Link*> ji_links = grammar.connectable2( sgraph.cat(j), sgraph.cat(i), sgraph[j].prop.flags, sgraph[i].prop.flags); // ref do Roles!!! 
    343424      list<const Link*>::iterator ri = ji_links.begin(); 
    344425      if(ri == ji_links.end()) { if(debug) fprintf(stderr,"no roles\n"); } 
     
    346427        { 
    347428          for(; ri != ji_links.end(); ++ri ) 
    348             if(!grammar.check_constr2(sgraph[*j].prop,sgraph[*i].prop,0,**ri )) 
     429            if(!grammar.check_constr2(sgraph[j].prop,sgraph[i].prop,0,**ri )) 
    349430              { if(debug) fprintf(stderr,"constraints failed\n"); } 
    350431            else 
    351432              { 
    352                 list<Boubble*> new_head_boubbles = collect_head_boubbles(*j,*i,(*ri)->role); 
    353                 list<Boubble*> new_dep_boubbles = collect_dep_boubbles(*j,*i,(*ri)->role); 
     433                list<Boubble*> new_head_boubbles = collect_head_boubbles(j,i,(*ri)->role); 
     434                list<Boubble*> new_dep_boubbles = collect_dep_boubbles(j,i,(*ri)->role); 
    354435                 
    355                 if( !(check_boubbles_at_target(new_head_boubbles,*j) && check_boubbles_at_target(new_dep_boubbles,*i)) ) 
     436                if( !(check_boubbles_at_target(new_head_boubbles,j) && check_boubbles_at_target(new_dep_boubbles,i)) ) 
    356437                  { if(debug) fprintf(stderr,"boubbles failed\n"); } 
    357438                else 
     
    368449//---------------------------------------------------------------------------------------------------- 
    369450 
    370 void try_connect_heads(list<int>::iterator j) 
    371 { 
    372   for(list<int>::iterator i(j); i!=nodelist.begin(); --i) 
    373     if(sgraph.visible(*i,*j)) 
    374     { 
    375       if(debug) fprintf(stderr, "## %d --> %d ... ",*i,*j); 
    376  
    377       list<const Link*> ij_links = grammar.connectable2( sgraph.cat(*i), sgraph.cat(*j), sgraph[*i].prop.flags, sgraph[*j].prop.flags ); 
     451void try_connect_heads(int j) 
     452{ 
     453  // for(list<int>::iterator i(j); i!=nodelist.begin(); --i) 
     454  //   if(sgraph.visible(*i,*j) && sgraph.saturated(*j)) 
     455 
     456  LViterator lvi(sgraph,j); 
     457  int i; 
     458  while((i=lvi.next()) >= 0) 
     459    if(sgraph.saturated(j)) 
     460    { 
     461      if(debug) fprintf(stderr, "## %d --> %d ... ",i,j); 
     462 
     463      list<const Link*> ij_links = grammar.connectable2( sgraph.cat(i), sgraph.cat(j), sgraph[i].prop.flags, sgraph[j].prop.flags ); 
    378464      list<const Link*>::iterator ri = ij_links.begin(); 
    379465      if(ri == ij_links.end()) { if(debug) fprintf(stderr,"no roles\n"); } 
     
    381467        { 
    382468          for(; ri != ij_links.end(); ++ri ) 
    383             if( !grammar.check_constr2( sgraph[*i].prop, sgraph[*j].prop, 1, **ri ) ) 
     469            if( !grammar.check_constr2( sgraph[i].prop, sgraph[j].prop, 1, **ri ) ) 
    384470              { if(debug) fprintf(stderr,"constraints failed\n"); } 
    385471            else 
    386472              { 
    387                 list<Boubble*> new_head_boubbles = collect_head_boubbles(*i,*j,(*ri)->role); 
    388                 list<Boubble*> new_dep_boubbles = collect_dep_boubbles(*i,*j,(*ri)->role); 
     473                list<Boubble*> new_head_boubbles = collect_head_boubbles(i,j,(*ri)->role); 
     474                list<Boubble*> new_dep_boubbles = collect_dep_boubbles(i,j,(*ri)->role); 
    389475                 
    390                 if( !(check_boubbles_at_target(new_head_boubbles,*i) && check_boubbles_at_target(new_dep_boubbles,*j)) ) 
     476                if( !(check_boubbles_at_target(new_head_boubbles,i) && check_boubbles_at_target(new_dep_boubbles,j)) ) 
    391477                  { if(debug) fprintf(stderr,"boubbles failed\n"); } 
    392478                else 
     
    399485    } 
    400486} 
    401    
     487 
     488//==================================================================================================== 
     489 
     490void update_sets() 
     491{ 
     492  for(int n=0; n<sgraph.size(); ++n) 
     493    { 
     494      LViterator lvi(sgraph,n,false); 
     495      LHiterator lhi(sgraph,n); 
     496      LDiterator ldi(sgraph,n); 
     497      int i; 
     498 
     499      // printf("UPDATING LV[%d]:",n); 
     500      while((i=lvi.next())>=0) 
     501        { 
     502          // printf(" %d",i); 
     503          sgraph[n].LV.set(i); 
     504        } 
     505      // printf("\n"); 
     506 
     507      while((i=lhi.next())>=0) sgraph[n].LH.set(i); 
     508      while((i=ldi.next())>=0) sgraph[n].LD.set(i); 
     509    } 
     510} 
     511 
     512//==================================================================================================== 
     513 
     514void print_sets(int n) 
     515{ 
     516  LViterator lvi(sgraph,n); 
     517  LHiterator lhi(sgraph,n); 
     518  LDiterator ldi(sgraph,n); 
     519   
     520  int i;   
     521  printf("LV[%d]: ",n); 
     522  while((i=lvi.next())>=0) 
     523        { 
     524          printf("%d ",i); 
     525          sgraph[n].LV.set(i); 
     526        } 
     527 
     528  printf("LH[%d]: ",n); 
     529  while((i=lhi.next())>=0) 
     530    { 
     531      printf("%d ",i); 
     532      sgraph[n].LH.set(i); 
     533    } 
     534  printf("LD[%d]: ",n); 
     535  while((i=ldi.next())>=0) 
     536    { 
     537      printf("%d ",i); 
     538      sgraph[n].LD.set(i); 
     539    } 
     540  printf("\n"); 
     541} 
     542 
    402543//==================================================================================================== 
    403544 
     
    430571    nodelist.push_back(basenode); 
    431572 
    432     if(debug) {sgraph.print_node_debug(stderr,"B ",basenode,-1);} // STDOUT!!! 
     573    if(debug) sgraph.print_node_debug(stderr,"B ",basenode,-1); // STDOUT!!! 
     574    if(debug) print_sets(basenode); 
    433575 
    434576    list<int>::iterator cursor=processed; 
    435577    while(++cursor != nodelist.end()) 
    436578    { 
    437       try_connect_dependents(cursor); 
    438       try_connect_heads(cursor); 
     579      if(debug) sgraph.print_node_debug(stderr,"> ",*cursor,-1); 
     580      try_connect_dependents(*cursor); 
     581      try_connect_heads(*cursor); 
    439582      processed=cursor; 
    440583    } 
    441584 
    442585  } 
    443   reverse_links(); 
    444 } 
     586   // reverse_links(); 
     587  update_sets(); 
     588} 
Note: See TracChangeset for help on using the changeset viewer.