stanfordnlp/CoreNLP · error · RuntimeException
Got unsplittable line: "
Error message
Got unsplittable line: "
What it means
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.
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
Example fix
// before
List<String> lines = Arrays.asList(content.split("\n"));
ClassicCounter<String> c = ClassicCounter.valueOfIgnoreComments(lines);
// after
List<String> lines = Arrays.stream(content.split("\n"))
.map(l -> l.replace("\r", "").trim())
.filter(l -> !l.isEmpty() && !l.startsWith("#"))
.collect(Collectors.toList());
ClassicCounter<String> c = ClassicCounter.valueOfIgnoreComments(lines); Defensive patterns
Strategy: validation
Validate before calling
for (String line : lines) {
String t = line.replace("\r", "");
if (t.isEmpty() || t.startsWith("#")) continue;
if (t.split("\t", -1).length != 2)
throw new IllegalArgumentException("bad TSV line: " + t);
} Try / catch
try {
c = ClassicCounter.valueOfIgnoreComments(lines);
} catch (RuntimeException e) {
log.error("Malformed counter file: {}", e.getMessage());
throw new IOException("counter file format invalid", e);
} Prevention
- Always save counter files with the library's own save methods
- Skip blank and '#' lines before parsing
- Normalize line endings (CRLF) before parsing
When it happens
Trigger: 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.
Common situations: 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.
Understand the failure class
Background: "Invalid ... format", "must be in format X", "does not look like a ..." — invalid argument format errors across CLI tools and libraries — this error's family across 17 libraries.
Related errors
- Expected left paren!
- Expected right paren!
- Bad data format:
- Cannot find matching labelled span for
- Error extracting labelled spans for column :
AI-assisted analysis of stanfordnlp/CoreNLP@1b7edd19c4 (2026-09-10).
Data as JSON: /api/errors/05ce133306d0d617.
Report an issue: GitHub.
Appendix: source
Thrown at src/edu/stanford/nlp/stats/ClassicCounter.java:569
* <blockquote>
* StringKey\tdoubleValue\n
* </blockquote>
*
* @param s String representation of a Counter, where entries are one per
* line such that each line is either a comment (begins with #)
* or key \t value
* @return The Counter with String keys
*/
public static ClassicCounter<String> valueOfIgnoreComments(String s) {
ClassicCounter<String> result = new ClassicCounter<>();
String[] lines = s.split("\n");
for (String line : lines) {
String[] fields = line.split("\t");
if (fields.length != 2) {
if (line.startsWith("#")) {
continue;
} else {
throw new RuntimeException("Got unsplittable line: \"" + line + '\"');
}
}
result.setCount(fields[0], Double.parseDouble(fields[1]));
}
return result;
}
/**
* Converts from the format printed by the toString method back into
* a Counter<String>. The toString() doesn't escape, so this only
* works providing the keys of the Counter do not have commas or equals signs
* in them.
*
* @param s A String representation of a Counter
* @return The Counter
*/
public static ClassicCounter<String> fromString(String s) {View on GitHub (pinned to 1b7edd19c4)