stanfordnlp/CoreNLP · error · RuntimeException

Error extracting labelled spans for column :

Error message

Error extracting labelled spans for column : 

What it means

At the end of getLabelledSpans, if openSpans is not empty, some label that was opened (e.g. an opening bracket like (LABEL) was never closed by the end of the document. The reader treats unclosed spans as a data-format error and throws, including the field index and the offending column text.

Solutions

  1. Check the file is complete — diff line count / tail against the official CoNLL-2012 gold files
  2. Fix the annotation: every '(LABEL' in the column must have a 'LABEL)' before the end of the document
  3. Re-export your data from the original corpus rather than truncating while streaming
  4. If intentionally processing partial data, pre-close all open spans before the document terminator

Example fix

// before (chain never closed at end of document)
 token (12
 token 12)
 token (12
 <EOF>
// after
 token (12
 token 12)
 token (12
 token 12)   <- close every opened chain before EOF
Defensive patterns

Strategy: validation

Validate before calling

// Ensure every '(LABEL' has a matching 'LABEL)' before end of document
long opens = corefColumn.chars().filter(c -> c=='(').count();
long closes = corefColumn.chars().filter(c -> c==')').count();
if (opens != closes) throw new IllegalStateException("Unbalanced coref brackets: " + opens + " vs " + closes);

Try / catch

try { spans = reader.getLabelledSpans(...); } catch (RuntimeException e) { if (e.getMessage().startsWith("Error extracting labelled spans")) { log.error("Unclosed spans in column: " + e.getMessage(), e); throw new CorruptAnnotationException(e); } throw e; }

Prevention

When it happens

Trigger: A document in the CoNLL file opens a labelled span (e.g. coref chain start '(12' or NER '(PERSON') but no matching close token appears before the document ends; also triggered by open/close order violations within a token (an open pushed and never popped).

Common situations: Truncated corpus files (last lines cut off mid-chain); streaming a partial document; corrupted downloads; custom exporters that emit chain-open markers but drop the close marker on the final mention.

Understand the failure class

Background: "Invalid ... format", "must be in format X", "does not look like a ..." — invalid argument format errors across CLI tools and libraries — this error's family across 17 libraries.

Related errors


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

Appendix: source

Thrown at src/edu/stanford/nlp/coref/docreader/CoNLLDocumentReader.java:453

              }
              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);
        int wordPos = Integer.parseInt(fields[FIELD_WORD_NO]);

View on GitHub (pinned to 1b7edd19c4)