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

  1. Remove or merge the duplicate arc before adding the new one
  2. Construct the graph with checkDeterminism=false if nondeterminism is acceptable
  3. Deduplicate input paths before addOnePathToGraph
  4. 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

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


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)