stanfordnlp/CoreNLP · error · RuntimeException

Error extracting labelled spans for column

Error message

Error extracting labelled spans for column {fieldIndex}: {concatField(sentWords, fieldIndex)}

What it means

CoNLL2011DocumentReader.getLabelledSpans builds coreference spans from per-column token labels using an openSpans stack. If any span was opened (pushed) but never closed by the end of the sentence's words, the stack is non-empty and the reader throws this RuntimeException, because the CoNLL file has an unterminated span for that column.

Solutions

  1. Inspect the CoNLL file named in the message at the reported column and fix/complete the unterminated span annotation (add the missing closing row).
  2. Validate the corpus with the official CoNLL scorer/scripts (which report unbalanced brackets) before running dcoref.
  3. Re-download or regenerate the corpus files — truncation during download/extraction is common.
  4. Verify the fieldIndex/column constants used when reading the file match the actual file layout.
  5. If preprocessing yourself, write a round-trip check that every opened span is closed per sentence before consuming the file.

Example fix

// before (broken corpus row, span opened but never closed)
// word ... (0  <- coref column opens span on this token, sentence ends

// after
// word ... (0)
// ... or complete the span across rows:
// word1 ... (0
// word2 ... 0)  <- span properly closed
Defensive patterns

Strategy: validation

Validate before calling

// Validate CoNLL file balance before running dcoref
int open = 0;
for (String[] row : sentences) {
  String col = row[fieldIndex];
  if (col.startsWith("(")) open += col.contains(")") ? 0 : 1;
  else if (col.contains(")")) open--; // check per-row semantics
}
if (open != 0) throw new IllegalStateException("Unbalanced spans in column " + fieldIndex);

Prevention

When it happens

Trigger: Parsing a CoNLL-2011/2012 corpus file where a begin-label (e.g. an opening coreference bracket or other labelled column value) appears for a token but the matching end/continuation label is never seen before the sentence ends — i.e. unbalanced bracket annotation in the corpus data.

Common situations: Truncated or hand-edited CoNLL corpus files; annotation-converted files (e.g. from OntoNotes conversions) with dropped closing rows; custom-preprocessed columns where the closing marker was lost; wrong column index (fieldIndex) passed so a non-coref column is interpreted as containing span labels.

Understand the failure class

Background: Schema validation failed / invalid input schema: payload rejected because its shape doesn't match the expected schema — this error's family across 28 libraries.

Related errors


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

Appendix: source

Thrown at src/edu/stanford/nlp/dcoref/CoNLL2011DocumentReader.java:408

              }
              t.setSecond(wordPos);
              spans.add(t);
            }
            if (isDelimiter) {
              lastDelimiterIndex = j;
            }
          }
          if (openParenIndex >= 0) {
            String s = val.substring(openParenIndex+1, val.length());
            if (removeStar) {
              s = starPattern.matcher(s).replaceAll("");
            }
            openSpans.push(new Triple<>(wordPos, -1, s));
          }
        }
      }
      if (openSpans.size() != 0) {
        throw new RuntimeException("Error extracting labelled spans for column " + fieldIndex + ": "
                + concatField(sentWords, fieldIndex));
      }
      return spans;
    }

    private CoreMap wordsToSentence(List<String[]> sentWords)
    {
      String sentText = concatField(sentWords, FIELD_WORD);
      Annotation sentence = new Annotation(sentText);
      Tree tree = wordsToParse(sentWords);
      sentence.set(TreeCoreAnnotations.TreeAnnotation.class, tree);
      List<Tree> leaves = tree.getLeaves();
      // Check leaves == number of words
      assert(leaves.size() == sentWords.size());
      List<CoreLabel> tokens = new ArrayList<>(leaves.size());
      sentence.set(CoreAnnotations.TokensAnnotation.class, tokens);
      for (int i = 0; i < sentWords.size(); i++) {
        String[] fields = sentWords.get(i);

View on GitHub (pinned to 1b7edd19c4)