summaryrefslogtreecommitdiff
path: root/chain/src/item/default
diff options
context:
space:
mode:
Diffstat (limited to 'chain/src/item/default')
-rw-r--r--chain/src/item/default/splone.rs22
1 files changed, 20 insertions, 2 deletions
diff --git a/chain/src/item/default/splone.rs b/chain/src/item/default/splone.rs
index 9da156a..f540000 100644
--- a/chain/src/item/default/splone.rs
+++ b/chain/src/item/default/splone.rs
@@ -555,6 +555,8 @@ impl DefaultForest<ForestLabel<GrammarLabel>> {
}
if node_label.clone_index().is_some() {
+ let node_children = self.children_of(node)?;
+
let mut parents = self.parents_of(node)?;
#[cfg(debug_assertions)]
@@ -562,13 +564,29 @@ impl DefaultForest<ForestLabel<GrammarLabel>> {
let packed = parents.next().unwrap().node();
- for clone in self.children_of(packed)? {
+ 'clone_loop: for clone in self.children_of(packed)? {
let degree = self.degree(clone)?;
if degree == 0 {
return Ok(Some(clone));
}
+ if degree <= edge_index {
+ continue;
+ }
+
+ if clone != node {
+ for (clone_child, child) in self
+ .children_of(clone)?
+ .zip(node_children.clone())
+ .take(edge_index + 1)
+ {
+ if clone_child != child {
+ continue 'clone_loop;
+ }
+ }
+ }
+
if degree >= edge_index + 2 {
let index_child = self.nth_child(clone, edge_index + 1)?;
@@ -706,7 +724,7 @@ impl DefaultForest<ForestLabel<GrammarLabel>> {
// we add no child to parent.edge()-th child here.
let cloned = self.clone_node(parent.node(), parent.edge(), false)?;
- dbg!(cloned, parent, new_child);
+ // dbg!(cloned, parent, new_child);
let mut builder = PLGBuilderMut::from_graph_mut(&mut self.graph);