stanfordnlp/CoreNLP · error · IllegalArgumentException
Please specify -model, either SENTIMENT, DVPARSER…
Error message
Please specify -model, either SENTIMENT, DVPARSER, EMBEDDING, COREF, FASTCOREF
What it means
ConvertModels.main parses the -model property into the Model enum; a missing or unrecognized value throws IllegalArgumentException('Please specify -model, either SENTIMENT, DVPARSER, EMBEDDING, COREF, FASTCOREF').
Solutions
- Add -model with one of SENTIMENT, DVPARSER, EMBEDDING, COREF, FASTCOREF
- Correct the spelling of the -model value
- Check the Model enum in ConvertModels.java for the exact accepted names
Example fix
// before ... -stage NEW -input in.gz -output out.gz // after ... -stage NEW -model COREF -input in.gz -output out.gz
Defensive patterns
Strategy: validation
Validate before calling
java.util.Set<String> valid = java.util.Set.of("SENTIMENT","DVPARSER","EMBEDDING","COREF","FASTCOREF");
if (model == null || !valid.contains(model.trim().toUpperCase(java.util.Locale.ROOT))) {
throw new IllegalArgumentException("-model must be one of " + valid);
} Try / catch
try {
ConvertModels.main(args);
} catch (IllegalArgumentException e) {
if (e.getMessage().contains("-model")) {
System.err.println("Accepted -model values: SENTIMENT, DVPARSER, EMBEDDING, COREF, FASTCOREF");
System.exit(2);
}
throw e;
} Prevention
- Keep a constants list of valid -model values in conversion scripts
- Echo the resolved -model value before running the converter
- Update scripts when the Model enum changes
When it happens
Trigger: Running main without -model, or with a value not in {SENTIMENT, DVPARSER, EMBEDDING, COREF, FASTCOREF}.
Common situations: Choosing the wrong converter invocation for the model type, typos like 'COREFMODEL', or following outdated docs that predate some enum entries.
Understand the failure class
Background: Invalid enum value errors: "Unknown type", "Invalid scope", "must be one of" — when a string is not on the library's allowed list — this error's family across 23 libraries.
Related errors
- Please specify -input
- Please specify -output
- Please specify -stage, either OLD or NEW
- Conflicting properties. Multi-word rules file will be…
- is an unsupported OutputStyle
AI-assisted analysis of stanfordnlp/CoreNLP@1b7edd19c4 (2026-09-10).
Data as JSON: /api/errors/17ee334558de4a9f.
Report an issue: GitHub.
Appendix: source
Thrown at src/edu/stanford/nlp/neural/ConvertModels.java:386
* <br>
*
* @author <a href=horatio@gmail.com>John Bauer</a>
*/
public static void main(String[] args) throws IOException, ClassNotFoundException, InstantiationException, NoSuchMethodException {
Properties props = StringUtils.argsToProperties(args);
final Stage stage;
try {
stage = Stage.valueOf(props.getProperty("stage").toUpperCase(Locale.ROOT));
} catch (IllegalArgumentException | NullPointerException e) {
throw new IllegalArgumentException("Please specify -stage, either OLD or NEW");
}
final Model modelType;
try {
modelType = Model.valueOf(props.getProperty("model").toUpperCase(Locale.ROOT));
} catch (IllegalArgumentException | NullPointerException e) {
throw new IllegalArgumentException("Please specify -model, either SENTIMENT, DVPARSER, EMBEDDING, COREF, FASTCOREF");
}
if (!props.containsKey("input")) {
throw new IllegalArgumentException("Please specify -input");
}
if (!props.containsKey("output")) {
throw new IllegalArgumentException("Please specify -output");
}
String inputPath = props.getProperty("input");
String outputPath = props.getProperty("output");
if (modelType == Model.SENTIMENT) {
if (stage == Stage.OLD) {
SentimentModel model = SentimentModel.loadSerialized(inputPath);
ObjectOutputStream out = IOUtils.writeStreamFromString(outputPath);
writeSentiment(model, out);View on GitHub (pinned to 1b7edd19c4)