{"record":{"id":"a88315351ba4f974","repo":"stanfordnlp/CoreNLP","slug":"none-of-flags-usexxxchar2-are-on","errorCode":null,"errorMessage":"none of flags.useXXXChar2 are on","messagePattern":"none of flags\\.useXXXChar2 are on","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"src/edu/stanford/nlp/wordseg/TagAffixDetector.java","lineNumber":43,"sourceCode":"    if ( ! corporaDict.isEmpty() && ! corporaDict.endsWith(\"/\")) {\n      corporaDict = corporaDict + '/';\n    }\n\n    String ccPath;\n    String adPath;\n    if (flags.useChPos || flags.useCTBChar2 || flags.usePKChar2) {\n      // if we're using POS information, override the ccPath\n      // For now we only have list for CTB and PK\n      if (flags.useASBCChar2 || flags.useHKChar2 || flags.useMSRChar2) {\n        throw new RuntimeException(\"only support settings for CTB and PK now.\");\n      } else if (flags.useCTBChar2) {\n        ccPath = corporaDict+\"dict/character_list\";\n        adPath = corporaDict+\"dict/in.ctb\";\n      } else if (flags.usePKChar2) {\n        ccPath = corporaDict+\"dict/pos_open/character_list.pku.utf8\";\n        adPath = corporaDict+\"dict/in.pk\";\n      } else {\n        throw new RuntimeException(\"none of flags.useXXXChar2 are on\");\n      }\n    } else {\n      ccPath = corporaDict+\"dict/pos_close/char.ctb.list\";\n      adPath = corporaDict+\"dict/in.ctb\";\n    }\n    if (VERBOSE) {\n      logger.info(\"TagAffixDetector: useChPos=\" + flags.useChPos +\n              \" | useCTBChar2=\" + flags.useCTBChar2 + \" | usePKChar2=\" + flags.usePKChar2);\n      logger.info(\"TagAffixDetector: building TagAffixDetector from \" + ccPath + \" and \" + adPath);\n    }\n    cc = new CorpusChar(ccPath);\n    aD = new AffixDictionary(adPath);\n  }\n\n  String checkDic(String t2, String c2 ) {\n    if(cc.getTag(t2, c2).equals(\"1\"))\n      return \"1\";\n    return \"0\";","sourceCodeStart":25,"sourceCodeEnd":61,"githubUrl":"https://github.com/stanfordnlp/CoreNLP/blob/1b7edd19c4d0d7b1f13a2591425b9b60a0b1af7a/src/edu/stanford/nlp/wordseg/TagAffixDetector.java#L25-L61","documentation":"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.","triggerScenarios":"Constructing TagAffixDetector with useChPos=true (or the outer condition true) but useCTBChar2=false and usePKChar2=false (and other char2 flags off).","commonSituations":"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.","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"],"exampleFix":"// before (Properties)\nuseChPos=true\n// after (Properties)\nuseChPos=true\nusePKChar2=true","handlingStrategy":"validation","validationCode":"Properties p = /* props */;\nboolean anyChar2 = Stream.of(\"useASBCChar2\",\"useCTBChar2\",\"useHKChar2\",\"useMSRChar2\",\"usePKChar2\")\n  .anyMatch(k -> Boolean.parseBoolean(p.getProperty(k, \"false\")));\nif (Boolean.parseBoolean(p.getProperty(\"useChPos\",\"false\")) && !anyChar2) {\n  p.setProperty(\"useCTBChar2\", \"true\");\n}","typeGuard":null,"tryCatchPattern":"try {\n  new TagAffixDetector(flags);\n} catch (RuntimeException e) {\n  if (e.getMessage().contains(\"useXXXChar2\")) {\n    flags.useCTBChar2 = true;\n    new TagAffixDetector(flags);\n  } else throw e;\n}","preventionTips":["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"],"tags":["java","chinese-segmentation","configuration","missing-flag"],"backgroundTag":"missing-required-flag","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"}