{"record":{"id":"05ce133306d0d617","repo":"stanfordnlp/CoreNLP","slug":"got-unsplittable-line","errorCode":null,"errorMessage":"Got unsplittable line: \"","messagePattern":"Got unsplittable line: \"","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"src/edu/stanford/nlp/stats/ClassicCounter.java","lineNumber":569,"sourceCode":"   * <blockquote>\n   * StringKey\\tdoubleValue\\n\n   * </blockquote>\n   *\n   * @param s String representation of a Counter, where entries are one per\n   *     line such that each line is either a comment (begins with #)\n   *     or key \\t value\n   * @return The Counter with String keys\n   */\n  public static ClassicCounter<String> valueOfIgnoreComments(String s) {\n      ClassicCounter<String> result = new ClassicCounter<>();\n      String[] lines = s.split(\"\\n\");\n      for (String line : lines) {\n        String[] fields = line.split(\"\\t\");\n        if (fields.length != 2) {\n          if (line.startsWith(\"#\")) {\n            continue;\n          } else {\n            throw new RuntimeException(\"Got unsplittable line: \\\"\" + line + '\\\"');\n          }\n        }\n        result.setCount(fields[0], Double.parseDouble(fields[1]));\n      }\n      return result;\n    }\n\n\n  /**\n   * Converts from the format printed by the toString method back into\n   * a Counter&lt;String&gt;.  The toString() doesn't escape, so this only\n   * works providing the keys of the Counter do not have commas or equals signs\n   * in them.\n   *\n   * @param s A String representation of a Counter\n   * @return The Counter\n   */\n  public static ClassicCounter<String> fromString(String s) {","sourceCodeStart":551,"sourceCodeEnd":587,"githubUrl":"https://github.com/stanfordnlp/CoreNLP/blob/1b7edd19c4d0d7b1f13a2591425b9b60a0b1af7a/src/edu/stanford/nlp/stats/ClassicCounter.java#L551-L587","documentation":"ClassicCounter.valueOfIgnoreComments parses a TSV file where each non-comment line must contain exactly two tab-separated fields (key<TAB>count). If a non-comment line does not split into exactly 2 fields, a RuntimeException with the offending line is thrown. Comment lines (starting with '#') are skipped, but only after the split check.","triggerScenarios":"Calling ClassicCounter.valueOfIgnoreComments on a file/lines that contain a line without exactly one tab character; lines using spaces instead of tabs; trailing blank lines or header rows.","commonSituations":"Reading a counts file edited by hand or exported from Excel with space separators; files with CRLF where fields.length checks fail unexpectedly; empty or malformed last line.","solutions":["Inspect the reported line and fix the delimiter to a tab character","Pre-filter lines: skip blank lines and lines starting with '#' before calling the parser","Regenerate the input file with the matching saveCounter/toString output format"],"exampleFix":"// before\nList<String> lines = Arrays.asList(content.split(\"\\n\"));\nClassicCounter<String> c = ClassicCounter.valueOfIgnoreComments(lines);\n// after\nList<String> lines = Arrays.stream(content.split(\"\\n\"))\n    .map(l -> l.replace(\"\\r\", \"\").trim())\n    .filter(l -> !l.isEmpty() && !l.startsWith(\"#\"))\n    .collect(Collectors.toList());\nClassicCounter<String> c = ClassicCounter.valueOfIgnoreComments(lines);","handlingStrategy":"validation","validationCode":"for (String line : lines) {\n  String t = line.replace(\"\\r\", \"\");\n  if (t.isEmpty() || t.startsWith(\"#\")) continue;\n  if (t.split(\"\\t\", -1).length != 2)\n    throw new IllegalArgumentException(\"bad TSV line: \" + t);\n}","typeGuard":null,"tryCatchPattern":"try {\n  c = ClassicCounter.valueOfIgnoreComments(lines);\n} catch (RuntimeException e) {\n  log.error(\"Malformed counter file: {}\", e.getMessage());\n  throw new IOException(\"counter file format invalid\", e);\n}","preventionTips":["Always save counter files with the library's own save methods","Skip blank and '#' lines before parsing","Normalize line endings (CRLF) before parsing"],"tags":["java","parsing","tsv","malformed-input"],"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"}