Changeset 854bece for src/dgp


Ignore:
Timestamp:
01/12/15 19:07:44 (10 years ago)
Author:
Tomasz Obrebski <obrebski@…>
Branches:
master
Children:
c03f8a5
Parents:
acbabee
git-author:
Tomasz Obrebski <obrebski@…> (01/12/15 19:07:44)
git-committer:
Tomasz Obrebski <obrebski@…> (01/12/15 19:07:44)
Message:

has_head prop added, visible_as_neighbour moved to prop

Location:
src/dgp
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • src/dgp/dgp1.cc

    racbabee r854bece  
    173173  int newd = find_existing_node(sgraph[d].mnode, new_dep_prop, new_dep_edge); 
    174174  if( newd < 0  ) 
    175     newd = create_new_node(d,new_dep_prop,new_dep_edge); 
     175    { 
     176      newd = create_new_node(d,new_dep_prop,new_dep_edge); 
     177      sgraph[newd].prop.has_head = true; 
     178    } 
    176179   
    177180  Edge new_head_edge(sgraph[newd].edge,newd); 
     
    201204 
    202205  Edge new_head_edge(sgraph[h].edge); 
    203   int newh = find_existing_node(sgraph[h].mnode, new_head_prop, new_head_edge); 
     206  int newh = -1; 
     207  if(!new_head_prop.forbidden[l.role]) newh = find_existing_node(sgraph[h].mnode, new_head_prop, new_head_edge); 
    204208  if( newh < 0 ) 
    205209      { 
    206210        newh = create_new_node(h,new_head_prop,new_head_edge); 
    207         sgraph[newh].visible_as_neighbour = false; 
     211        sgraph[newh].prop.visible_as_neighbour = false; 
    208212      } 
    209213 
    210214  Edge new_dep_edge; 
    211   int newd = find_existing_node(sgraph[d].mnode, new_dep_prop, new_dep_edge); 
    212   if( newd < 0) 
    213     newd = create_new_node(d,new_dep_prop,new_dep_edge); 
     215  int newd = d; 
     216  if( ! (new_dep_edge == sgraph[d].edge) || ! (old_dep_prop == new_dep_prop) ) 
     217    { 
     218      newd = create_new_node(d,new_dep_prop,new_dep_edge); 
     219      sgraph[newd].prop.has_head = true; 
     220    } 
    214221 
    215222 
     
    299306  int i; 
    300307  while((i=lvi.next()) >= 0) 
    301       if(sgraph.saturated(i)) 
     308    if(sgraph.saturated(i) && ! sgraph.has_head(i)) 
    302309        { 
    303310          if(debug) {fprintf(stderr,"\t%d <-- %d",i,j); } 
  • src/dgp/sgraph.cc

    racbabee r854bece  
    180180   
    181181  buf+=sprintf(buf,"/"); 
     182  buf+=sprintf(buf,nodes[n].prop.visible_as_neighbour ? "o" : "x"); 
    182183  if(nodes[n].edge.self()) 
    183184    buf += sprintf(buf,"* "); 
  • src/dgp/sgraph.hh

    racbabee r854bece  
    5555  bool init_attached; 
    5656  bool fin_attached; 
     57  bool visible_as_neighbour; 
     58  bool has_head; 
    5759   
    5860  FlagSet flags; 
     
    7274  if(init_attached != p.init_attached) return false; 
    7375  if(fin_attached != p.fin_attached) return false; 
     76  if(visible_as_neighbour != p.visible_as_neighbour) return false; 
     77  if(has_head != p.has_head) return false; 
    7478 
    7579  list<Boubble*>::const_iterator b,b1; 
     
    106110void NodeProp::copy(const NodeProp& p) 
    107111{ 
    108   required=p.required; 
    109   forbidden=p.forbidden; 
    110   attached=p.attached; 
    111   flags=p.flags; 
    112   init_attached=p.init_attached; 
    113   fin_attached=p.fin_attached; 
     112  required = p.required; 
     113  forbidden = p.forbidden; 
     114  attached = p.attached; 
     115  flags = p.flags; 
     116  init_attached = p.init_attached; 
     117  fin_attached = p.fin_attached; 
     118  visible_as_neighbour = p.visible_as_neighbour; 
     119  has_head = p.has_head; 
    114120  for(list<Boubble*>::const_iterator b = p.boubbles.begin(); b!=p.boubbles.end(); b++) 
    115121    boubbles.push_back(new Boubble(**b)); 
     
    127133  init_attached=false; 
    128134  fin_attached=false; 
     135  visible_as_neighbour=true; 
     136  has_head=false; 
    129137  clear_boubbles(); 
    130138} 
     
    161169struct SNode 
    162170{ 
    163    
    164   SNode() { visible_as_neighbour = true; } 
     171  SNode() { prop.clear(); } 
    165172 
    166173  int mnode; 
    167174 
    168175  NodeProp prop; 
    169  
    170176  Edge edge; 
    171   bool visible_as_neighbour; 
    172177 
    173178  bitset<MAXNODES> LV; 
     
    179184  vector<Arc> deps; 
    180185 
    181   void clear(); 
    182   bool saturated(); 
     186  void clear() { prop.clear(), LV.reset(), LD.reset(), LH.reset(), heads.clear(), deps.clear(); } 
     187  bool saturated() { return prop.required.none(); } 
     188   
    183189 
    184190  // void edge_clear()               { edge.clear(); edge_contains_self=false;} 
     
    191197}; 
    192198 
    193 //---------------------------------------------------------------------------------------------------- 
    194 inline 
    195 void SNode::clear() 
    196 { prop.clear(), LV.reset(), LD.reset(), LH.reset(), heads.clear(), deps.clear(); } 
    197 //---------------------------------------------------------------------------------------------------- 
    198 inline 
    199 bool SNode::saturated() 
    200 { return prop.required.none(); } 
    201  
    202199//==================================================================================================== 
    203200// SGraph CLASS 
     
    219216  void update_left(int headind, int depind); 
    220217  void update_right(int headind, int depind); 
    221   bool visible(int left, int right); 
    222   bool saturated(int node); 
     218  bool visible(int left, int right) { return nodes[right].LV[left]; } 
     219  bool saturated(int node) { return nodes[node].saturated(); } 
     220  bool has_head(int node) { return nodes[node].prop.has_head; } 
    223221 
    224222  Cat  cat(int i) const { return mgraph[nodes[i].mnode].cat; }     
     
    251249  int sprint_node_debug(char* buf, const char* pref, int n, int anc); 
    252250}; 
    253  
    254 //---------------------------------------------------------------------------------------------------- 
    255  
    256 inline bool SGraph::visible(int left, int right) 
    257 { 
    258   return nodes[right].LV[left]; 
    259 } 
    260  
    261 //---------------------------------------------------------------------------------------------------- 
    262  
    263 inline bool SGraph::saturated(int node) 
    264 { 
    265   return nodes[node].saturated(); 
    266 } 
    267251 
    268252//---------------------------------------------------------------------------------------------------- 
     
    413397      vector<int>& spredecessors = mgraph[*mp].snodes; 
    414398      for(vector<int>::iterator sp = spredecessors.begin(); sp != spredecessors.end(); ++sp ) 
    415         if(sgraph[*sp].visible_as_neighbour || !strict) 
     399        if(sgraph[*sp].prop.visible_as_neighbour || !strict) 
    416400          { 
    417401            push(wayup,*sp); 
Note: See TracChangeset for help on using the changeset viewer.