stanfordnlp/CoreNLP · error · IllegalArgumentException
is an unsupported OutputStyle
Error message
is an unsupported OutputStyle
What it means
PlainTextDocumentReaderAndWriter.printAnswers selects a printing routine based on the configured OutputStyle. The switch's default branch throws IllegalArgumentException if the outputStyle constant is not one of the handled styles — normally only reachable if a new OutputStyle constant was added without updating printAnswers, or the style was set programmatically to an unexpected value.
Solutions
- Set outputStyle to one of the supported constants handled by printAnswers (e.g. via OutputStyle.fromShortName with a valid short name).
- If you added a new OutputStyle enum constant, add a case for it in printAnswers.
- Check for library version mixing (jar on classpath differing from compiled-against version) and align versions.
Example fix
// before
props.setProperty("outputStyle", "fancy");
// after
props.setProperty("outputStyle", "tsv"); Defensive patterns
Strategy: validation
Validate before calling
OutputStyle style = PlainTextDocumentReaderAndWriter.OutputStyle.fromShortName(props.getProperty("outputStyle"));
// ensure it is one of the styles handled by printAnswers before tagging Try / catch
try {
writer.printAnswers(l, out);
} catch (IllegalArgumentException e) {
if (e.getMessage() != null && e.getMessage().endsWith("is an unsupported OutputStyle")) {
log.error("Unsupported OutputStyle: " + e.getMessage());
} else throw e;
} Prevention
- Only set outputStyle via OutputStyle.fromShortName with registered short names.
- If adding enum constants, update printAnswers' switch in the same change.
- Keep Stanford NLP jar versions consistent on the classpath.
When it happens
Trigger: Calling printAnswers / getAnswers / runTaggerSGML with a writer whose outputStyle is an OutputStyle constant not covered by the switch (e.g. a newly added enum value or one set via reflection/setOutputStyle).
Common situations: Extending or upgrading Stanford NLP where a custom/new OutputStyle was introduced but printAnswers was not updated; wiring an OutputStyle object directly instead of using fromShortName-parsed values.
Related errors
- is not an OutputStyle
- : Entry doesn't have overwriteable types , but entry type…
- : Ignoring duplicate entry: , old type = , new type =
- : Replacing duplicate entry (higher priority): old= , new=
- Arabic does not support feature type: " + feat.toString()
AI-assisted analysis of stanfordnlp/CoreNLP@1b7edd19c4 (2026-09-10).
Data as JSON: /api/errors/c3b800f34aaf5a06.
Report an issue: GitHub.
Appendix: source
Thrown at src/edu/stanford/nlp/sequences/PlainTextDocumentReaderAndWriter.java:256
printAnswersTokenizedInlineXML(l, out);
}
break;
case TSV:
if (preserveSpacing) {
printAnswersAsIsTextTsv(l, out);
} else {
printAnswersTokenizedTextTsv(l, out);
}
break;
case TABBED:
if (preserveSpacing) {
printAnswersAsIsTextTabbed(l, out);
} else {
printAnswersTokenizedTextTabbed(l, out);
}
break;
default:
throw new IllegalArgumentException(outputStyle +
" is an unsupported OutputStyle");
}
}
private static <IN extends CoreMap> void printAnswersTokenizedText(List<IN> l, PrintWriter out) {
for (IN wi : l) {
out.print(StringUtils.getNotNullString(wi.get(CoreAnnotations.TextAnnotation.class)));
out.print('/');
out.print(StringUtils.getNotNullString(wi.get(CoreAnnotations.AnswerAnnotation.class)));
out.print(' ');
}
out.println(); // put a single newline at the end [added 20091024].
}
private static <IN extends CoreMap> void printAnswersAsIsText(List<IN> l, PrintWriter out) {
for (IN wi : l) {
out.print(StringUtils.getNotNullString(wi.get(CoreAnnotations.BeforeAnnotation.class)));
out.print(StringUtils.getNotNullString(wi.get(CoreAnnotations.TextAnnotation.class)));View on GitHub (pinned to 1b7edd19c4)