Changeset 854bece
- Timestamp:
- 01/12/15 19:07:44 (10 years ago)
- 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)
- Location:
- src/dgp
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
src/dgp/dgp1.cc
racbabee r854bece 173 173 int newd = find_existing_node(sgraph[d].mnode, new_dep_prop, new_dep_edge); 174 174 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 } 176 179 177 180 Edge new_head_edge(sgraph[newd].edge,newd); … … 201 204 202 205 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); 204 208 if( newh < 0 ) 205 209 { 206 210 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; 208 212 } 209 213 210 214 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 } 214 221 215 222 … … 299 306 int i; 300 307 while((i=lvi.next()) >= 0) 301 if(sgraph.saturated(i))308 if(sgraph.saturated(i) && ! sgraph.has_head(i)) 302 309 { 303 310 if(debug) {fprintf(stderr,"\t%d <-- %d",i,j); } -
src/dgp/sgraph.cc
racbabee r854bece 180 180 181 181 buf+=sprintf(buf,"/"); 182 buf+=sprintf(buf,nodes[n].prop.visible_as_neighbour ? "o" : "x"); 182 183 if(nodes[n].edge.self()) 183 184 buf += sprintf(buf,"* "); -
src/dgp/sgraph.hh
racbabee r854bece 55 55 bool init_attached; 56 56 bool fin_attached; 57 bool visible_as_neighbour; 58 bool has_head; 57 59 58 60 FlagSet flags; … … 72 74 if(init_attached != p.init_attached) return false; 73 75 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; 74 78 75 79 list<Boubble*>::const_iterator b,b1; … … 106 110 void NodeProp::copy(const NodeProp& p) 107 111 { 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; 114 120 for(list<Boubble*>::const_iterator b = p.boubbles.begin(); b!=p.boubbles.end(); b++) 115 121 boubbles.push_back(new Boubble(**b)); … … 127 133 init_attached=false; 128 134 fin_attached=false; 135 visible_as_neighbour=true; 136 has_head=false; 129 137 clear_boubbles(); 130 138 } … … 161 169 struct SNode 162 170 { 163 164 SNode() { visible_as_neighbour = true; } 171 SNode() { prop.clear(); } 165 172 166 173 int mnode; 167 174 168 175 NodeProp prop; 169 170 176 Edge edge; 171 bool visible_as_neighbour;172 177 173 178 bitset<MAXNODES> LV; … … 179 184 vector<Arc> deps; 180 185 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 183 189 184 190 // void edge_clear() { edge.clear(); edge_contains_self=false;} … … 191 197 }; 192 198 193 //----------------------------------------------------------------------------------------------------194 inline195 void SNode::clear()196 { prop.clear(), LV.reset(), LD.reset(), LH.reset(), heads.clear(), deps.clear(); }197 //----------------------------------------------------------------------------------------------------198 inline199 bool SNode::saturated()200 { return prop.required.none(); }201 202 199 //==================================================================================================== 203 200 // SGraph CLASS … … 219 216 void update_left(int headind, int depind); 220 217 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; } 223 221 224 222 Cat cat(int i) const { return mgraph[nodes[i].mnode].cat; } … … 251 249 int sprint_node_debug(char* buf, const char* pref, int n, int anc); 252 250 }; 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 }267 251 268 252 //---------------------------------------------------------------------------------------------------- … … 413 397 vector<int>& spredecessors = mgraph[*mp].snodes; 414 398 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) 416 400 { 417 401 push(wayup,*sp);
Note: See TracChangeset
for help on using the changeset viewer.