{"record":{"id":"c22c3ce997354f0b","repo":"stanfordnlp/CoreNLP","slug":"no-index-annotation-for","errorCode":null,"errorMessage":"No index annotation for ","messagePattern":"No index annotation for ","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"src/edu/stanford/nlp/trees/CollinsDependency.java","lineNumber":42,"sourceCode":"\n\tprivate static final String normPOSLabel = \"TAG\";\n\n\tprivate final CoreLabel modifier;\n\tprivate final CoreLabel head;\n\tprivate final CollinsRelation relation;\n\n\t/**\n\t * Modifier must have IndexAnnotation. If head has 0 as its index, then it is\n\t * the start symbol (\"boundary symbol\" in the Dan Klein code).\n\t *\n\t * @param modifier\n\t * @param head\n\t * @param rel\n\t */\n\tpublic CollinsDependency(CoreLabel modifier, CoreLabel head, CollinsRelation rel) {\n\n\t\tif(modifier.index() == 0)\n\t\t\tthrow new RuntimeException(\"No index annotation for \" + modifier.toString());\n\n\t\tthis.modifier = modifier;\n\t\tthis.head = head;\n\t\trelation = rel;\n\t}\n\n\tpublic CollinsRelation getRelation() { return relation; }\n\n\tpublic DependencyFactory dependencyFactory() { return null; }\n\n\tpublic CoreLabel dependent() { return modifier; }\n\n\tpublic CoreLabel governor() { return head; }\n\n\tpublic boolean equalsIgnoreName(Object o) { return this.equals(o); }\n\n\tpublic String name() { return \"CollinsBilexicalDependency\"; }\n","sourceCodeStart":24,"sourceCodeEnd":60,"githubUrl":"https://github.com/stanfordnlp/CoreNLP/blob/1b7edd19c4d0d7b1f13a2591425b9b60a0b1af7a/src/edu/stanford/nlp/trees/CollinsDependency.java#L24-L60","documentation":"The CollinsDependency constructor requires that the modifier CoreLabel carry a token index (modifier.index() != 0), because Collins-style dependencies are defined over positionally indexed tokens. If the modifier's index is 0 (never annotated), the dependency would be meaningless, so it throws immediately naming the offending label.","triggerScenarios":"Constructing CollinsDependency from labels produced without the tokenizer's IndexAnnotation — e.g. labels created manually with new CoreLabel(word) instead of being read from a tokenizer/parser pipeline, or after stripping annotations.","commonSituations":"Post-processing parse outputs with hand-built CoreLabels; converting between dependency formats where indices were dropped; using an annotation pipeline without tokenization (labels never got an IndexAnnotation).","solutions":["Ensure labels come from a tokenized pipeline so IndexAnnotation is set, or call modifier.setIndex(i) before constructing CollinsDependency.","When building labels manually, assign indices explicitly: CoreLabel l = new CoreLabel(); l.setWord(w); l.setIndex(pos);"],"exampleFix":"// before\nCoreLabel mod = new CoreLabel();\nmod.setWord(\"runs\");\nnew CollinsDependency(mod, head, rel);\n// after\nmod.setIndex(3);\nnew CollinsDependency(mod, head, rel);","handlingStrategy":"validation","validationCode":"if (modifier.index() == 0) { modifier.setIndex(tokenPosition); } // before constructing","typeGuard":"boolean hasIndex(CoreLabel l) { return l.index() != 0; }","tryCatchPattern":"try { new CollinsDependency(mod, head, rel); } catch (RuntimeException e) { mod.setIndex(assignIndex(mod)); new CollinsDependency(mod, head, rel); }","preventionTips":["Always build labels through a tokenized pipeline so IndexAnnotation is set","Call setIndex when constructing CoreLabels manually"],"tags":["java","nlp","annotations","missing-required-argument"],"backgroundTag":"missing-required-argument","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"}