Skip to content

Commit 120dbba

Browse files
committed
Allow for MergeNodes where multiple nodes pointing out of the group, but to the same node
1 parent 1b7edd1 commit 120dbba

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/edu/stanford/nlp/semgraph/semgrex/ssurgeon/MergeNodes.java

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,9 +95,15 @@ public boolean evaluate(SemanticGraph sg, SemgrexMatcher sm) {
9595
}
9696
// parent is outside this subtree
9797
// therefore, we can use this word as the head of the subtree
98-
// but if we already have a head, give up instead
9998
if (head != null) {
100-
return false;
99+
if (parents.equals(sg.getParents(head))) {
100+
// if the parents of the other node are the same, we can keep going
101+
// since the nodes are about to merge anyway
102+
break;
103+
} else {
104+
// if we already have a head with different parents, give up instead
105+
return false;
106+
}
101107
}
102108
head = candidate;
103109
break;

0 commit comments

Comments
 (0)