stanfordnlp/CoreNLP · error · RuntimeException
none of flags.useXXXChar2 are on
Error message
none of flags.useXXXChar2 are on
What it means
TagAffixDetector requires at least one char2 corpus flag (useCTBChar2 or usePKChar2) when useChPos-style POS detection is active. If none of the flags.useXXXChar2 flags are on, no dictionary paths can be chosen and RuntimeException('none of flags.useXXXChar2 are on') is thrown.
Solutions
- Set useCTBChar2=true or usePKChar2=true alongside useChPos in the properties
- Remove useChPos if you don't intend to use character-based POS features
- Verify the properties file actually enables exactly one supported char2 flag
Example fix
// before (Properties) useChPos=true // after (Properties) useChPos=true usePKChar2=true
Defensive patterns
Strategy: validation
Validate before calling
Properties p = /* props */;
boolean anyChar2 = Stream.of("useASBCChar2","useCTBChar2","useHKChar2","useMSRChar2","usePKChar2")
.anyMatch(k -> Boolean.parseBoolean(p.getProperty(k, "false")));
if (Boolean.parseBoolean(p.getProperty("useChPos","false")) && !anyChar2) {
p.setProperty("useCTBChar2", "true");
} Try / catch
try {
new TagAffixDetector(flags);
} catch (RuntimeException e) {
if (e.getMessage().contains("useXXXChar2")) {
flags.useCTBChar2 = true;
new TagAffixDetector(flags);
} else throw e;
} Prevention
- Pair useChPos with useCTBChar2 or usePKChar2 in every properties file
- Comment properties templates so users know char2 flags are prerequisites
- Add config validation before constructing the detector
When it happens
Trigger: Constructing TagAffixDetector with useChPos=true (or the outer condition true) but useCTBChar2=false and usePKChar2=false (and other char2 flags off).
Common situations: Setting useChPos without setting the corpus char2 flag; properties files where the corpus flag was renamed or removed; users enabling POS-char features on an unsupported configuration.
Understand the failure class
Background: "--flag is required" and "must specify" CLI errors: how missing-required-flag validation works and how to fix it — this error's family across 20 libraries.
Related errors
- only support settings for CTB and PK now.
- only support settings for CTB and PK now.
- only support settings for CTB and PK now.
- only support settings for CTB and PKU now.
- Both parse.model and parse.executable properties must be…
AI-assisted analysis of stanfordnlp/CoreNLP@1b7edd19c4 (2026-09-10).
Data as JSON: /api/errors/a88315351ba4f974.
Report an issue: GitHub.
Appendix: source
Thrown at src/edu/stanford/nlp/wordseg/TagAffixDetector.java:43
if ( ! corporaDict.isEmpty() && ! corporaDict.endsWith("/")) {
corporaDict = corporaDict + '/';
}
String ccPath;
String adPath;
if (flags.useChPos || flags.useCTBChar2 || flags.usePKChar2) {
// if we're using POS information, override the ccPath
// For now we only have list for CTB and PK
if (flags.useASBCChar2 || flags.useHKChar2 || flags.useMSRChar2) {
throw new RuntimeException("only support settings for CTB and PK now.");
} else if (flags.useCTBChar2) {
ccPath = corporaDict+"dict/character_list";
adPath = corporaDict+"dict/in.ctb";
} else if (flags.usePKChar2) {
ccPath = corporaDict+"dict/pos_open/character_list.pku.utf8";
adPath = corporaDict+"dict/in.pk";
} else {
throw new RuntimeException("none of flags.useXXXChar2 are on");
}
} else {
ccPath = corporaDict+"dict/pos_close/char.ctb.list";
adPath = corporaDict+"dict/in.ctb";
}
if (VERBOSE) {
logger.info("TagAffixDetector: useChPos=" + flags.useChPos +
" | useCTBChar2=" + flags.useCTBChar2 + " | usePKChar2=" + flags.usePKChar2);
logger.info("TagAffixDetector: building TagAffixDetector from " + ccPath + " and " + adPath);
}
cc = new CorpusChar(ccPath);
aD = new AffixDictionary(adPath);
}
String checkDic(String t2, String c2 ) {
if(cc.getTag(t2, c2).equals("1"))
return "1";
return "0";View on GitHub (pinned to 1b7edd19c4)