stanfordnlp/CoreNLP · error · RuntimeException
Creating nondeterminism while inserting arc
Error message
Creating nondeterminism while inserting arc {a} because it already has arc {existing} {checkDeterminism} What it means
TransducerGraph.addArc detects, when checkDeterminism is enabled, that an arc with the same (source, input) pair already exists, meaning inserting the new arc would make the graph nondeterministic. It throws a RuntimeException naming both the new arc and the existing conflicting arc.
Solutions
- Remove or merge the duplicate arc before adding the new one
- Construct the graph with checkDeterminism=false if nondeterminism is acceptable
- Deduplicate input paths before addOnePathToGraph
- Inspect the reported existing arc to understand the conflict
Example fix
// before TransducerGraph g = new TransducerGraph(); g.addArc(source, target, input); // after TransducerGraph g = new TransducerGraph(false); // disable determinism checking if (!g.getArcBySourceAndInput(source, input)) g.addArc(source, target, input);
Defensive patterns
Strategy: validation
Validate before calling
// Guard before adding: refuse a second arc for the same (source,input) pair
if (graphHasArcFor(graph, source, input)) {
throw new IllegalStateException("Arc already exists for " + source + " -> " + input);
}
graph.addArc(source, target, input); Try / catch
try {
graph.addArc(source, target, input);
} catch (RuntimeException e) {
if (e.getMessage() != null && e.getMessage().startsWith("Creating nondeterminism")) {
// merge or skip the conflicting arc
} else throw e;
} Prevention
- Deduplicate training paths before building the graph
- Construct with checkDeterminism=false only when nondeterminism is intended
- Track (source,input) pairs in a set as you add arcs
- Merge alternative continuations under a single arc when possible
When it happens
Trigger: Calling addArc (directly or via addOnePathToGraph / graph-building code) to insert a second arc with the same source node and input label while determinism checking is on.
Common situations: Building a transducer from a corpus where the same prefix admits two different continuations; adding duplicate training paths; combining graphs where edges overlap.
Understand the failure class
Background: "Invalid state transition" errors: "status must be X, actually Y", "already rejected/charging/uninstalled", "cannot ... while running" — what they mean when a library rejects your call — this error's family across 31 libraries.
Related errors
- Unexpected node class
- Cannot manually set the index attribute. If you need a…
- Cannot manually change the sentence index. If you need an…
- Subtree cannot contain cycle leading back to root node!
- Must supply a target label to compute precision and recall…
AI-assisted analysis of stanfordnlp/CoreNLP@1b7edd19c4 (2026-09-10).
Data as JSON: /api/errors/861472fe50fa715d.
Report an issue: GitHub.
Appendix: source
Thrown at src/edu/stanford/nlp/fsm/TransducerGraph.java:253
* @return true if and only if it added Arc a to the graph.
* determinism.
*/
protected boolean addArc(Arc a) {
Object source = a.getSourceNode();
Object target = a.getTargetNode();
Object input = a.getInput();
if (source == null || target == null || input == null) {
return false;
}
// add to data structures
if (arcs.contains(a)) {
return false;
}
// it's new, so add to the rest of the data structures
// add to source and input map
Pair p = Generics.newPair(source, input);
if (arcsBySourceAndInput.containsKey(p) && checkDeterminism) {
throw new RuntimeException("Creating nondeterminism while inserting arc " + a + " because it already has arc " + arcsBySourceAndInput.get(p) + checkDeterminism);
}
arcsBySourceAndInput.put(p, a);
Maps.putIntoValueHashSet(arcsBySource, source, a);
p = Generics.newPair(target, input);
Maps.putIntoValueHashSet(arcsByTargetAndInput, p, a);
Maps.putIntoValueHashSet(arcsByTarget, target, a);
Maps.putIntoValueHashSet(arcsByInput, input, a);
// add to arcs
arcs.add(a);
return true;
}
public boolean removeArc(Arc a) {
Object source = a.getSourceNode();
Object target = a.getTargetNode();
Object input = a.getInput();
// remove from arcs
if (!arcs.remove(a)) {View on GitHub (pinned to 1b7edd19c4)