{"record":{"id":"4d874f598f585420","repo":"stanfordnlp/CoreNLP","slug":"unknown-feature-type-feature","errorCode":null,"errorMessage":"Unknown feature type \" + feature","messagePattern":"Unknown feature type \" \\+ feature","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"src/edu/stanford/nlp/ie/crf/CRFClassifier.java","lineNumber":257,"sourceCode":"   *\n   * @param feature Feature string\n   * @return index of featureType\n   */\n  private static int getFeatureTypeIndex(String feature) {\n    if (feature.endsWith(\"|C\")) {\n      return 0;\n    } else if (feature.endsWith(\"|CpC\")) {\n      return 1;\n    } else if (feature.endsWith(\"|Cp2C\")) {\n      return 2;\n    } else if (feature.endsWith(\"|Cp3C\")) {\n      return 3;\n    } else if (feature.endsWith(\"|Cp4C\")) {\n      return 4;\n    } else if (feature.endsWith(\"|Cp5C\")) {\n      return 5;\n    } else {\n      throw new RuntimeException(\"Unknown feature type \" + feature);\n    }\n  }\n\n  /**\n   * Scales the weights of this CRFClassifier by the specified weight.\n   *\n   * @param scale The scale to multiply by\n   */\n  public void scaleWeights(double scale) {\n    for (int i = 0; i < weights.length; i++) {\n      for (int j = 0; j < weights[i].length; j++) {\n        weights[i][j] *= scale;\n      }\n    }\n  }\n\n  /**\n   * Combines weights from another crf (scaled by weight) into this CRF's","sourceCodeStart":239,"sourceCodeEnd":275,"githubUrl":"https://github.com/stanfordnlp/CoreNLP/blob/1b7edd19c4d0d7b1f13a2591425b9b60a0b1af7a/src/edu/stanford/nlp/ie/crf/CRFClassifier.java#L239-L275","documentation":"getFeatureTypeIndex maps a feature name to an index (0-5) based on its suffix (e.g. |C, |Cp2C, ... |Cp5C), which encodes the label-window size for that feature. If the feature name ends with none of the recognized suffixes, the classifier cannot determine how many labels the feature's weight matrix applies to, so it throws a RuntimeException.","triggerScenarios":"Calling combine() (or any code path that builds the feature-type map via getFeatureTypeIndex) when one classifier's featureIndex contains a feature whose name lacks a recognized '|CpNC' suffix; typically features created by a CRF with different featureFactory suffix configuration.","commonSituations":"Merging two CRF models trained with different feature factories or suffix conventions; custom SeqClassifierFlags.props / featureFactory strings that drop the standard suffix; loading a model whose feature naming doesn't match the current code's expectations.","solutions":["Check the feature name reported in the exception; ensure both models were trained with the same featureFactory (flags.featureFactory) and its suffix conventions.","Retrain or re-serialize both classifiers with matching feature definitions before calling combine().","Extend getFeatureTypeIndex (or the feature factory) to emit a recognized suffix for your custom features, or exclude non-standard features before combining."],"exampleFix":"// before: custom feature factory emits features like \"MYFEAT-3\"\n// after: emit with the expected suffix so the type index resolves\nnew CoreLabel(); featName = base + \"|C\"; // e.g. \"MYFEAT-3|C\"","handlingStrategy":"validation","validationCode":"List<String> SUFFIXES = List.of(\"|C\", \"|Cp2C\", \"|Cp3C\", \"|Cp4C\", \"|Cp5C\");\nfor (String f : (Iterable<String>) crf.featureIndex) {\n  if (SUFFIXES.stream().noneMatch(f::endsWith))\n    throw new IllegalStateException(\"Unrecognized feature suffix: \" + f);\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Use the same featureFactory configuration for all models you plan to combine.","Inspect a serialized model's featureIndex before combining it.","Keep standard |CpNC suffixes in any custom feature factory."],"tags":["java","crf","feature-index","model-combine"],"backgroundTag":"invalid-enum-value","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"}