stanfordnlp/CoreNLP · error · IllegalArgumentException
Unsupported format + format
Error message
Unsupported format + format
What it means
SemanticGraph.toString(SemanticGraphOutputFormat) throws IllegalArgumentException when the format enum has no handler in the switch, i.e. an output format was added to the enum but not supported here (only READABLE, LIST, RECURSIVE are handled).
Solutions
- Use one of the supported formats: SemanticGraphOutputFormat.READABLE, LIST, or RECURSIVE
- Check the SemanticGraphOutputFormat enum in your version and map unsupported values to a supported renderer (e.g. toXML if available)
- Pin the parser version and re-check the switch when upgrading
Example fix
// before String s = sg.toString(SemanticGraphOutputFormat.XML); // after String s = sg.toString(SemanticGraphOutputFormat.READABLE);
Defensive patterns
Strategy: validation
Validate before calling
if (format == SemanticGraphOutputFormat.READABLE || format == SemanticGraphOutputFormat.LIST || format == SemanticGraphOutputFormat.RECURSIVE) { String s = sg.toString(format); } Type guard
boolean supported = format == SemanticGraphOutputFormat.READABLE || format == SemanticGraphOutputFormat.LIST || format == SemanticGraphOutputFormat.RECURSIVE;
Try / catch
try { s = sg.toString(format); } catch (IllegalArgumentException e) { s = sg.toString(SemanticGraphOutputFormat.READABLE); } Prevention
- Restrict format choices to the enum members handled in your CoreNLP version
- Re-check switch coverage when upgrading parser versions
- Default to READABLE for logging
When it happens
Trigger: Calling sg.toString(format) with a SemanticGraphOutputFormat value outside the handled set, typically XML or any newly introduced format constant.
Common situations: Upgrading the Stanford parser to a version with new enum members while custom code switches over formats; passing XML expecting a String output when the API only supports the three formats.
Related errors
- ERROR: unknown dependency type
- Arabic does not support feature type: " + feat.toString()
- Unknown side
- Unknown mode + mode
- No sentiment value for integer:
AI-assisted analysis of stanfordnlp/CoreNLP@1b7edd19c4 (2026-09-10).
Data as JSON: /api/errors/debc2164644d2f9c.
Report an issue: GitHub.
Appendix: source
Thrown at src/edu/stanford/nlp/semgraph/SemanticGraph.java:1492
*
* </dl>
*
* @param format A {@code String} specifying the desired format
* @return A {@code String} representation of the typed dependencies in
* this {@code GrammaticalStructure}
*/
public String toString(OutputFormat format) {
switch(format) {
case XML:
return toXMLString();
case READABLE:
return toReadableString();
case LIST:
return toList();
case RECURSIVE:
return toString();
default:
throw new IllegalArgumentException("Unsupported format " + format);
}
}
/**
* Returns a String representation of this graph as a list of typed
* dependencies, as exemplified by the following:
*
* <pre>
* nsubj(died-6, Sam-3)
* tmod(died-6, today-9)
* </pre>
*
* @return a {@code String} representation of this set of typed dependencies
*/
public String toList() {
StringBuilder buf = new StringBuilder();
for (IndexedWord root : getRoots()) {
buf.append("root(ROOT-0, ");View on GitHub (pinned to 1b7edd19c4)