stanfordnlp/CoreNLP · error · IllegalArgumentException
Invalid metric type for
Error message
Invalid metric type for ${Constants.OPTIMIZE_SIEVES_SCORE_PROP} property: ${optimizeScoreType} What it means
The SieveCoreferenceSystem constructor validates the metric named by the Constants.OPTIMIZE_SIEVES_SCORE_PROP property against the list of valid scorer metric types. If the configured optimizeScoreType (or its metric part) is not a recognized coref scoring metric such as muc, bcub, ceafe or ceafm, it throws an IllegalArgumentException before the system is built.
Solutions
- Set the property to a valid metric name exactly as accepted by the system (muc, bcub, ceafe, ceafm, etc.)
- Check spelling and case against the validMetricType list used in the validation loop
- If using a subscore form, ensure the part after the separator is a valid CorefScorer.SubScoreType enum constant
- Consult the Constants class / CorefScorer source for the exact accepted metric strings in your CoreNLP version
Example fix
// before coref.props: dcoref.optimize.sievesScore = bcube // after coref.props: dcoref.optimize.sievesScore = bcub
Defensive patterns
Strategy: validation
Validate before calling
Set<String> valid = new HashSet<>(Arrays.asList("muc","bcub","ceafe","ceafm"));
String score = props.getProperty("dcoref.optimize.sievesScore");
if (score != null && !valid.contains(score.split("\\.")[0])) {
throw new IllegalArgumentException("Unknown metric: " + score);
} Try / catch
try {
SieveCoreferenceSystem corefSystem = new SieveCoreferenceSystem(props);
} catch (IllegalArgumentException e) {
logger.severe("Bad optimize metric config: " + e.getMessage());
props.setProperty(Constants.OPTIMIZE_SIEVES_SCORE_PROP, "bcub"); // fall back to default
} Prevention
- Copy metric names verbatim from Constants/CorefScorer documentation
- Use a shared constants file for metric names instead of inline strings in props
- Keep a minimal known-good coref properties file as a template
- Diff your props against upstream example configs after upgrading CoreNLP
When it happens
Trigger: Setting the property dcoref.optimize.sievesScore (OPTIMIZE_SIEVES_SCORE_PROP) to a metric string not in the valid set — e.g. a misspelled name, wrong case, or a subscore format like 'pairwise.foo' whose first part doesn't match a valid metric — while sieve optimization (optimizeSieves) is enabled.
Common situations: Typos in a coref tuning properties file (e.g. 'bcube' instead of 'bcub'); copying config between CoreNLP versions where the accepted metric list changed; forgetting that combined SubScoreType values must parse via CorefScorer.SubScoreType.valueOf(parts[1]).
Understand the failure class
Background: "Invalid value" and "allowed values are" config errors: what your library rejected and how to fix it — this error's family across 41 libraries.
Related errors
- Invalid ordering constraint
- Cannot have these two ordering constraints
- Cannot have these two ordering constraints
- No input file specified!
- Invalid sieve name
AI-assisted analysis of stanfordnlp/CoreNLP@1b7edd19c4 (2026-09-10).
Data as JSON: /api/errors/d94c11133d0bfdad.
Report an issue: GitHub.
Appendix: source
Thrown at src/edu/stanford/nlp/dcoref/SieveCoreferenceSystem.java:239
// flag for optimizing sieve ordering
optimizeSieves = Boolean.parseBoolean(props.getProperty(Constants.OPTIMIZE_SIEVES_PROP, "false"));
optimizeScoreType = props.getProperty(Constants.OPTIMIZE_SIEVES_SCORE_PROP, "pairwise.Precision");
// Break down of the optimize score type
String[] validMetricTypes = { "muc", "pairwise", "bcub", "ceafe", "ceafm", "combined" };
String[] parts = optimizeScoreType.split("\\.");
optimizeConllScore = parts.length > 2 && "conll".equalsIgnoreCase(parts[2]);
optimizeMetricType = parts[0];
boolean optimizeMetricTypeOk = false;
for (String validMetricType : validMetricTypes) {
if (validMetricType.equalsIgnoreCase(optimizeMetricType)) {
optimizeMetricTypeOk = true;
break;
}
}
if (!optimizeMetricTypeOk) {
throw new IllegalArgumentException("Invalid metric type for " +
Constants.OPTIMIZE_SIEVES_SCORE_PROP + " property: " + optimizeScoreType);
}
optimizeSubScoreType = CorefScorer.SubScoreType.valueOf(parts[1]);
if (optimizeSieves) {
String keepSieveOrder = props.getProperty(Constants.OPTIMIZE_SIEVES_KEEP_ORDER_PROP);
if (keepSieveOrder != null) {
String[] orderings = keepSieveOrder.split("\\s*,\\s*");
sievesKeepOrder = new ArrayList<>();
String firstSieveConstraint = null;
String lastSieveConstraint = null;
for (String ordering:orderings) {
// Convert ordering constraints from string
Pair<Integer,Integer> p = fromSieveOrderConstraintString(ordering, sieveClassNames);
// Do initial check of sieves order, can only have one where the first is ANY (< 0), and one where second is ANY (< 0)
if (p.first() < 0 && p.second() < 0) {
throw new IllegalArgumentException("Invalid ordering constraint: " + ordering);
} else if (p.first() < 0) {View on GitHub (pinned to 1b7edd19c4)