Changeset 519eaf5 for src


Ignore:
Timestamp:
03/30/14 23:59:06 (10 years ago)
Author:
Tomasz Obrebski <obrebski@…>
Branches:
master
Children:
0a58b3f
Parents:
f924e4b
git-author:
Tomasz Obrebski <obrebski@…> (03/30/14 23:59:06)
git-committer:
Tomasz Obrebski <obrebski@…> (03/30/14 23:59:06)
Message:

Bug fixes: bubbles,props

Location:
src
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • src/compdic/compdic

    rf600a02 r519eaf5  
    181181echo generating cats file ... 
    182182 
    183 cat $1 | cut -d ',' -f 2 | sort -u $2.cats 
     183cat $1 | cut -d ',' -f 2 | sort -u > $2.cats 
  • src/dgc/dgc

    r3b02b04 r519eaf5  
    293293            my $hflagconstr = @{$x->{hflagconstr}} ? "//@{$x->{hflagconstr}}" : ""; 
    294294            my $dflagconstr = @{$x->{dflagconstr}} ? "//@{$x->{dflagconstr}}" : ""; 
    295             my $props = join(map { "\&$_" } $x->{props}); 
    296             print_outin("LINK $head->{cat}$hflagconstr $dep->{cat}$dflagconstr $x->{role}$props",$x, @agrs, @govs); 
     295            my $props = join('',map("\&$_", @{$x->{props}})); 
     296 
     297            print_outin("LINK $head->{cat}$hflagconstr $dep->{cat}$dflagconstr $x->{role} $props",$x, @agrs, @govs); 
    297298        } 
    298299    } 
  • src/dgp/boubble.hh

    r3b02b04 r519eaf5  
    2424{ 
    2525public: 
    26   Boubble(list<Role> u, list<Role> d, LongRel l, int s=-1); 
    27   Boubble(const char* pathstr, const char* l, int s=-1); 
    28   //  Boubble(const Boubble& b) {_src=b._src; _upath=b._upath; _dpath=b._dpath; _rel=b._rel; }; 
    29  
    30   Dir dir(); 
    31   LongRel rel(); 
    32   int src(); 
     26  Boubble() {}; 
     27  Boubble(list<Role> u, list<Role> d, LongRel l, int s=-1, bool r=false); 
     28  Boubble(const char* pathstr, const char* l, int s=-1, bool r=false); 
     29  //Boubble(const Boubble& b) {_src=b._src; _upath=b._upath; _dpath=b._dpath; _rel=b._rel; _reverse=b._reverse; }; 
     30 
     31  Dir dir() const; 
     32  LongRel rel() const; 
     33  int src() const; 
    3334  void src(int s); 
     35  bool reverse() const; 
     36  void reverse(bool b); 
    3437 
    3538  Role next(); 
    3639 
    3740  Boubble* step(Role r, Dir d); 
    38    
    39   bool is_at_target(); 
     41  Boubble* reversed(); 
     42   
     43  bool is_at_target() const; 
    4044 
    4145  bool operator==(Boubble const& b) const; 
     
    5256  list<Role>           _dpath; 
    5357  LongRel              _rel; 
     58  bool                 _reverse; 
    5459 
    5560}; 
     
    5863 
    5964inline 
    60 Boubble::Boubble(list<Role> u, list<Role> d, LongRel l, int s) : _upath(u), _dpath(d), _rel(l), _src(s) {} 
    61  
    62 //---------------------------------------------------------------------------------------------------- 
    63  
    64 inline 
    65 Boubble::Boubble(const char* pathstr, const char* l, int s) 
     65Boubble::Boubble(list<Role> u, list<Role> d, LongRel l, int s, bool r) 
     66  : _upath(u), _dpath(d), _rel(l), _src(s), _reverse(r) {} 
     67 
     68//---------------------------------------------------------------------------------------------------- 
     69 
     70inline 
     71Boubble::Boubble(const char* pathstr, const char* l, int s, bool r) 
    6672{ 
    6773  Dir dir = UP; 
     
    8389  _rel = LongRel(l); 
    8490  _src = s; 
    85 } 
    86  
    87 //---------------------------------------------------------------------------------------------------- 
    88  
    89 inline 
    90 Dir Boubble::dir() 
     91  _reverse = r; 
     92} 
     93 
     94//---------------------------------------------------------------------------------------------------- 
     95 
     96inline 
     97Dir Boubble::dir() const 
    9198{  
    9299  if(!_upath.empty()) 
     
    100107 
    101108inline 
    102 LongRel Boubble::rel() 
     109LongRel Boubble::rel() const 
    103110{ return _rel; } 
    104111 
     
    106113 
    107114inline 
    108 int Boubble::src() 
     115int Boubble::src() const 
    109116{ return _src; } 
    110117 
     
    114121void Boubble::src(int s) 
    115122{ _src=s; } 
     123 
     124//---------------------------------------------------------------------------------------------------- 
     125 
     126inline 
     127bool Boubble::reverse() const 
     128{ return _reverse; } 
     129 
     130//---------------------------------------------------------------------------------------------------- 
     131 
     132inline 
     133void Boubble::reverse(bool b) 
     134{ _reverse=b; } 
    116135 
    117136//---------------------------------------------------------------------------------------------------- 
     
    134153  if(d==UP && !_upath.empty() && _upath.front() == r) 
    135154    { 
    136       Boubble* newboubble = new Boubble(_upath,_dpath,_rel,_src); 
     155      Boubble* newboubble = new Boubble(_upath,_dpath,_rel,_src,_reverse); 
    137156      newboubble->_upath.pop_front(); 
    138157      return newboubble; 
     
    141160  if(d==DOWN && _upath.empty() && !_dpath.empty() && _dpath.front() == r) 
    142161    { 
    143       Boubble* newboubble = new Boubble(_upath,_dpath,_rel,_src); 
     162      Boubble* newboubble = new Boubble(_upath,_dpath,_rel,_src,_reverse); 
    144163      newboubble->_dpath.pop_front(); 
    145164      return newboubble; 
     
    151170 
    152171inline 
    153 bool Boubble::is_at_target() 
     172Boubble* Boubble::reversed() 
     173{ 
     174  Boubble* newboubble = new Boubble(_dpath,_upath,_rel,-1,!_reverse); 
     175  newboubble->_upath.reverse(); 
     176  newboubble->_dpath.reverse(); 
     177  // cout << *this << "-----" << *newboubble << endl; 
     178  return newboubble; 
     179} 
     180 
     181//---------------------------------------------------------------------------------------------------- 
     182 
     183inline 
     184bool Boubble::is_at_target() const 
    154185{ return _upath.empty() && _dpath.empty(); } 
    155186 
     
    208239  o << b._rel.str(); 
    209240  o << "]"; 
     241  if(b.reverse()) o << "!"; 
     242  return o; 
    210243} 
    211244 
  • src/dgp/dgp1.cc

    rb97a556 r519eaf5  
     1#include <iostream> 
     2using namespace std; 
     3 
    14#include "dgp0.hh" 
    25#include "global.hh" 
     
    7982          { 
    8083            ret = *ps; 
    81             // fprintf(stderr,"FIND EXISTING NODE SUCCEEDED BEACAUSE OF LH/LV equality ()\n"); 
     84            fprintf(stderr,"#\tsucceeded because of LH/LV equality ()\n"); 
    8285          } 
    8386        else 
    8487          { 
    85             // fprintf(stderr,"FIND EXISTING NODE FAILED BEACAUSE OF LH/LV inequality\n"); 
     88            fprintf(stderr,"#\tfailed beacause of LH/LV inequality\n"); 
    8689          } 
    8790    } 
     
    158161//==================================================================================================== 
    159162 
    160 int 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); 
     163int create_new_head_node_left(int anc, NodeProp& prop, bitset<MAXNODES>& LH, bitset<MAXNODES>& LD, bitset<MAXNODES>& LV) 
     164{ 
     165  int newheadind = sgraph.clone(anc,prop); 
    165166  nodelist.push_back(newheadind); 
    166   sgraph[newheadind].LH=newheadLH; 
    167   sgraph[newheadind].LD = newheadLD; 
    168   sgraph[newheadind].in_LH=true; 
     167  sgraph[newheadind].LH = LH; 
     168  sgraph[newheadind].LD = LD; 
     169  sgraph[newheadind].in_LH = true; 
    169170  sgraph[newheadind].LV.reset(); 
    170171 
    171   copy_links(h,newheadind); 
     172  copy_links(anc,newheadind); 
    172173  create_reverse_links(newheadind); 
    173174   
    174   if(debug) sgraph.print_node_debug(stderr,"C ",newheadind,h); 
     175  if(debug) sgraph.print_node_debug(stderr,"add new",newheadind,anc); 
    175176  // if(debug) print_sets(newheadind); 
    176177  return newheadind; 
    177178} 
    178179 
    179 int 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); 
     180int create_new_dep_node_left(int anc, NodeProp& prop, bitset<MAXNODES>& LH, bitset<MAXNODES>& LD, bitset<MAXNODES>& LV) 
     181{ 
     182  int newind = sgraph.clone(anc,prop); 
    184183  nodelist.push_back(newind); 
    185184  sgraph[newind].LH.reset(); 
     
    188187  sgraph[newind].LV.reset(); 
    189188 
    190   copy_links(d,newind); 
     189  copy_links(anc,newind); 
    191190  create_reverse_links(newind); 
    192191   
    193   if(debug) sgraph.print_node_debug(stderr,"C ",newind,d); 
     192  if(debug) sgraph.print_node_debug(stderr,"add new",newind,anc); 
    194193  // if(debug) print_sets(newind); 
    195194   
     
    197196} 
    198197 
    199 int 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); 
     198int create_new_head_node_right(int anc, NodeProp& prop, bitset<MAXNODES>& newheadLH, bitset<MAXNODES>& newheadLD, bitset<MAXNODES>& newheadLV) 
     199{ 
     200  int newheadind = sgraph.clone(anc,prop); 
    204201  nodelist.push_back(newheadind); 
    205202  sgraph[newheadind].LH=newheadLH; 
     
    208205  sgraph[newheadind].LV=newheadLV; 
    209206   
    210   copy_links(h,newheadind); 
     207  copy_links(anc,newheadind); 
    211208  create_reverse_links(newheadind); 
    212209 
    213   if(debug) sgraph.print_node_debug(stderr,"C ",newheadind,h); 
     210  if(debug) sgraph.print_node_debug(stderr,"add new",newheadind,anc); 
    214211  // if(debug) print_sets(newheadind); 
    215212   
     
    217214} 
    218215 
    219 int 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); 
     216int create_new_dep_node_right(int anc, NodeProp& prop, bitset<MAXNODES>& LH, bitset<MAXNODES>& LD, bitset<MAXNODES>& LV) 
     217{ 
     218  int newind = sgraph.clone(anc,prop); 
    222219  nodelist.push_back(newind); 
    223220  sgraph[newind].LH=LH; 
     
    226223  sgraph[newind].LV.reset(); 
    227224   
    228   copy_links(d,newind); 
     225  copy_links(anc,newind); 
    229226  create_reverse_links(newind); 
    230227 
    231   if(debug) sgraph.print_node_debug(stderr,"C ",newind,d); 
     228  if(debug) sgraph.print_node_debug(stderr,"ADD NEW",newind,anc); 
    232229  // if(debug) print_sets(newind); 
    233230   
     
    253250    bitset<MAXNODES> newheadLV = sgraph[d].LV; 
    254251    bitset<MAXNODES> newheadLD = sgraph[h].LD; 
    255  
    256     //    vector<int> newedge; 
    257252 
    258253    newheadind = find_existing_node(sgraph[h].mnode, newheadprop, newheadLH, newheadLV); 
     
    302297  if(sgraph[d].saturated()) sgraph[newheadind].LD |= sgraph[d].LD; 
    303298   
    304   if(debug) sgraph.print_arc(stderr,newheadind,d,l.role,0); 
    305   if(debug) sgraph.print_node_debug(stderr,"U ",newheadind,h); 
     299  if(debug) sgraph.print_arc(stderr,"new link",newheadind,d,l.role,0); 
     300  if(debug) sgraph.print_node_debug(stderr,"update",newheadind,h); 
    306301  // if(debug) print_sets(newheadind); 
    307   if(debug) sgraph.print_node_debug(stderr,"U ",newdepind,d); 
     302  if(debug) sgraph.print_node_debug(stderr,"update",newdepind,d); 
    308303  // if(debug) print_sets(newdepind); 
    309304} 
     
    380375  if(sgraph[newheadind].saturated()) sgraph[newdepind].LH |= sgraph[newheadind].LH; 
    381376 
    382   if(debug) sgraph.print_arc(stderr,newheadind,newdepind,l.role,1); 
    383   if(debug) sgraph.print_node_debug(stderr,"U ",newheadind,h); 
    384   if(debug) sgraph.print_node_debug(stderr,"U ",newdepind,d); 
    385    
     377  if(debug) sgraph.print_arc(stderr,"new link",newheadind,newdepind,l.role,1); 
     378  if(debug) sgraph.print_node_debug(stderr,"update",newheadind,h); 
     379  if(debug) sgraph.print_node_debug(stderr,"update",newdepind,d); 
     380   
     381} 
     382 
     383//==================================================================================================== 
     384 
     385// bool check_meeting_boubles(list<Boubble*>& hboubbles, list<Boubble*>& dboubbles) 
     386// { 
     387//   bool hremove=false;             // czy usun±æ ostatnio sprawdzany b±bel 
     388//   bool dremove=false;             // czy usun±æ ostatnio sprawdzany b±bel 
     389 
     390//   for(list<Boubble*>::iterator hb = hboubbles.begin(); hb != hboubbles.end(); hb = hremove ? hboubbles.erase(hb) : ++hb ) 
     391//     { 
     392//       hremove=false; 
     393//       for(list<Boubble*>::iterator db = dboubbles.begin(); db != dboubbles.end(); db = dremove ? dboubbles.erase(db) : ++db ) 
     394//      { 
     395//        dremove=false; 
     396//        if( (*hb)->rel()==(*db)->rel() && (*hb)->dir()==DOWN && (*db)->dir()==UP && (*hb)->reverse()!=(*db)->reverse() ) 
     397//          { 
     398//            int srcnode,dstnode; 
     399//            if( (*hb)->reverse()==false ) 
     400//              srcnode = (*hb)->src(), dstnode = (*db)->src(); 
     401//            else 
     402//              srcnode = (*db)->src(), dstnode = (*hb)->src(); 
     403//            if( grammar.check_longrel(sgraph.cat(srcnode), sgraph.cat(dstnode), (*hb)->rel()) ) 
     404//              { 
     405//                hremove=dremove=true; 
     406//                if(debug) fprintf(stderr,"BOUBBLES MET!!!\n"); 
     407//              } 
     408//            else 
     409//              { 
     410//                if(debug) fprintf(stderr,"BOUBBLES' MEETING FAILED!!!\n"); 
     411//                return false; 
     412//              } 
     413//          } 
     414//      } 
     415//     } 
     416//   return true; 
     417// } 
     418 
     419//==================================================================================================== 
     420 
     421bool check_meeting_boubles(list<Boubble*>& boubbles) 
     422{ 
     423  bool hremove=false;             // czy usun±æ ostatnio sprawdzany b±bel 
     424  bool dremove=false;             // czy usun±æ ostatnio sprawdzany b±bel 
     425 
     426  for(list<Boubble*>::iterator hb = boubbles.begin(); hb != boubbles.end(); hb = hremove ? boubbles.erase(hb) : ++hb ) 
     427    { 
     428      cout << endl << "hb:" << **hb ; 
     429      hremove=false; 
     430      for(list<Boubble*>::iterator db = hb; db != boubbles.end(); db = dremove ? boubbles.erase(db) : ++db ) 
     431        { 
     432          cout << " db:" << **db; 
     433          dremove=false; 
     434          if( (*hb)->rel()==(*db)->rel() && (*hb)->reverse()!=(*db)->reverse() ) 
     435            { 
     436              cout << "Z"; 
     437              int srcnode,dstnode; 
     438              if( (*hb)->reverse()==false ) 
     439                srcnode = (*hb)->src(), dstnode = (*db)->src(); 
     440              else 
     441                srcnode = (*db)->src(), dstnode = (*hb)->src(); 
     442              if( grammar.check_longrel(sgraph.cat(srcnode), sgraph.cat(dstnode), (*hb)->rel()) ) 
     443                { 
     444                  cout << " REMOVE "; 
     445                  hremove=dremove=true; 
     446                  if(debug) fprintf(stderr,"BOUBBLES MET!!!\n"); 
     447                } 
     448              else 
     449                { 
     450                  cout << " FAIL "; 
     451                  if(debug) fprintf(stderr,"BOUBBLES' MEETING FAILED!!!\n"); 
     452                  return false; 
     453                } 
     454            } 
     455        } 
     456    } 
     457  return true; 
    386458} 
    387459 
     
    393465bool check_boubbles_at_target(list<Boubble*>& boubbles, int node) 
    394466{ 
    395   list<Boubble*>::iterator last; // ostatnio sprawdzany b±bel 
    396467  bool remove=false;             // czy usun±æ ostatnio sprawdzany b±bel 
    397468 
     
    399470    if( (*b)->is_at_target() ) 
    400471      if( grammar.check_longrel(sgraph.cat((*b)->src()), sgraph.cat(node), (*b)->rel()) ) 
    401         remove=true; 
     472        { 
     473          cout << endl << "REMOVE ChBatT " << **b << endl; 
     474          remove=true; 
     475        } 
    402476      else 
    403477        return false; 
     
    412486void try_connect_dependents(int j) 
    413487{ 
    414   // for(list<int>::iterator i(j); i!=nodelist.begin(); --i) 
    415   //   if(sgraph.visible(*i,*j) && sgraph.saturated(*i)) 
    416488  LViterator lvi(sgraph,j); 
    417489  int i; 
    418490  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!!! 
    424       list<const Link*>::iterator ri = ji_links.begin(); 
    425       if(ri == ji_links.end()) { if(debug) fprintf(stderr,"no roles\n"); } 
     491    { 
     492      //if(debug) sgraph.print_node_debug(stderr,"D-CUR>",i,-1); 
     493 
     494      if(sgraph.saturated(i)) 
     495        { 
     496          if(debug) {fprintf(stderr,"%d <--",i); } 
     497           
     498          list<const Link*> ji_links = grammar.connectable2( sgraph.cat(j), sgraph.cat(i), sgraph[j].prop.flags, sgraph[i].prop.flags); // ref do Roles!!! 
     499          list<const Link*>::iterator ri = ji_links.begin(); 
     500          if(ri == ji_links.end()) { if(debug) fprintf(stderr,"     no roles\n"); } 
     501          else 
     502            { 
     503              for(; ri != ji_links.end(); ++ri ) 
     504                { 
     505                  if(debug) fprintf(stderr,"     %s",(*ri)->role.str()); 
     506                  if(!grammar.check_constr2(sgraph[j].prop,sgraph[i].prop,0,**ri )) 
     507                    { if(debug) fprintf(stderr," ...constraints failed\n"); } 
     508                  else 
     509                    { 
     510                      list<Boubble*> new_head_boubbles = collect_head_boubbles(j,i,(*ri)->role); 
     511                      list<Boubble*> new_dep_boubbles = collect_dep_boubbles(j,i,(*ri)->role); 
     512                      if( check_meeting_boubles(new_head_boubbles) && 
     513                          check_meeting_boubles(new_dep_boubbles) && 
     514                          check_boubbles_at_target(new_head_boubbles,j) && 
     515                          check_boubbles_at_target(new_dep_boubbles,i) ) 
     516                        { 
     517                          if(debug) fprintf(stderr," ...SUCCESS!\n"); 
     518                          connect_left( j, i, **ri, new_head_boubbles, new_dep_boubbles); 
     519                        } 
     520                      else 
     521                        { if(debug) fprintf(stderr," ...boubbles failed\n"); } 
     522                    } 
     523                } 
     524            } 
     525        } 
    426526      else 
    427         { 
    428           for(; ri != ji_links.end(); ++ri ) 
    429             if(!grammar.check_constr2(sgraph[j].prop,sgraph[i].prop,0,**ri )) 
    430               { if(debug) fprintf(stderr,"constraints failed\n"); } 
    431             else 
    432               { 
    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); 
    435                  
    436                 if( !(check_boubbles_at_target(new_head_boubbles,j) && check_boubbles_at_target(new_dep_boubbles,i)) ) 
    437                   { if(debug) fprintf(stderr,"boubbles failed\n"); } 
    438                 else 
    439                   { 
    440                     if(debug) fprintf(stderr,"success\n"); 
    441                     connect_left( j, i, **ri, new_head_boubbles, new_dep_boubbles); 
    442                   } 
    443               } 
    444         } 
    445     } 
    446 } 
    447  
    448  
     527          if(debug) {fprintf(stderr,"%d <--     unsaturated\n",i); } 
     528    } 
     529   
     530} 
    449531//---------------------------------------------------------------------------------------------------- 
    450532 
    451533void try_connect_heads(int j) 
    452534{ 
    453   // for(list<int>::iterator i(j); i!=nodelist.begin(); --i) 
    454   //   if(sgraph.visible(*i,*j) && sgraph.saturated(*j)) 
    455  
    456535  LViterator lvi(sgraph,j); 
    457536  int i; 
    458537  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 ); 
    464       list<const Link*>::iterator ri = ij_links.begin(); 
    465       if(ri == ij_links.end()) { if(debug) fprintf(stderr,"no roles\n"); } 
     538    { 
     539      // if(debug) sgraph.print_node_debug(stderr,"H-CUR> ",i,-1); 
     540      if(sgraph.saturated(j)) 
     541        { 
     542          if(debug) fprintf(stderr, "%d -->",i); 
     543           
     544          list<const Link*> ij_links = grammar.connectable2( sgraph.cat(i), sgraph.cat(j), sgraph[i].prop.flags, sgraph[j].prop.flags ); 
     545          list<const Link*>::iterator ri = ij_links.begin(); 
     546          if(ri == ij_links.end()) { if(debug) fprintf(stderr,"     no roles\n"); } 
     547          else 
     548            { 
     549              for(; ri != ij_links.end(); ++ri ) 
     550                { 
     551                  if(debug) fprintf(stderr,"     %s",(*ri)->role.str()); 
     552                  if( !grammar.check_constr2( sgraph[i].prop, sgraph[j].prop, 1, **ri ) ) 
     553                    { if(debug) fprintf(stderr," ...constraints failed\n"); } 
     554                  else 
     555                    { 
     556                      list<Boubble*> new_head_boubbles = collect_head_boubbles(i,j,(*ri)->role); 
     557                      list<Boubble*> new_dep_boubbles = collect_dep_boubbles(i,j,(*ri)->role); 
     558                       
     559                      if( check_meeting_boubles(new_head_boubbles) && 
     560                          check_meeting_boubles(new_dep_boubbles) && 
     561                          check_boubbles_at_target(new_head_boubbles,i) && 
     562                          check_boubbles_at_target(new_dep_boubbles,j) ) 
     563                        { 
     564                          if(debug) fprintf(stderr," ...SUCCESS!\n"); 
     565                          connect_right( i, j, **ri, new_head_boubbles, new_dep_boubbles ); 
     566                        } 
     567                      else 
     568                        { if(debug) fprintf(stderr," ...bubbles failed\n",i); } 
     569                    } 
     570                } 
     571            } 
     572        } 
    466573      else 
    467         { 
    468           for(; ri != ij_links.end(); ++ri ) 
    469             if( !grammar.check_constr2( sgraph[i].prop, sgraph[j].prop, 1, **ri ) ) 
    470               { if(debug) fprintf(stderr,"constraints failed\n"); } 
    471             else 
    472               { 
    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); 
    475                  
    476                 if( !(check_boubbles_at_target(new_head_boubbles,i) && check_boubbles_at_target(new_dep_boubbles,j)) ) 
    477                   { if(debug) fprintf(stderr,"boubbles failed\n"); } 
    478                 else 
    479                   { 
    480                     if(debug) fprintf(stderr,"success\n"); 
    481                     connect_right( i, j, **ri, new_head_boubbles, new_dep_boubbles ); 
    482                   } 
    483               } 
    484         } 
     574          if(debug) {fprintf(stderr,"%d <--     unsaturated\n",j); } 
    485575    } 
    486576} 
     
    571661    nodelist.push_back(basenode); 
    572662 
    573     if(debug) sgraph.print_node_debug(stderr,"B ",basenode,-1); // STDOUT!!! 
    574     if(debug) print_sets(basenode); 
     663    if(debug) sgraph.print_node_debug(stderr,"add base",basenode,-1); // STDOUT!!! 
     664    // if(debug) print_sets(basenode); 
    575665 
    576666    list<int>::iterator cursor=processed; 
    577667    while(++cursor != nodelist.end()) 
    578668    { 
    579       if(debug) sgraph.print_node_debug(stderr,"> ",*cursor,-1); 
     669      if(debug) sgraph.print_node_debug(stderr,"MAIN-CUR> ",*cursor,-1); 
    580670      try_connect_dependents(*cursor); 
    581671      try_connect_heads(*cursor); 
  • src/dgp/grammar.hh

    ra15e59b r519eaf5  
    118118  vector< vector< LongRels > > longrel;  //[Cat][Cat] 
    119119 
    120   list< Boubble* >              boubbles; 
     120  list< Boubble* >             boubbles; 
    121121   
    122122  vector< vector< list<Boubble*> > >   uptrigger;//[Cat][Role] 
     
    126126  void add_type(const char* s); 
    127127  void add_flag(const char* s)                   { Flag::add(s); } 
    128   void add_long(const char* l, const char* p)    { LongRel::add(l); boubbles.push_back( new Boubble(p,l) ); } 
     128  void add_long(const char* l, const char* p)    { LongRel::add(l); boubbles.push_back( new Boubble(p,l) ); 
     129                                                                    boubbles.push_back( (new Boubble(p,l))->reversed() ); } 
    129130  void add_triggers(Cat h, Cat d, LongRel l); 
    130131 
  • src/dgp/sgraph.cc

    rb97a556 r519eaf5  
    2929 
    3030  newnode.edge.push_back(lastnodeind()); 
     31 
     32  newnode.edge_contains_self = true ; 
    3133 
    3234  return lastnodeind(); 
     
    8587//---------------------------------------------------------------------------------------------------- 
    8688 
    87 void SGraph::print_arc(FILE* f, int head, int dep, Role role, int dir) // 0 - left, 1 - right 
     89void SGraph::print_arc(FILE* f, const char* msg, int head, int dep, Role role, int dir) // 0 - left, 1 - right 
    8890{ 
    8991  if(dir==0) 
    90     fprintf(f,"#A  %s:%d <-- %d\n", role.str(), dep, head); 
     92    fprintf(f,"%s  %s:%d <-- %d\n", msg, role.str(), dep, head); 
    9193  else 
    92     fprintf(f,"#A  %s:%d --> %d\n", role.str(), head, dep); 
     94    fprintf(f,"%s  %s:%d --> %d\n", msg, role.str(), head, dep); 
    9395} 
    9496 
     
    113115    for(vector<Arc>::iterator h=node.heads.begin(); h!=node.heads.end(); ++h) 
    114116    { 
    115       // if(cont) buf+=sprintf(buf,","); else cont=true; 
    116117      buf+=sprintf(buf,"(++%s:%d)",h->role.str(),h->dst); 
    117       // buf+=sprintf(buf,"++%s-%d(%d~%d)",h->role.str(),h->dst,h->headanc,h->depanc); 
    118       // buf+=sprintf(buf,"(<-%s-%d)",h->role.str(),h->dst); 
    119118    } 
    120119 
     
    122121    for(vector<Arc>::iterator d=node.deps.begin(); d!=node.deps.end(); ++d) 
    123122    { 
    124       //      if(! nodes[d->dst].saturated()) continue; // NIE DRUKUJ NIENASYCONYCH PODRZEDNIKOW 
    125       // if(cont) buf+=sprintf(buf,","); else cont=true; 
    126123      buf+=sprintf(buf,"(--%s:%d)",d->role.str(),d->dst); 
    127       // buf+=sprintf(buf,"--%s-%d(%d~%d)",d->role.str(),d->dst,d->headanc,d->depanc); 
    128       // buf+=sprintf(buf,"(-%s->%d)",d->role.str(),d->dst); 
    129124    } 
    130125   
     
    177172{ 
    178173  char *buf0 = buf; 
    179   buf+=sprintf(buf,"#%s",pref); 
    180  
    181   buf+=sprintf(buf,"%-16s",form(n)); 
    182  
     174  buf+=sprintf(buf,"%-10s",pref); 
     175  buf+=sprintf(buf,"%d.%s",n,form(n)); 
     176  buf+=sprintf(buf,";"); 
     177  buf+=sprintf(buf,"%s ",cat(n).str()); 
     178  while(buf-buf0<40) buf+=sprintf(buf," "); 
    183179  buf+=sprint_node(buf,n,anc,HEADS|DEPS|SETS|CONSTRAINTS); 
    184180   
    185   buf+=sprintf(buf,"/"); 
    186   for(vector<int>::iterator e = nodes[n].edge.begin(); e != nodes[n].edge.end(); e++ ) 
    187     buf += sprintf(buf,"%d ", *e); 
     181  // buf+=sprintf(buf,"/"); 
     182  // for(vector<int>::iterator e = nodes[n].edge.begin(); e != nodes[n].edge.end(); e++ ) 
     183  //   buf += sprintf(buf,"%d ", *e); 
    188184 
    189185  buf+=sprintf(buf,"\n"); 
  • src/dgp/sgraph.hh

    r3b02b04 r519eaf5  
    228228  int print_node_debug(FILE* f, const char* pref, int n, int anc); 
    229229 
    230   void print_arc(FILE* f, int left, int right, Role role, int dir); // 0 - left, 1 - right 
     230  void print_arc(FILE* f, const char* msg, int left, int right, Role role, int dir); // 0 - left, 1 - right 
    231231 
    232232  //private: 
     
    327327       
    328328    } 
    329   // if(!strict) 
    330   //   { 
    331   //     push_ld(n); 
    332   //              push_ln(n); 
    333   //   } 
    334329} 
    335330 
Note: See TracChangeset for help on using the changeset viewer.