stanfordnlp/CoreNLP · error · RuntimeException

No index annotation for

Error message

No index annotation for 

What it means

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.

Solutions

  1. Ensure labels come from a tokenized pipeline so IndexAnnotation is set, or call modifier.setIndex(i) before constructing CollinsDependency.
  2. When building labels manually, assign indices explicitly: CoreLabel l = new CoreLabel(); l.setWord(w); l.setIndex(pos);

Example fix

// before
CoreLabel mod = new CoreLabel();
mod.setWord("runs");
new CollinsDependency(mod, head, rel);
// after
mod.setIndex(3);
new CollinsDependency(mod, head, rel);
Defensive patterns

Strategy: validation

Validate before calling

if (modifier.index() == 0) { modifier.setIndex(tokenPosition); } // before constructing

Type guard

boolean hasIndex(CoreLabel l) { return l.index() != 0; }

Try / catch

try { new CollinsDependency(mod, head, rel); } catch (RuntimeException e) { mod.setIndex(assignIndex(mod)); new CollinsDependency(mod, head, rel); }

Prevention

When it happens

Trigger: 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.

Common situations: 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).

Understand the failure class

Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.

Related errors


AI-assisted analysis of stanfordnlp/CoreNLP@1b7edd19c4 (2026-09-10). Data as JSON: /api/errors/c22c3ce997354f0b. Report an issue: GitHub.

Appendix: source

Thrown at src/edu/stanford/nlp/trees/CollinsDependency.java:42

	private static final String normPOSLabel = "TAG";

	private final CoreLabel modifier;
	private final CoreLabel head;
	private final CollinsRelation relation;

	/**
	 * Modifier must have IndexAnnotation. If head has 0 as its index, then it is
	 * the start symbol ("boundary symbol" in the Dan Klein code).
	 *
	 * @param modifier
	 * @param head
	 * @param rel
	 */
	public CollinsDependency(CoreLabel modifier, CoreLabel head, CollinsRelation rel) {

		if(modifier.index() == 0)
			throw new RuntimeException("No index annotation for " + modifier.toString());

		this.modifier = modifier;
		this.head = head;
		relation = rel;
	}

	public CollinsRelation getRelation() { return relation; }

	public DependencyFactory dependencyFactory() { return null; }

	public CoreLabel dependent() { return modifier; }

	public CoreLabel governor() { return head; }

	public boolean equalsIgnoreName(Object o) { return this.equals(o); }

	public String name() { return "CollinsBilexicalDependency"; }

View on GitHub (pinned to 1b7edd19c4)