{"record":{"id":"80308ee6d3c21cb1","repo":"stanfordnlp/CoreNLP","slug":"only-support-settings-for-ctb-and-pku-now","errorCode":null,"errorMessage":"only support settings for CTB and PKU now.","messagePattern":"only support settings for CTB and PKU now\\.","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"src/edu/stanford/nlp/wordseg/NonDict2.java","lineNumber":42,"sourceCode":"  public final String corporaDict;\n  private final CorpusDictionary cd;\n\n  private static Redwood.RedwoodChannels logger = Redwood.channels(NonDict2.class);\n\n  public NonDict2(SeqClassifierFlags flags) {\n    if (flags.sighanCorporaDict != null) {\n      corporaDict = flags.sighanCorporaDict; // use the same flag for Sighan 2005,\n      // but our list is extracted from ctb\n    } else {\n      corporaDict = DEFAULT_HOME;\n    }\n\n    String path;\n    if (flags.dict2name != null && !flags.dict2name.equals(\"\")) {\n      path = corporaDict + \"/dict/\" + flags.dict2name;\n      logger.info(\"INFO: dict2name specified | building NonDict2 from \"+path);\n    } else if (flags.useAs || flags.useHk || flags.useMsr) {\n      throw new RuntimeException(\"only support settings for CTB and PKU now.\");\n    } else if ( flags.usePk ) {\n      path = corporaDict+\"/dict/pku.non\";\n      logger.info(\"INFO: flags.usePk=true | building NonDict2 from \"+path);\n    } else { // CTB\n      path = corporaDict+\"/dict/ctb.non\";\n      logger.info(\"INFO: flags.usePk=false | building NonDict2 from \"+path);\n    }\n\n    cd = new CorpusDictionary(path);\n  }\n\n  public String checkDic(String c2, SeqClassifierFlags flags) {\n    if (cd.getW(c2).equals(\"1\")) {\n      return \"1\";\n    } \n    return \"0\";\n  }\n","sourceCodeStart":24,"sourceCodeEnd":60,"githubUrl":"https://github.com/stanfordnlp/CoreNLP/blob/1b7edd19c4d0d7b1f13a2591425b9b60a0b1af7a/src/edu/stanford/nlp/wordseg/NonDict2.java#L24-L60","documentation":"NonDict2's constructor builds the non-dictionary (unseen word) feature dictionary based on corpus flags. It only supports CTB and PKU: if flags.useAs, useHk, or useMsr is set, it refuses and throws RuntimeException('only support settings for CTB and PKU now.') because no .non dictionary resource exists for those corpora.","triggerScenarios":"Instantiating NonDict2 (during segmenter setup) with useAs=true, useHk=true, or useMsr=true and no custom dict2name specified.","commonSituations":"Segmenting ASBC (Taiwan), HK, or MSR Sighan data with the NonDict2 feature enabled; mixing corpus flags; users assuming all Sighan corpora are supported like CTB/PK.","solutions":["Set dict2name to a custom non-dictionary file path so the constructor builds NonDict2 from your resource","Disable useAs/useHk/useMsr and use CTB or PK settings instead","Supply your own corpus-specific .non dictionary file and adjust the constructor path"],"exampleFix":"// before (Properties)\nuseAs=true\n// after (Properties)\ndict2name=asbc.non\nuseAs=false","handlingStrategy":"validation","validationCode":"Properties p = /* segmenter props */;\nboolean unsupported = Boolean.parseBoolean(p.getProperty(\"useAs\",\"false\"))\n  || Boolean.parseBoolean(p.getProperty(\"useHk\",\"false\"))\n  || Boolean.parseBoolean(p.getProperty(\"useMsr\",\"false\"));\nif (unsupported && (p.getProperty(\"dict2name\") == null || p.getProperty(\"dict2name\").isEmpty())) {\n  throw new IllegalArgumentException(\"Set dict2name or use CTB/PK settings (NonDict2 limitation)\");\n}","typeGuard":null,"tryCatchPattern":"try {\n  segmenter.initialize();\n} catch (RuntimeException e) {\n  if (e.getMessage().contains(\"CTB and PKU\")) {\n    props.setProperty(\"dict2name\", \"custom.non\");\n    segmenter.initialize();\n  } else throw e;\n}","preventionTips":["For ASBC/HK/MSR data, always provide dict2name pointing to a valid .non dictionary","Don't combine corpus flags; choose CTB or PK for NonDict2 features","Verify dictionary files exist under corporaDict/dict/ at startup"],"tags":["java","chinese-segmentation","dictionary","configuration"],"backgroundTag":"unsupported-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"}