stanfordnlp/CoreNLP · error · RuntimeException
only support settings for CTB and PK now.
Error message
only support settings for CTB and PK now.
What it means
Identical logic to ChineseSegmenterFeatureFactory: Gale2007ChineseSegmenterFeatureFactory.featuresCpC selects a tagset only for CTB or PK char-based features and throws RuntimeException otherwise. The Gale 2007 variant enforces the same corpus-specific tag inventory requirement.
Solutions
- Enable useCTBChar2=true or usePKChar2=true in the flags/properties
- Load the correct properties file for the corpus being segmented
- Patch the feature factory to extend tagset selection to additional corpora
Example fix
// before SeqClassifierFlags flags = new SeqClassifierFlags(); // after SeqClassifierFlags flags = new SeqClassifierFlags(); flags.usePKChar2 = true;
Defensive patterns
Strategy: validation
Validate before calling
SeqClassifierFlags f = new SeqClassifierFlags();
if (!f.useCTBChar2 && !f.usePKChar2) {
f.useCTBChar2 = true; // default to CTB before extraction
} Try / catch
try {
clf = new CRFClassifier<>(galeFlags);
} catch (RuntimeException e) {
if (e.getMessage().contains("CTB and PK")) {
galeFlags.usePKChar2 = true;
clf = new CRFClassifier<>(galeFlags);
} else throw e;
} Prevention
- Set useCTBChar2/usePKChar2 immediately after creating SeqClassifierFlags
- Reuse the shipped Sighan properties files as templates
- Document required flags wherever the Gale2007 factory is instantiated
When it happens
Trigger: Using the Gale2007 segmenter feature factory with neither useCTBChar2 nor usePKChar2 set, while the feature extractor needs a tagset (featuresCpC invoked via getCliqueFeatures).
Common situations: Configuring the Gale2007 segmenter for ASBC/HK/MSR data; running tests with default flags that omit the char2 corpus options; programmatic SeqClassifierFlags construction missing the flag.
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
- only support settings for CTB and PK now.
- none of flags.useXXXChar2 are on
- only support settings for CTB and PK now.
- only support settings for CTB and PKU now.
- after W derivative, index() != x.length()
AI-assisted analysis of stanfordnlp/CoreNLP@1b7edd19c4 (2026-09-10).
Data as JSON: /api/errors/f6df1993bafd5aa5.
Report an issue: GitHub.
Appendix: source
Thrown at src/edu/stanford/nlp/wordseg/Gale2007ChineseSegmenterFeatureFactory.java:527
(CTB/ASBC/HK/PK/MSR) POS information of each characters.
If a character falls into some function categories,
it is very likely there is a boundary.
A lot of Chinese function words belong to single characters.
This feature is also good for numbers and punctuations.
DE* are grouped into DE.
*/
if (flags.useCTBChar2 || flags.useASBCChar2 || flags.useHKChar2
|| flags.usePKChar2 || flags.useMSRChar2) {
String[] tagsets;
// the "useChPos" now only works for CTB and PK
if (flags.useChPos) {
if(flags.useCTBChar2) {
tagsets = new String[]{"AD", "AS", "BA", "CC", "CD", "CS", "DE", "DT", "ETC", "IJ", "JJ", "LB", "LC", "M", "NN", "NR", "NT", "OD", "P", "PN", "PU", "SB", "SP", "VA", "VC", "VE", "VV" };
} else if (flags.usePKChar2) {
//tagsets = new String[]{"r", "j", "t", "a", "nz", "l", "vn", "i", "m", "ns", "nr", "v", "n", "q", "Ng", "b", "d", "nt"};
tagsets = new String[]{"2","3","4"};
} else {
throw new RuntimeException("only support settings for CTB and PK now.");
}
} else {
//logger.info("Using Derived features");
tagsets = new String[]{"2","3","4"};
}
if (taDetector == null) {
createTADetector();
}
for (String tag : tagsets) {
features.add(taDetector.checkDic(tag+"p", charp) + taDetector.checkDic(tag+"i", charp) + taDetector.checkDic(tag+"s", charc)+ taDetector.checkInDic(charp)+taDetector.checkInDic(charc)+ tag+ "prep-sufc" );
//features.add("|ctbchar2");
}
}
/*
In error analysis, we found English words and numbers are often separated.
Rule 1: isNumber feature: check if the current and previous char is a number.View on GitHub (pinned to 1b7edd19c4)