{"record":{"id":"17e9e5f5f35b90f6","repo":"stanfordnlp/CoreNLP","slug":"error-line-d-10-fields-expected-but-d-are-pre","errorCode":null,"errorMessage":"Error (line %d): 10 fields expected but %d are present","messagePattern":"Error \\(line (.+?)\\): 10 fields expected but (.+?) are present","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"src/edu/stanford/nlp/trees/GrammaticalStructure.java","lineNumber":1076,"sourceCode":"   * Read in a file containing a CoNLL-X dependency treebank and return a\n   * corresponding list of GrammaticalStructures.\n   *\n   * @throws IOException\n   */\n  public static List<GrammaticalStructure> readCoNLLXGrammaticalStructureCollection(String fileName, Map<String, GrammaticalRelation> shortNameToGRel, GrammaticalStructureFromDependenciesFactory factory) throws IOException {\n    try (BufferedReader r = IOUtils.readerFromString(fileName)) {\n      LineNumberReader reader = new LineNumberReader(r);\n      List<GrammaticalStructure> gsList = new LinkedList<>();\n\n      List<List<String>> tokenFields = new ArrayList<>();\n\n      for (String inline = reader.readLine(); inline != null;\n           inline = reader.readLine()) {\n        if (!inline.isEmpty()) {\n          // read in a single sentence token by token\n          List<String> fields = Arrays.asList(inline.split(\"\\t\"));\n          if (fields.size() != CoNLLX_FieldCount) {\n            throw new RuntimeException(String.format(\"Error (line %d): 10 fields expected but %d are present\", reader.getLineNumber(), fields.size()));\n          }\n          tokenFields.add(fields);\n        } else {\n          if (tokenFields.isEmpty())\n            continue; // skip excess empty lines\n\n          gsList.add(buildCoNLLXGrammaticalStructure(tokenFields, shortNameToGRel, factory));\n          tokenFields = new ArrayList<>();\n        }\n      }\n\n      return gsList;\n    }\n  }\n\n  public static GrammaticalStructure buildCoNLLXGrammaticalStructure(List<List<String>> tokenFields,\n                                Map<String, GrammaticalRelation> shortNameToGRel,\n                                GrammaticalStructureFromDependenciesFactory factory) {","sourceCodeStart":1058,"sourceCodeEnd":1094,"githubUrl":"https://github.com/stanfordnlp/CoreNLP/blob/1b7edd19c4d0d7b1f13a2591425b9b60a0b1af7a/src/edu/stanford/nlp/trees/GrammaticalStructure.java#L1058-L1094","documentation":"GrammaticalStructure's CoNLL-X reader requires every non-empty input line to contain exactly 10 tab-separated fields (CoNLLX_FieldCount). When a line has a different field count, the reader throws this RuntimeException so malformed corpora are caught immediately rather than producing corrupt dependency trees. CoNLL-X format is fixed at 10 columns (id, form, lemma, cpostag, postag, feats, head, deprel, phead, pdeprel), so any deviation means the file is not valid CoNLL-X.","triggerScenarios":"Calling GrammaticalStructure reading methods such as readCoNLLXGrammaticalStructure (or constructors from a BufferedReader) on a line whose split(\"\\t\") yields != 10 fields, e.g. space-separated instead of tab-separated files, truncated lines, or files with a header/comment row.","commonSituations":"Feeding CoNLL-U or other tab formats with fewer/more columns; converting a dependency file through a text editor that converted tabs to spaces or trimmed trailing tabs (field 10 empty); joining fields with single tabs after pre-processing left empty columns collapsed.","solutions":["Inspect the reported line number in the file and fix the field count to exactly 10 tab-separated columns, keeping empty columns as empty strings between tabs.","Ensure separators are actual tab characters ('\\t'), not spaces — convert with e.g. sed or awk if needed.","Strip header/comment lines (lines starting with '#') before passing the stream to the reader.","Pre-validate the file yourself: check every non-empty line has 10 fields and report a friendly error before invoking the library."],"exampleFix":"// before (space-separated line)\n1\tHe\tPRP\t2\tnsubj\n// after (10 tab-separated fields, empties preserved)\n1\tHe\t_\tPRP\tPRP\t_\t2\tnsubj\t_\t_","handlingStrategy":"validation","validationCode":"// Pre-validate a CoNLL-X file before reading\nfor (String line : Files.readAllLines(path)) {\n  if (line.isEmpty()) continue;\n  int n = line.split(\"\\t\", -1).length;\n  if (n != 10) throw new IllegalArgumentException(\n    \"Line not 10 tab-separated fields (\" + n + \"): \" + line);\n}","typeGuard":null,"tryCatchPattern":"try {\n  GrammaticalStructure gs = EnglishGrammaticalStructure.readCoNLLXGrammaticalStructure(reader);\n} catch (RuntimeException e) {\n  if (e.getMessage() != null && e.getMessage().contains(\"10 fields expected\")) {\n    log.error(\"Malformed CoNLL-X input: \" + e.getMessage());\n  } else throw e;\n}","preventionTips":["Always generate CoNLL-X output programmatically with tabs and keep empty columns as empty strings.","Never round-trip CoNLL-X files through editors/CSV tools that mangle tabs or strip trailing fields.","Run a 10-field line validator on the corpus before parsing."],"tags":["parsing","conll-x","dependency-trees","input-validation"],"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"}