stanfordnlp/CoreNLP · error · IllegalArgumentException
TokensRegexNERAnnotator ERROR: Line of provided mapping…
Error message
TokensRegexNERAnnotator ERROR: Line of provided mapping file has too tab-separated columns ( expecting ). Line:
What it means
Each data line in the mapping file must have the number of tab-separated columns implied by the header (at least the pattern and annotation columns, at most all header columns). Lines with too few or too many columns throw IllegalArgumentException reporting the line number, actual and expected counts, and the offending line text.
Solutions
- Re-save the mapping file using real tab characters (\t) between all columns.
- Count columns on the offending line against the header and fix missing or extra fields.
- Check the error text: 'few' with the 'spaces not tabs?' hint means convert spaces to tabs.
- Strip trailing tabs/whitespace from lines and remove blank or malformed rows.
Example fix
// before (spaces, splits to 1 column)
[ { word:/CEO/ } ] PERSON
// after (tabs)
[ { word:/CEO/ } ] PERSON Defensive patterns
Strategy: validation
Validate before calling
int expected = headerColumns;
for (int i = 0; i < lines.length; i++) {
int n = lines[i].split("\t", -1).length;
if (n < minRequired || n > expected) throw new IllegalStateException("Line " + (i+1) + " has " + n + " columns, expected " + expected);
} Try / catch
try { annotator = new TokensRegexNERAnnotator(name, props); } catch (IllegalArgumentException e) { if (e.getMessage().contains("tab-separated columns")) { reportBadLine(e.getMessage()); } else throw e; } Prevention
- Edit mapping files only in editors that preserve tabs; show whitespace characters
- Convert from CSV with an explicit comma-to-tab step and verify column counts
- Run a pre-load linter over mapping files in CI
- Avoid manual copy-paste of rows from docs; regenerate rows with a script
When it happens
Trigger: A mapping row uses spaces instead of tabs so it splits into a single column; a row has stray/unescaped tabs producing extra columns; a row omits required columns like the ner value.
Common situations: Editing mapping files in editors that silently convert tabs to spaces; copying rows from documentation where tabs became spaces; trailing tabs from copy-paste; CSV-comma-separated files supplied instead of tab-separated.
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
- Couldn't read TokensRegexNER from
- DocDate mapping file failed to match against
- Duplicate header field:
- Invalid match group for entry
- Provided mapping file is in wrong format: " + line
AI-assisted analysis of stanfordnlp/CoreNLP@1b7edd19c4 (2026-09-10).
Data as JSON: /api/errors/60539a51ef5a06bf.
Report an issue: GitHub.
Appendix: source
Thrown at src/edu/stanford/nlp/pipeline/TokensRegexNERAnnotator.java:727
if (equals) {
//This is the header line -> skip
continue;
}
}
}
if (split.length < minLength || split.length > maxLength) {
String err = "many";
String expect = "<= " + maxLength;
String extra = "";
if (split.length < minLength) {
err = "few";
expect = ">= " + minLength;
if (split.length == 1) {
extra = "Maybe the problem is that you are using spaces not tabs? ";
}
}
throw new IllegalArgumentException("TokensRegexNERAnnotator " + annotatorName +
" ERROR: Line " + lineCount + " of provided mapping file has too " + err +
" tab-separated columns (" + split.length + " expecting " + expect + "). " + extra + "Line: " + line);
}
String regex = split[iPattern].trim();
String tokensRegex = null;
String[] regexes = null;
if (regex.startsWith("( ") && regex.endsWith(" )")) {
// Tokens regex (remove start and end parenthesis)
tokensRegex = regex.substring(1,regex.length()-1).trim();
} else {
regexes = regex.split("\\s+");
}
String[] key = (regexes != null)? regexes: new String[] { tokensRegex };
if (ignoreCase) {
String[] norm = new String[key.length];
for (int i = 0; i < key.length; i++) {
norm[i] = key[i].toLowerCase();
}View on GitHub (pinned to 1b7edd19c4)