stanfordnlp/CoreNLP · error · IllegalArgumentException
Not a valid NewlineIsSentenceBreak name
Error message
Not a valid NewlineIsSentenceBreak name: '${name}' (should be one of 'always', 'never', 'two') What it means
WordToSentenceProcessor.stringToNewlineIsSentenceBreak converts the option string into the NewlineIsSentenceBreak enum. Only 'always', 'never', or anything containing 'two' is accepted; any other (or null/empty) name throws IllegalArgumentException.
Solutions
- Set the option to exactly one of: always, never, two (or any string containing 'two', e.g. twoConsecutive)
- Lowercase/normalize the value before passing it in
- Remove the property to use the default (never) if newline breaks are not desired
- Validate config values before building the processor
Example fix
// before
props.setProperty("ssplit.newlineIsSentenceBreak", "true");
// after
props.setProperty("ssplit.newlineIsSentenceBreak", "always"); Defensive patterns
Strategy: validation
Validate before calling
String v = opt == null ? null : opt.trim().toLowerCase();
if (v != null && !v.equals("always") && !v.equals("never") && !v.contains("two"))
throw new IllegalArgumentException("newlineIsSentenceBreak must be always|never|two"); Try / catch
try {
processor = new WordToSentenceProcessor<>(props);
} catch (IllegalArgumentException e) {
props.setProperty("ssplit.newlineIsSentenceBreak", "never");
processor = new WordToSentenceProcessor<>(props);
} Prevention
- Use only the literal values always, never, two
- Normalize case/whitespace on option values before passing properties
- Do not reuse boolean-style values (true/false) for this enum option
When it happens
Trigger: Setting the ssplit.newlineIsSentenceBreak (or related) option to an unrecognized value such as 'true', 'yes', 'Always', or a misspelling when constructing WordToSentenceProcessor from properties.
Common situations: Typos in CoreNLP properties (ssplit.newlineIsSentenceBreak=true instead of always); case sensitivity mistakes; values copied from other tokenizers' docs.
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
- Unknown timeAnnotator
- Unknown LogPriorType:
- is not a legal LogPrior.
- Unsupported subScoreType
- Unsupported inference type: " + flags.crfType
AI-assisted analysis of stanfordnlp/CoreNLP@1b7edd19c4 (2026-09-10).
Data as JSON: /api/errors/2c6c6460cae2a6ee.
Report an issue: GitHub.
Appendix: source
Thrown at src/edu/stanford/nlp/process/WordToSentenceProcessor.java:147
private final Pattern sentenceRegionEndPattern;
private final NewlineIsSentenceBreak newlineIsSentenceBreak;
private final boolean isOneSentence;
/** Whether to output empty sentences. */
private final boolean allowEmptySentences;
public static NewlineIsSentenceBreak stringToNewlineIsSentenceBreak(String name) {
if ("always".equals(name)) {
return NewlineIsSentenceBreak.ALWAYS;
} else if ("never".equals(name)) {
return NewlineIsSentenceBreak.NEVER;
} else if (name != null && name.contains("two")) {
return NewlineIsSentenceBreak.TWO_CONSECUTIVE;
} else {
throw new IllegalArgumentException("Not a valid NewlineIsSentenceBreak name: '" + name + "' (should be one of 'always', 'never', 'two')");
}
}
/** This is a sort of hacked in other way to end sentences.
* Tokens with the ForcedSentenceEndAnnotation set to true
* will also end a sentence.
*/
@SuppressWarnings("OverlyStrongTypeCast")
private static boolean isForcedEndToken(Object o) {
if (o instanceof CoreMap) {
Boolean forcedEndValue =
((CoreMap)o).get(CoreAnnotations.ForcedSentenceEndAnnotation.class);
String originalText = ((CoreMap) o).get(CoreAnnotations.OriginalTextAnnotation.class);
return (forcedEndValue != null && forcedEndValue) ||
(originalText != null && originalText.equals("\u2029"));
} else {
return false;
}View on GitHub (pinned to 1b7edd19c4)