{"record":{"id":"10750b2f778e222a","repo":"stanfordnlp/CoreNLP","slug":"first-line-of-input-file-should-be-header-definiti","errorCode":null,"errorMessage":"First line of input file should be header definition","messagePattern":"First line of input file should be header definition","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"src/edu/stanford/nlp/ie/KBPRelationExtractor.java","lineNumber":363,"sourceCode":"   * @param conllInputFile The input file, formatted as a TSV\n   * @return A list of examples.\n   */\n  @SuppressWarnings(\"StatementWithEmptyBody\")\n  static List<Pair<KBPInput, String>> readDataset(File conllInputFile) throws IOException {\n    BufferedReader reader = IOUtils.readerFromFile(conllInputFile);\n    List<Pair<KBPInput, String>> examples = new ArrayList<>();\n\n    int i = 0;\n    String relation = null;\n    List<String> tokens = new ArrayList<>();\n    Span subject = new Span(Integer.MAX_VALUE, Integer.MIN_VALUE);\n    NERTag subjectNER = null;\n    Span object = new Span(Integer.MAX_VALUE, Integer.MIN_VALUE);\n    NERTag objectNER = null;\n\n    String line = reader.readLine();\n    if (!line.startsWith(\"#\")) {\n      throw new IllegalArgumentException(\"First line of input file should be header definition\");\n    }\n    while ( (line = reader.readLine()) != null ) {\n      String[] fields = line.split(\"\\t\");\n      if (relation == null) {\n        // Case: read the relation\n        assert fields.length == 1;\n        relation = fields[0];\n      } else if (fields.length == 9) {\n        // Case: read a token\n        tokens.add(fields[0]);\n        if (\"SUBJECT\".equals(fields[1])) {\n          subject = new Span(Math.min(subject.start(), i), Math.max(subject.end(), i + 1));\n          subjectNER = valueOf(fields[2].toUpperCase(Locale.ROOT));\n        } else if (\"OBJECT\".equals(fields[3])) {\n          object = new Span(Math.min(object.start(), i), Math.max(object.end(), i + 1));\n          objectNER = valueOf(fields[4].toUpperCase(Locale.ROOT));\n        } else if (\"-\".equals(fields[1]) && \"-\".equals(fields[3])) {\n          // do nothing","sourceCodeStart":345,"sourceCodeEnd":381,"githubUrl":"https://github.com/stanfordnlp/CoreNLP/blob/1b7edd19c4d0d7b1f13a2591425b9b60a0b1af7a/src/edu/stanford/nlp/ie/KBPRelationExtractor.java#L345-L381","documentation":"KBPRelationExtractor.readDataset parses a tab-separated CoNLL-style KBP test file. The first line must be a header starting with '#'; otherwise the file format is wrong and it throws an IllegalArgumentException.","triggerScenarios":"Calling readDataset (or the KBP eval main) with a file whose first line is data, blank, or lacks the '#'-prefixed header — e.g. a headerless CoNLL dump or a plain-text file.","commonSituations":"Files prepared without the header row; CSV vs TSV exports stripped of comment lines; Unix tooling (grep/sed) that dropped '#' lines as comments.","solutions":["Add a '#'-prefixed header line as the first line of the dataset file","Verify you are pointing at the official KBP CoNLL-format file, not a derived/filtered copy","Check whether your preprocessing pipeline stripped the comment/header lines","Peek with head -n 1 file to confirm the header before running"],"exampleFix":"// before\nreadDataset(\"test.tsv\"); // first line is data → IllegalArgumentException\n// after\n// prepend header: '#' columns...\nreadDataset(\"test_with_header.tsv\"); // first line: \"# WORD\tRE\t...\tOBJECT\t...\"","handlingStrategy":"validation","validationCode":"try (BufferedReader r = new BufferedReader(new FileReader(file))) {\n  String first = r.readLine();\n  if (first == null || !first.startsWith(\"#\"))\n    throw new IllegalArgumentException(file + \" missing '#' header line\");\n}","typeGuard":null,"tryCatchPattern":"try {\n  List<Pair<KBPInput, String>> data = readDataset(path);\n} catch (IllegalArgumentException e) {\n  log.error(\"KBP dataset malformed: \" + e.getMessage());\n  throw e;\n}","preventionTips":["Never let grep/sed filtering drop '#' comment/header lines","head -n 1 the dataset before running evaluation","Use the official KBP sample file as a format reference"],"tags":["java","corenlp","kbp","file-format"],"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-15T23:17:13.987Z"}