{"record":{"id":"1db00dd24a81df9f","repo":"stanfordnlp/CoreNLP","slug":"this-code-branch-left-blank-because-we-do-not-unde-1db00d","errorCode":null,"errorMessage":"This code branch left blank because we do not understand what this method should do.","messagePattern":"This code branch left blank because we do not understand what this method should do\\.","errorType":"exception","errorClass":"java.lang.UnsupportedOperationException","httpStatus":null,"severity":"error","filePath":"src/edu/stanford/nlp/ling/IndexedWord.java","lineNumber":612,"sourceCode":"      @Override\n      public Label newLabel(String labelStr) {\n        CoreLabel coreLabel = new CoreLabel();\n        coreLabel.setValue(labelStr);\n        return new IndexedWord(coreLabel);\n      }\n\n      @Override\n      public Label newLabel(String labelStr, int options) {\n        return newLabel(labelStr);\n      }\n\n      @Override\n      public Label newLabel(Label oldLabel) {\n        return new IndexedWord(oldLabel);\n      }\n\n      @Override\n      public Label newLabelFromString(String encodedLabelStr) {\n        throw new UnsupportedOperationException(\"This code branch left blank\" +\n        \" because we do not understand what this method should do.\");\n      }\n    };\n  }\n\n  /**\n   * {@inheritDoc}\n   */\n  @Override\n  public LabelFactory labelFactory() {\n    return IndexedWord.factory();\n  }\n\n}\n","sourceCodeStart":594,"sourceCodeEnd":628,"githubUrl":"https://github.com/stanfordnlp/CoreNLP/blob/1b7edd19c4d0d7b1f13a2591425b9b60a0b1af7a/src/edu/stanford/nlp/ling/IndexedWord.java#L594-L628","documentation":"IndexedWord.factory() returns an anonymous LabelFactory whose newLabelFromString method throws UnsupportedOperationException with a placeholder message stating the authors never implemented it. It is an explicitly unimplemented factory method, not a data or configuration error. Any attempt to build an IndexedWord from a string through this factory fails.","triggerScenarios":"Calling IndexedWord.factory().newLabelFromString(s), or generic label-creation code that invokes newLabelFromString on the label factory returned by IndexedWord.factory().","commonSituations":"Reflection-based or generic deserialization frameworks that assume every LabelFactory supports newLabelFromString; code that builds labels uniformly from serialized string representations of dependency-graph nodes.","solutions":["Do not use factory().newLabelFromString for IndexedWord; create a CoreLabel from your string and wrap it: new IndexedWord(coreLabel).","Use IndexedWord.valueOf(CoreLabel) or copy an existing label with factory().newLabel(label).","Parse the string yourself (word, index, sentence index) and set them on the constructed IndexedWord."],"exampleFix":"// before\nLabel l = IndexedWord.factory().newLabelFromString(\"went-3\"); // throws\n// after\nCoreLabel cl = new CoreLabel();\ncl.setWord(\"went\");\nIndexedWord iw = new IndexedWord(cl);\niw.setIndex(3);","handlingStrategy":"try-catch","validationCode":"LabelFactory lf = IndexedWord.factory();\n// newLabelFromString is intentionally unimplemented — never call it\n// build via newLabel(existingLabel) or new IndexedWord(coreLabel) instead","typeGuard":null,"tryCatchPattern":"try {\n  return IndexedWord.factory().newLabelFromString(str);\n} catch (UnsupportedOperationException e) {\n  CoreLabel cl = new CoreLabel();\n  cl.setWord(str.split(\"-\")[0]);\n  return new IndexedWord(cl);\n}","preventionTips":["Treat IndexedWord.factory().newLabelFromString as permanently unimplemented; do not call it.","Use factory().newLabel(Label) or the IndexedWord(CoreLabel) constructor.","For reflection-driven label creation, special-case IndexedWord and construct from a CoreLabel.","Check source of third-party label utilities for calls to newLabelFromString."],"tags":["java","nlp","not-implemented","indexedword"],"backgroundTag":"method-not-implemented","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"}