stanfordnlp/CoreNLP · error · RuntimeException

Unexpected number of field , expected >= for line (,):

Error message

Unexpected number of field , expected >=  for line (,): 

What it means

While parsing the CoNLL file line by line, readNextDocument splits each line on the delimiter and requires at least FIELDS_MIN tab/space-separated fields (document id, part number, etc.). Lines with too few columns cannot be interpreted as CoNLL rows, so a RuntimeException names the file, line number and raw line.

Solutions

  1. Open the file at the reported filename:lineCnt and fix or remove the malformed line
  2. Ensure every data line has the full set of CoNLL columns matching the header FIELDS_* constants
  3. Verify the delimiter pattern used to construct CoNLLDocumentReader matches the actual file delimiter (e.g. \\s+ for whitespace)
  4. Re-run the official CoNLL-2012 scripts to regenerate well-formed gold files

Example fix

// before (line with missing columns)
 bc/cctv/00/cctv_0001 0 0   <- only 3 fields
// after
 bc/cctv/00/cctv_0001 0 0 token POS NE coref ... <- all FIELDS_MIN columns present
Defensive patterns

Strategy: validation

Validate before calling

for (String line : Files.readAllLines(path)) { if (line.trim().isEmpty()) continue; if (line.split(delimiter).length < 12) throw new IllegalStateException("Too few fields: " + line); }

Try / catch

try { docs = readerDocs; } catch (RuntimeException e) { if (e.getMessage().startsWith("Unexpected number of field")) { throw new DataFormatException("Malformed CoNLL line: " + e.getMessage(), e); } throw e; }

Prevention

When it happens

Trigger: Any line in the CoNLL-formatted input whose delimiter-split yields fewer than FIELDS_MIN fields — e.g. blank-ish lines with stray whitespace, an end-of-document marker in the wrong format, or a header/summary line mixed into the data.

Common situations: Files converted with the wrong delimiter (space vs tab after delimiterPattern misconfiguration); concatenated corpora with unexpected section headers; manual edits inserting empty or partial lines mid-document.

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/5b608bddbf470478. Report an issue: GitHub.

Appendix: source

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

          if (line.length() != 0) {
            if (line.startsWith(docStart)) {
              // Start of new document
              if (document != null) {
                logger.warning("Unexpected begin document at line (\" + filename + \",\" + lineCnt + \")");
              }
              document = new CoNLLDocument();
              document.filename = this.filename;
              document.documentIdPart = line.substring(docStartLength);
            } else if (line.startsWith("#end document")) {
              annotateDocument(document);
              docCnt++;
              return document;
              // End of document
            } else {
              assert document != null;
              String[] fields = delimiterPattern.split(line);
              if (fields.length < FIELDS_MIN) {
                throw new RuntimeException("Unexpected number of field " + fields.length +
                        ", expected >= " + FIELDS_MIN + " for line (" + filename + "," + lineCnt + "): " + line);
              }
              String curDocId = fields[FIELD_DOC_ID];
              String partNo = fields[FIELD_PART_NO];
              if (document.getDocumentID() == null) {
                document.setDocumentID(curDocId);
                document.setPartNo(partNo);
              } else {
                // Check documentID didn't suddenly change on us
                assert(document.getDocumentID().equals(curDocId));
                assert(document.getPartNo().equals(partNo));
              }
              curSentWords.add(fields);
            }
          } else {
            // Current sentence has ended, new sentence is about to be started
            if (curSentWords.size() > 0) {
              assert document != null;

View on GitHub (pinned to 1b7edd19c4)