{"record":{"id":"89891b1ed8372168","repo":"stanfordnlp/CoreNLP","slug":"unknown-label-label","errorCode":null,"errorMessage":"Unknown label ${label}","messagePattern":"Unknown label (.+?)","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"src/edu/stanford/nlp/classify/LinearClassifier.java","lineNumber":387,"sourceCode":"    // NB: this duplicate method is needed so it calls the scoresOf method\n    // with an RVFDatum signature!!  Don't remove it!\n    // JLS: type resolution of method parameters is static\n    Counter<L> scores = scoresOf(example);\n    Counters.logNormalizeInPlace(scores);\n    return scores;\n  }\n\n  /**\n   * Returns indices of labels\n   * @param labels - Set of labels to get indices\n   * @return Set of indices\n   */\n  protected Set<Integer> getLabelIndices(Set<L> labels) {\n    Set<Integer> iLabels = Generics.newHashSet();\n    for (L label:labels) {\n      int iLabel = labelIndex.indexOf(label);\n      iLabels.add(iLabel);\n      if (iLabel < 0) throw new IllegalArgumentException(\"Unknown label \" + label);\n    }\n    return iLabels;\n  }\n\n  /**\n   * Returns number of features with weight above a certain threshold\n   * (across all labels).\n   *\n   * @param threshold  Threshold above which we will count the feature\n   * @param useMagnitude Whether the notion of \"large\" should ignore\n   *                     the sign of the feature weight.\n   * @return number of features satisfying the specified conditions\n   */\n  public int getFeatureCount(double threshold, boolean useMagnitude)\n  {\n    int n = 0;\n    for (double[] weightArray : weights) {\n      for (double weight : weightArray) {","sourceCodeStart":369,"sourceCodeEnd":405,"githubUrl":"https://github.com/stanfordnlp/CoreNLP/blob/1b7edd19c4d0d7b1f13a2591425b9b60a0b1af7a/src/edu/stanford/nlp/classify/LinearClassifier.java#L369-L405","documentation":"Thrown by LinearClassifier.getLabelIndices when a requested label is not present in the classifier's labelIndex. The classifier can only score labels seen during training; the caller asked for an unknown label's index.","triggerScenarios":"Thrown at src/edu/stanford/nlp/classify/LinearClassifier.java:387 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Use only labels from classifier.labels()","Check for label spelling/casing mismatches","Retrain the model if the label should exist","Filter the requested label set against labelIndex before lookup"],"exampleFix":null,"handlingStrategy":"type-guard","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"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"}