stanfordnlp/CoreNLP · error · RuntimeException
Coordination node must have at least 2 children.
Error message
Coordination node must have at least 2 children.
What it means
The CoordinationPattern constructor throws RuntimeException when fewer than 2 child patterns are supplied. A coordination node in a Semgrex pattern represents AND/OR of sub-patterns, which is meaningless with 0 or 1 children.
Solutions
- Ensure at least 2 child SemgrexPatterns exist before constructing a CoordinationPattern
- If only one child, use the child pattern directly instead of wrapping it in a coordination
- Fix the pattern parser/builder so single-branch coordinations are simplified away
Example fix
// before
new CoordinationPattern(isNodeCoord, Collections.singletonList(child), isConj, isRoot);
// after
SemgrexPattern pattern = children.size() == 1 ? children.get(0)
: new CoordinationPattern(isNodeCoord, children, isConj, isRoot); Defensive patterns
Strategy: validation
Validate before calling
if (children == null || children.size() < 2) throw new IllegalArgumentException("CoordinationPattern needs >= 2 children"); Try / catch
try { SemgrexPattern p = new CoordinationPattern(isNodeCoord, children, isConj, isRoot); } catch (RuntimeException e) { fallback = children.size() == 1 ? children.get(0) : null; } Prevention
- Check children size before wrapping in a coordination node
- Simplify single-child coordinations to the child pattern itself
- Add unit tests for pattern builders that assemble coordinations from dynamic input
When it happens
Trigger: Constructing new CoordinationPattern(isNodeCoord, listOfOnePattern, isConj, isRoot) with a list of size 0 or 1 — usually when a parser or builder collects children programmatically and only one alternative was found.
Common situations: Programmatic Semgrex pattern construction from configuration or grammar files where a coordination clause has a single branch; parser bug that drops duplicate children.
Understand the failure class
Background: "Must be a positive integer", "Invalid value", "Unsupported": the invalid-argument-value error family, when a library rejects the value you pass — this error's family across 35 libraries.
Related errors
- Cannot process a single key/value from annotation as it is…
- Child should only be set on a UniqPattern at creation time
- Duplicate attribute found in semgrex expression
- ERROR: Invalid syntax in macro line: ""!
- Error parsing semgrex pattern
AI-assisted analysis of stanfordnlp/CoreNLP@1b7edd19c4 (2026-09-10).
Data as JSON: /api/errors/0b7e5987f36ad759.
Report an issue: GitHub.
Appendix: source
Thrown at src/edu/stanford/nlp/semgraph/semgrex/CoordinationPattern.java:33
private static Redwood.RedwoodChannels log = Redwood.channels(CoordinationPattern.class);
private static final long serialVersionUID = -3122330899634961002L;
private final boolean isConj;
private final boolean isNodeCoord;
/**
* Represents whether this is the root coordination. If so, the
* children have a higher operation priority, as the : operator is
* the lowest precedence possible.
*/
private final boolean isRoot;
private final List<SemgrexPattern> children;
/* if isConj is true, then it is an "AND" ; if it is false, it is an "OR".*/
/* if isNodeCoord is true, then it is a node coordination conj; if it is false, then
* it is a relation coordination conj. */
public CoordinationPattern(boolean isNodeCoord, List<SemgrexPattern> children, boolean isConj, boolean isRoot) {
if (children.size() < 2) {
throw new RuntimeException("Coordination node must have at least 2 children.");
}
this.children = Collections.unmodifiableList(children);
this.isConj = isConj;
this.isNodeCoord = isNodeCoord;
this.isRoot = isRoot;
}
public boolean isNodeCoord() { return isNodeCoord; }
@Override
public void setChild(SemgrexPattern child) {
if (isNodeCoord) {
for (Object c : children) {
if (c instanceof NodePattern)
((NodePattern)c).setChild(child);
}
} else {
View on GitHub (pinned to 1b7edd19c4)