stanfordnlp/CoreNLP · error · RuntimeException
Arc input is in unexpected format:
Error message
Arc input is in unexpected format:
What it means
When converting compacted transducer graphs back into grammar rules, binary-rule arc inputs encode direction with '<'/'[' (left) or '>'/']' (right). If an arc's input string has neither marker, its orientation cannot be determined, so convertGraphsToGrammar throws with the offending arc.
Solutions
- Regenerate the graphs through the standard compaction path so arc inputs carry the '<'/'>' (or '['/']') marker.
- Check for version mismatch between the code that wrote the graphs and the code reading them.
- Disable grammar compaction for grammars produced outside the standard pipeline.
Defensive patterns
Strategy: try-catch
Validate before calling
for (Arc<String> arc : graph.getArcs()) {
String in = arc.getInput();
if (!(in.contains("<") || in.contains(">") || in.contains("[") || in.contains("]")))
throw new IllegalArgumentException("Bad arc input: " + arc);
} Try / catch
try { grammar = compactor.compact(graphs); } catch (RuntimeException e) { log.error(e.getMessage()); throw e; } Prevention
- Build transducer graphs only via the standard compaction code path
- Avoid mixing graph files across parser versions
When it happens
Trigger: Compacting a grammar whose transducer graph contains arcs not created by the standard binary-rule encoding — e.g. graphs loaded from custom code or corrupted graph data.
Common situations: Using saveGraphs/graph-restore features across versions where arc input conventions changed, or feeding custom TransducerGraphs into the compactor.
Understand the failure class
Background: "Invalid ... format", "must be in format X", "does not look like a ..." — invalid argument format errors across CLI tools and libraries — this error's family across 17 libraries.
Related errors
- Grammar format error. Expected bar in state name:
- can't have null topcat
- expecting BEGIN block; got end of file.
- Cannot find matching labelled span for
- Error extracting labelled spans for column :
AI-assisted analysis of stanfordnlp/CoreNLP@1b7edd19c4 (2026-09-10).
Data as JSON: /api/errors/73fbdc0730e82579.
Report an issue: GitHub.
Appendix: source
Thrown at src/edu/stanford/nlp/parser/lexparser/GrammarCompactor.java:329
UnaryRule ur = new UnaryRule(newStateIndex.addToIndex(target), newStateIndex.addToIndex(inputString), smartNegate(output));
unaryRules.add(ur);
} else if (inputString.equals(END) || inputString.equals(EPSILON)) {
// make a UnaryRule
UnaryRule ur = new UnaryRule(newStateIndex.addToIndex(target), newStateIndex.addToIndex(source), smartNegate(output));
unaryRules.add(ur);
} else {
// make a BinaryRule
// figure out whether the input was generated on the left or right
int length = inputString.length();
char leftOrRight = inputString.charAt(length - 1);
inputString = inputString.substring(0, length - 1);
BinaryRule br;
if (leftOrRight == '<' || leftOrRight == '[') {
br = new BinaryRule(newStateIndex.addToIndex(target), newStateIndex.addToIndex(inputString), newStateIndex.addToIndex(source), smartNegate(output));
} else if (leftOrRight == '>' || leftOrRight == ']') {
br = new BinaryRule(newStateIndex.addToIndex(target), newStateIndex.addToIndex(source), newStateIndex.addToIndex(inputString), smartNegate(output));
} else {
throw new RuntimeException("Arc input is in unexpected format: " + arc);
}
binaryRules.add(br);
}
}
}
// by now, the unaryRules and binaryRules Sets have old untouched and new rules with scores
ClassicCounter<String> symbolCounter = new ClassicCounter<>();
if (outputType == RAW_COUNTS) {
// now we take the sets of rules and turn them into grammars
// the scores of the rules we are given are actually counts
// so we count parent symbol occurrences
for (UnaryRule rule : unaryRules) {
symbolCounter.incrementCount(newStateIndex.get(rule.parent), rule.score);
}
for (BinaryRule rule : binaryRules) {
symbolCounter.incrementCount(newStateIndex.get(rule.parent), rule.score);
}
}View on GitHub (pinned to 1b7edd19c4)