stanfordnlp/CoreNLP · error · IllegalArgumentException
Unknown monotonicity: " + mono
Error message
Unknown monotonicity: " + mono
What it means
Operator.monoFromString converts a string like "additive" or "anti-multiplicative" into a Monotonicity/MonotonicityType pair. When the input string does not match any of the seven recognized monotonicity names, the switch falls through to default and throws IllegalArgumentException. This guards against typos or unsupported monotonicity vocabulary in quantifier/operator definitions.
Solutions
- Check the input string against the accepted spellings in the switch in Operator.monoFromString and fix the typo or casing
- Normalize input (trim/lowercase) before calling monoFromString
- Parse user/config input with a fallback to Monotonicity.NONMONOTONE when unknown
Example fix
// before
Monotonicity m = Operator.monoFromString("antiadditive").first;
// after
String mono = input.trim().toLowerCase(); // "anti-additive"
Monotonicity m = Operator.monoFromString(mono).first; Defensive patterns
Strategy: validation
Validate before calling
Set<String> VALID = Set.of("monotone","antitone","nonmonotone","additive","multiplicative","additive-multiplicative","anti-additive","anti-multiplicative","anti-additive-multiplicative");
if (mono == null || !VALID.contains(mono.trim().toLowerCase())) throw new IllegalArgumentException("bad mono: " + mono); Try / catch
try { Pair<Monotonicity,MonotonicityType> p = Operator.monoFromString(s); } catch (IllegalArgumentException e) { /* default to NONMONOTONE */ } Prevention
- Normalize and lowercase input strings before parsing
- Keep quantifier specs aligned with the accepted vocabulary in Operator
When it happens
Trigger: Calling Operator.monoFromString() with any string other than exactly one of: "monotone", "antitone", "nonmonotone" (implied by the switch), "additive", "multiplicative", "additive-multiplicative", "anti-additive", "anti-multiplicative", or "anti-additive-multiplicative" — e.g. passing "antiadditive" or "none".
Common situations: Typo in a custom quantifier specification; parsing an operator gloss/annotation file with unexpected monotonicity strings; case-sensitivity issues since matching is exact lowercase.
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
- attempt to get word when sentence and lattice are null!
- Attempted to parse empty/null tag
- Bad data format:
- Bad number put into wordToNumber. Word is: \"" + input +…
- Bad number put into wordToNumber. Word is: \"" + curPart +…
AI-assisted analysis of stanfordnlp/CoreNLP@1b7edd19c4 (2026-09-10).
Data as JSON: /api/errors/cf56136aa683b3bc.
Report an issue: GitHub.
Appendix: source
Thrown at src/edu/stanford/nlp/naturalli/Operator.java:153
this.subjType = subj.second;
this.objMono = Monotonicity.INVALID;
this.objType = MonotonicityType.NONE;
}
public boolean isUnary() {
return objMono == Monotonicity.INVALID;
}
public static Pair<Monotonicity, MonotonicityType> monoFromString(String mono) {
switch (mono) {
case "nonmonotone": return Pair.makePair(Monotonicity.NONMONOTONE, MonotonicityType.NONE);
case "additive": return Pair.makePair(Monotonicity.MONOTONE, MonotonicityType.ADDITIVE);
case "multiplicative": return Pair.makePair(Monotonicity.MONOTONE, MonotonicityType.MULTIPLICATIVE);
case "additive-multiplicative": return Pair.makePair(Monotonicity.MONOTONE, MonotonicityType.BOTH);
case "anti-additive": return Pair.makePair(Monotonicity.ANTITONE, MonotonicityType.ADDITIVE);
case "anti-multiplicative": return Pair.makePair(Monotonicity.ANTITONE, MonotonicityType.MULTIPLICATIVE);
case "anti-additive-multiplicative": return Pair.makePair(Monotonicity.ANTITONE, MonotonicityType.BOTH);
default: throw new IllegalArgumentException("Unknown monotonicity: " + mono);
}
}
public static String monotonicitySignature(Monotonicity mono, MonotonicityType type) {
switch (mono) {
case MONOTONE:
switch (type) {
case NONE: return "nonmonotone";
case ADDITIVE: return "additive";
case MULTIPLICATIVE: return "multiplicative";
case BOTH: return "additive-multiplicative";
}
case ANTITONE:
switch (type) {
case NONE: return "nonmonotone";
case ADDITIVE: return "anti-additive";
case MULTIPLICATIVE: return "anti-multiplicative";
case BOTH: return "anti-additive-multiplicative";View on GitHub (pinned to 1b7edd19c4)