{"record":{"id":"b1284646b1558a81","repo":"stanfordnlp/CoreNLP","slug":"unexpected-number-of-field-fields-length-expect","errorCode":null,"errorMessage":"Unexpected number of field {fields.length}, expected >= {FIELDS_MIN} for line ({filename},{lineCnt}): {line}","messagePattern":"Unexpected number of field (.+?), expected >= (.+?) for line \\((.+?),(.+?)\\): (.+?)","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"src/edu/stanford/nlp/dcoref/CoNLL2011DocumentReader.java","lineNumber":658,"sourceCode":"          line = line.trim();\n          if (line.length() != 0) {\n            if (line.startsWith(docStart)) {\n              // Start of new document\n              if (document != null) {\n                logger.warning(\"Unexpected begin document at line (\\\" + filename + \\\",\\\" + lineCnt + \\\")\");\n              }\n              document = new Document();\n              document.documentIdPart = line.substring(docStartLength);\n            } else if (line.startsWith(\"#end document\")) {\n              annotateDocument(document);\n              docCnt++;\n              return document;\n              // End of document\n            } else {\n              assert document != null;\n              String[] fields = delimiterPattern.split(line);\n              if (fields.length < FIELDS_MIN) {\n                throw new RuntimeException(\"Unexpected number of field \" + fields.length +\n                        \", expected >= \" + FIELDS_MIN + \" for line (\" + filename + \",\" + lineCnt + \"): \" + line);\n              }\n              String curDocId = fields[FIELD_DOC_ID];\n              String partNo = fields[FIELD_PART_NO];\n              if (document.getDocumentID() == null) {\n                document.setDocumentID(curDocId);\n                document.setPartNo(partNo);\n              } else {\n                // Check documentID didn't suddenly change on us\n                assert(document.getDocumentID().equals(curDocId));\n                assert(document.getPartNo().equals(partNo));\n              }\n              curSentWords.add(fields);\n            }\n          } else {\n            // Current sentence has ended, new sentence is about to be started\n            if (curSentWords.size() > 0) {\n              assert document != null;","sourceCodeStart":640,"sourceCodeEnd":676,"githubUrl":"https://github.com/stanfordnlp/CoreNLP/blob/1b7edd19c4d0d7b1f13a2591425b9b60a0b1af7a/src/edu/stanford/nlp/dcoref/CoNLL2011DocumentReader.java#L640-L676","documentation":"DocumentIterator.next() splits each non-blank line of the CoNLL file on the delimiter and requires at least FIELDS_MIN tab-separated fields to extract document id, part number, word, etc. A line with fewer fields than FIELDS_MIN is malformed, so it throws a RuntimeException including the file name, line count, and raw line to pinpoint the bad row.","triggerScenarios":"Calling DocumentIterator (via CoNLL2011DocumentReader.nextDoc / dcoref pipeline) over a corpus file that contains a line with too few columns — e.g. a blank-ish line with only a word, a header line, or a row where trailing tabs were stripped.","commonSituations":"Editors or upload pipelines trimming trailing tabs from TSV/CoNLL files; mixing CoNLL formats (CoNLL-2010 vs 2011 vs 2012 have different column counts); accidentally feeding a non-CoNLL text file as the corpus path.","solutions":["Open the file at the reported line (from the message: filename,lineCnt) and fix or remove the malformed row, restoring all required tab-separated columns.","Ensure no text editor or transfer step (e.g. git autocrlf, upload normalization) stripped trailing tabs from the corpus.","Confirm the file is the correct CoNLL-2011 format matching the FIELDS_MIN expectation; re-obtain the original corpus if not.","Run a pre-check script that counts fields per line and reports lines below the required count before running the reader.","If generating files yourself, terminate each row with the full column set including trailing empty fields."],"exampleFix":"// before (line stripped to 2 fields)\n// XYZ\t1\n\n// after (full CoNLL row with all FIELDS_MIN columns)\n// XYZ\t1\t1\tword\tPOS\tPARSE\tPRED\tCOREF...","handlingStrategy":"validation","validationCode":"// Pre-check every line has enough tab-separated fields\ntry (BufferedReader r = Files.newBufferedReader(Paths.get(corpusPath))) {\n  String line; int n = 0;\n  while ((line = r.readLine()) != null) {\n    if (!line.trim().isEmpty() && line.split(\"\\t\").length < 10 /* FIELDS_MIN */)\n      throw new IllegalStateException(\"Line \" + (n+1) + \" has too few fields: \" + line);\n    n++;\n  }\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Preserve trailing tabs when saving TSV/CoNLL files (disable trim-on-save).","Verify corpus format matches the reader's expected column count before ingest.","Run a field-count linter over generated corpus files.","Transfer corpora with binary-safe methods (git lfs, checksums) to avoid silent edits."],"tags":["java","corpus-parsing","format-validation","corenlp"],"backgroundTag":"invalid-argument-format","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"}