{"record":{"id":"60539a51ef5a06bf","repo":"stanfordnlp/CoreNLP","slug":"tokensregexnerannotator-error-line-of-provided-m","errorCode":null,"errorMessage":"TokensRegexNERAnnotator ERROR: Line  of provided mapping file has too  tab-separated columns ( expecting ). Line: ","messagePattern":"TokensRegexNERAnnotator ERROR: Line  of provided mapping file has too  tab-separated columns \\( expecting \\)\\. Line: ","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"src/edu/stanford/nlp/pipeline/TokensRegexNERAnnotator.java","lineNumber":727,"sourceCode":"          if (equals) {\n            //This is the header line -> skip\n            continue;\n          }\n        }\n      }\n\n      if (split.length < minLength || split.length > maxLength) {\n        String err = \"many\";\n        String expect = \"<= \" + maxLength;\n        String extra = \"\";\n        if (split.length < minLength) {\n          err = \"few\";\n          expect = \">= \" + minLength;\n          if (split.length == 1) {\n            extra = \"Maybe the problem is that you are using spaces not tabs? \";\n          }\n        }\n        throw new IllegalArgumentException(\"TokensRegexNERAnnotator \" + annotatorName +\n                \" ERROR: Line \" + lineCount + \" of provided mapping file has too \" + err +\n                \" tab-separated columns (\" + split.length + \" expecting \" + expect + \"). \" + extra + \"Line: \" + line);\n      }\n      String regex = split[iPattern].trim();\n      String tokensRegex = null;\n      String[] regexes = null;\n      if (regex.startsWith(\"( \") && regex.endsWith(\" )\")) {\n        // Tokens regex (remove start and end parenthesis)\n        tokensRegex = regex.substring(1,regex.length()-1).trim();\n      } else {\n        regexes = regex.split(\"\\\\s+\");\n      }\n      String[] key = (regexes != null)? regexes: new String[] { tokensRegex };\n      if (ignoreCase) {\n        String[] norm = new String[key.length];\n        for (int i = 0; i < key.length; i++) {\n          norm[i] = key[i].toLowerCase();\n        }","sourceCodeStart":709,"sourceCodeEnd":745,"githubUrl":"https://github.com/stanfordnlp/CoreNLP/blob/1b7edd19c4d0d7b1f13a2591425b9b60a0b1af7a/src/edu/stanford/nlp/pipeline/TokensRegexNERAnnotator.java#L709-L745","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"// before (spaces, splits to 1 column)\n[ { word:/CEO/ } ] PERSON\n// after (tabs)\n[ { word:/CEO/ } ]\tPERSON","handlingStrategy":"validation","validationCode":"int expected = headerColumns;\nfor (int i = 0; i < lines.length; i++) {\n  int n = lines[i].split(\"\\t\", -1).length;\n  if (n < minRequired || n > expected) throw new IllegalStateException(\"Line \" + (i+1) + \" has \" + n + \" columns, expected \" + expected);\n}","typeGuard":null,"tryCatchPattern":"try { annotator = new TokensRegexNERAnnotator(name, props); } catch (IllegalArgumentException e) { if (e.getMessage().contains(\"tab-separated columns\")) { reportBadLine(e.getMessage()); } else throw e; }","preventionTips":["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"],"tags":["nlp","mapping-file","format-validation","whitespace"],"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-17T15:17:12.973Z"}