{"record":{"id":"f6df1993bafd5aa5","repo":"stanfordnlp/CoreNLP","slug":"only-support-settings-for-ctb-and-pk-now-f6df19","errorCode":null,"errorMessage":"only support settings for CTB and PK now.","messagePattern":"only support settings for CTB and PK now\\.","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"src/edu/stanford/nlp/wordseg/Gale2007ChineseSegmenterFeatureFactory.java","lineNumber":527,"sourceCode":"      (CTB/ASBC/HK/PK/MSR) POS information of each characters.\n      If a character falls into some function categories,\n      it is very likely there is a boundary.\n      A lot of Chinese function words belong to single characters.\n      This feature is also good for numbers and punctuations.\n      DE* are grouped into DE.\n    */\n    if (flags.useCTBChar2 || flags.useASBCChar2 || flags.useHKChar2\n        || flags.usePKChar2 || flags.useMSRChar2) {\n      String[] tagsets;\n      // the \"useChPos\" now only works for CTB and PK\n      if (flags.useChPos) {\n        if(flags.useCTBChar2) {\n          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\" };\n        } else if (flags.usePKChar2) {\n          //tagsets = new String[]{\"r\", \"j\", \"t\", \"a\", \"nz\", \"l\", \"vn\", \"i\", \"m\", \"ns\", \"nr\", \"v\", \"n\", \"q\", \"Ng\", \"b\", \"d\", \"nt\"};\n          tagsets = new String[]{\"2\",\"3\",\"4\"};\n        } else {\n          throw new RuntimeException(\"only support settings for CTB and PK now.\");\n        }\n      } else {\n        //logger.info(\"Using Derived features\");\n        tagsets = new String[]{\"2\",\"3\",\"4\"};\n      }\n\n      if (taDetector == null) {\n        createTADetector();\n      }\n      for (String tag : tagsets) {\n\tfeatures.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\" );\n        //features.add(\"|ctbchar2\");\n      }\n    }\n\n    /*\n      In error analysis, we found English words and numbers are often separated.\n      Rule 1: isNumber feature: check if the current and previous char is a number.","sourceCodeStart":509,"sourceCodeEnd":545,"githubUrl":"https://github.com/stanfordnlp/CoreNLP/blob/1b7edd19c4d0d7b1f13a2591425b9b60a0b1af7a/src/edu/stanford/nlp/wordseg/Gale2007ChineseSegmenterFeatureFactory.java#L509-L545","documentation":"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.","triggerScenarios":"Using the Gale2007 segmenter feature factory with neither useCTBChar2 nor usePKChar2 set, while the feature extractor needs a tagset (featuresCpC invoked via getCliqueFeatures).","commonSituations":"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.","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"],"exampleFix":"// before\nSeqClassifierFlags flags = new SeqClassifierFlags();\n// after\nSeqClassifierFlags flags = new SeqClassifierFlags();\nflags.usePKChar2 = true;","handlingStrategy":"validation","validationCode":"SeqClassifierFlags f = new SeqClassifierFlags();\nif (!f.useCTBChar2 && !f.usePKChar2) {\n  f.useCTBChar2 = true; // default to CTB before extraction\n}","typeGuard":null,"tryCatchPattern":"try {\n  clf = new CRFClassifier<>(galeFlags);\n} catch (RuntimeException e) {\n  if (e.getMessage().contains(\"CTB and PK\")) {\n    galeFlags.usePKChar2 = true;\n    clf = new CRFClassifier<>(galeFlags);\n  } else throw e;\n}","preventionTips":["Set useCTBChar2/usePKChar2 immediately after creating SeqClassifierFlags","Reuse the shipped Sighan properties files as templates","Document required flags wherever the Gale2007 factory is instantiated"],"tags":["java","chinese-segmentation","crf","configuration"],"backgroundTag":"invalid-config-value","analyzedSha":"1b7edd19c4d0d7b1f13a2591425b9b60a0b1af7a","analyzedAt":"2026-09-10T02:24:07.274Z","contentChangedAt":"2026-09-10T02:24:07.274Z","schemaVersion":2},"datasetVersion":"2026-09-17T15:17:12.973Z"}