{"record":{"id":"b2065c2a4dee709e","repo":"stanfordnlp/CoreNLP","slug":"error-typed-singleton-feature","errorCode":null,"errorMessage":"ERROR: typed SINGLETON feature.","messagePattern":"ERROR: typed SINGLETON feature\\.","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"src/edu/stanford/nlp/ie/ChineseMorphFeatureSets.java","lineNumber":114,"sourceCode":"      }\n\n      Matcher typedSingleFeatMatcher = typedSingleFeatPattern.matcher(line);\n      if (typedSingleFeatMatcher.matches()) {\n        String featName = typedSingleFeatMatcher.group(1);\n        featIndex.add(featName);\n        String featIndexString = Integer.toString(featIndex.indexOf(featName));\n        String charString = typedSingleFeatMatcher.group(2);\n        switch (featType) {\n          case PREFIX:\n            addTypedFeature(featIndexString, charString.charAt(0), true);\n            break;\n\n          case SUFFIX:\n            addTypedFeature(featIndexString, charString.charAt(0), false);\n            break;\n\n          case SINGLETON:\n            throw new RuntimeException(\"ERROR: typed SINGLETON feature.\");\n        }\n        continue;\n      }\n\n      Matcher singleFeatMatcher = singleFeatPattern.matcher(line);\n      if (singleFeatMatcher.matches()) {\n        String charString = singleFeatMatcher.group();\n        featureSet.add(charString.charAt(0));\n        continue;\n      }\n\n      if (line.startsWith(\"prefix\") || line.startsWith(\"suffix\")) {\n        if (featureSet.size() > 0) {\n          Pair<Set<Character>, Set<Character>> p = affixFeatures.get(singleFeatIndexString);\n          if (p == null) {\n            affixFeatures.put(singleFeatIndexString, p = new Pair<>());\n          }\n          if (featType == FeatType.PREFIX) {","sourceCodeStart":96,"sourceCodeEnd":132,"githubUrl":"https://github.com/stanfordnlp/CoreNLP/blob/1b7edd19c4d0d7b1f13a2591425b9b60a0b1af7a/src/edu/stanford/nlp/ie/ChineseMorphFeatureSets.java#L96-L132","documentation":"When parsing a typed morphological feature line, a SINGLETON entry hits a case the code does not handle: single-character features cannot be typed as prefix/suffix, so getFeatures throws a RuntimeException. It indicates malformed or unsupported content in the .gb feature file.","triggerScenarios":"A feature file line parsed as a typed feature whose FeatType resolves to SINGLETON, i.e. a typed line declaring a singleton feature in the .gb morphological feature data.","commonSituations":"Hand-edited or corrupted .gb feature files; feature files from a different format version being fed to this loader; mixing typed and singleton feature declarations incorrectly.","solutions":["Remove or fix the SINGLETON entry in the typed feature section of the .gb file","Declare singleton features in the single-feature section (matched by singleFeatPattern), not as typed features","Verify the feature file matches the format expected by this library version"],"exampleFix":"// before (in .gb typed section)\nS:好\n// after: move singleton chars to the untyped/single feature list\n好","handlingStrategy":"validation","validationCode":"// pre-validate .gb lines: no typed line may declare a SINGLETON feature\nfor (String line : Files.readAllLines(gbFile.toPath(), StandardCharsets.UTF_8)) {\n  if (line.matches(\"^[PS]:.\") ) throw new IllegalStateException(\"Typed SINGLETON-like line in \" + gbFile);\n}","typeGuard":null,"tryCatchPattern":"try { fs = new ChineseMorphFeatureSets(dir); }\ncatch (RuntimeException e) { if (e.getMessage().contains(\"SINGLETON\")) { log.error(\"Malformed .gb file at line-level: fix typed SINGLETON entry\"); } throw e; }","preventionTips":["Validate feature files with a lint script before loading","Keep feature files unmodified from the official distribution","Distinguish typed vs singleton feature sections per the file format docs"],"tags":["parsing","malformed-input","chinese-nlp"],"backgroundTag":"invalid-argument-format","analyzedSha":"1b7edd19c4d0d7b1f13a2591425b9b60a0b1af7a","analyzedAt":"2026-09-10T02:24:07.274Z","contentChangedAt":"2026-09-10T02:24:07.274Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}