{"record":{"id":"9c57eb51c524da6c","repo":"stanfordnlp/CoreNLP","slug":"unknown-label","errorCode":null,"errorMessage":"Unknown label: ","messagePattern":"Unknown label: ","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"src/edu/stanford/nlp/international/arabic/process/IOBUtils.java","lineNumber":542,"sourceCode":"          case \"ل\":\n            sb.append((addPrefixMarker ? prefixMarker : \"\") +\n                (addSpace ? \" \" : \"\") +\n                (applyRewrites ? \"ال\" : \"ل\"));\n            break;\n          case \"ي\":\n          case \"ا\":\n            sb.append(applyRewrites ? \"ى\" : token);\n            break;\n          case \"ى\":\n            sb.append(applyRewrites ? \"ي\" : token);\n            break;\n          default:\n            // Nonsense rewrite predicted by the classifier--just assume CONT\n            sb.append(token);\n            break;\n        }\n      } else {\n        throw new RuntimeException(\"Unknown label: \" + label);\n      }\n      lastLabel = label;\n    }\n    return sb.toString().trim();\n  }\n  \n  private static class PrefixMarkerAnnotation implements CoreAnnotation<Boolean> {\n    @Override\n    public Class<Boolean> getType() {\n      return Boolean.class;\n    }\n  }\n  \n  private static class SuffixMarkerAnnotation implements CoreAnnotation<Boolean> {\n    @Override\n    public Class<Boolean> getType() {\n      return Boolean.class;\n    }","sourceCodeStart":524,"sourceCodeEnd":560,"githubUrl":"https://github.com/stanfordnlp/CoreNLP/blob/1b7edd19c4d0d7b1f13a2591425b9b60a0b1af7a/src/edu/stanford/nlp/international/arabic/process/IOBUtils.java#L524-L560","documentation":"IOBToString converts IO/B-tagged tokens back into a segmented string. When a token carries a label outside the recognized IOB scheme (not B*, I*, or the handled control labels), the method throws RuntimeException('Unknown label: ' + label) because no rewrite rule exists for it.","triggerScenarios":"Running IOBToString over classifier output whose labels were produced with a different tag set or corrupted labeling, so a label reaching the switch's else branch is unrecognized.","commonSituations":"Mixing label inventories between training and decoding; feeding hand-built or third-party IOB sequences with unexpected tags; classifier emitting labels the post-processor does not know (version or feature-set mismatch).","solutions":["Inspect the offending label value in the message and reconcile it with the expected IOB tag set","Retrain/decode with the same label scheme the IOB post-processing expects","Pre-validate/normalize labels before calling IOBToString, mapping or rejecting unknown tags","Update the switch in IOBUtils to handle the new label type if it is legitimate"],"exampleFix":"// before\nString s = IOBUtils.IOBToString(tokens, \"tag\"); // unknown custom label\n// after\nfor (CoreLabel t : tokens) {\n  String l = t.tag();\n  if (!l.equals(\"B\") && !l.equals(\"I\") && !l.startsWith(\"B-\") && !l.startsWith(\"I-\"))\n    throw new IllegalArgumentException(\"Unexpected IOB label: \" + l);\n}\nString s = IOBUtils.IOBToString(tokens, \"tag\");","handlingStrategy":"validation","validationCode":"for (CoreLabel t : tokens) {\n  String l = t.tag();\n  if (!(l.equals(\"B\") || l.equals(\"I\") || l.startsWith(\"B-\") || l.startsWith(\"I-\")))\n    throw new IllegalArgumentException(\"Unexpected IOB label: \" + l);\n}","typeGuard":"boolean isKnownIobLabel(String l){ return l.equals(\"B\")||l.equals(\"I\")||l.startsWith(\"B-\")||l.startsWith(\"I-\"); }","tryCatchPattern":"try { String s = IOBUtils.IOBToString(tokens, key); } catch (RuntimeException e) { /* inspect e.getMessage() for the offending label */ }","preventionTips":["Keep training and decoding label schemes identical","Normalize third-party IOB output to the expected tag set before conversion"],"tags":["java","nlp","iob","label-scheme"],"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-17T15:17:12.973Z"}