{"record":{"id":"5b608bddbf470478","repo":"stanfordnlp/CoreNLP","slug":"unexpected-number-of-field-expected-for-line","errorCode":null,"errorMessage":"Unexpected number of field , expected >=  for line (,): ","messagePattern":"Unexpected number of field , expected >=  for line \\(,\\): ","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"src/edu/stanford/nlp/coref/docreader/CoNLLDocumentReader.java","lineNumber":699,"sourceCode":"          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 CoNLLDocument();\n              document.filename = this.filename;\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":681,"sourceCodeEnd":717,"githubUrl":"https://github.com/stanfordnlp/CoreNLP/blob/1b7edd19c4d0d7b1f13a2591425b9b60a0b1af7a/src/edu/stanford/nlp/coref/docreader/CoNLLDocumentReader.java#L681-L717","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Open the file at the reported filename:lineCnt and fix or remove the malformed line","Ensure every data line has the full set of CoNLL columns matching the header FIELDS_* constants","Verify the delimiter pattern used to construct CoNLLDocumentReader matches the actual file delimiter (e.g. \\\\s+ for whitespace)","Re-run the official CoNLL-2012 scripts to regenerate well-formed gold files"],"exampleFix":"// before (line with missing columns)\n bc/cctv/00/cctv_0001 0 0   <- only 3 fields\n// after\n bc/cctv/00/cctv_0001 0 0 token POS NE coref ... <- all FIELDS_MIN columns present","handlingStrategy":"validation","validationCode":"for (String line : Files.readAllLines(path)) { if (line.trim().isEmpty()) continue; if (line.split(delimiter).length < 12) throw new IllegalStateException(\"Too few fields: \" + line); }","typeGuard":null,"tryCatchPattern":"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; }","preventionTips":["Match the reader's delimiter pattern to the actual file delimiter","Strip non-CoNLL headers/summaries from data files","Validate file structure before long training/eval runs","Keep one canonical conversion script for corpus preparation"],"tags":["java","conll","file-format","line-parsing"],"backgroundTag":"schema-validation-failed","analyzedSha":"1b7edd19c4d0d7b1f13a2591425b9b60a0b1af7a","analyzedAt":"2026-09-10T02:24:07.274Z","contentChangedAt":"2026-09-10T02:24:07.274Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}