{"record":{"id":"5b125111a2840ef7","repo":"stanfordnlp/CoreNLP","slug":"provided-mapping-file-is-in-wrong-format-line","errorCode":null,"errorMessage":"Provided mapping file is in wrong format: \" + line","messagePattern":"Provided mapping file is in wrong format: \" \\+ line","errorType":"exception","errorClass":"java.lang.IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"src/edu/stanford/nlp/ie/regexp/RegexNERSequenceClassifier.java","lineNumber":284,"sourceCode":"   *  Creates a combined list of Entries using the provided mapping file, and sorts them by\n   *  first by priority, then the number of tokens in the regex.\n   *\n   *  @param mapping The Reader containing RegexNER mappings. It's lines are counted from 1\n   *  @return a sorted list of Entries\n   */\n  private static List<Entry> readEntries(BufferedReader mapping, boolean ignoreCase) throws IOException {\n    List<Entry> entries = new ArrayList<>();\n\n    int lineCount = 0;\n    for (String line; (line = mapping.readLine()) != null; ) {\n      lineCount ++;\n      // skip blank lines\n      if (line.trim().equals(\"\"))\n        continue;\n\n      String[] split = line.split(\"\\t\");\n      if (split.length < 2 || split.length > 4)\n        throw new IllegalArgumentException(\"Provided mapping file is in wrong format: \" + line);\n\n      String[] regexes = split[0].trim().split(\"\\\\s+\");\n      String type = split[1].trim();\n      Set<String> overwritableTypes = Generics.newHashSet();\n      double priority = 0.0;\n      List<Pattern> tokens = new ArrayList<>();\n\n      if (split.length >= 3) {\n        overwritableTypes.addAll(Arrays.asList(split[2].trim().split(\",\")));\n      }\n      // by default, always consider overwriting the background symbol\n      overwritableTypes.add(\"O\");\n\n      if (split.length == 4) {\n        try {\n          priority = Double.parseDouble(split[3].trim());\n        } catch(NumberFormatException e) {\n          throw new IllegalArgumentException(\"ERROR: Invalid line \" + lineCount + \" in regexner file \" + mapping + \": \\\"\" + line + \"\\\"!\", e);","sourceCodeStart":266,"sourceCodeEnd":302,"githubUrl":"https://github.com/stanfordnlp/CoreNLP/blob/1b7edd19c4d0d7b1f13a2591425b9b60a0b1af7a/src/edu/stanford/nlp/ie/regexp/RegexNERSequenceClassifier.java#L266-L302","documentation":"RegexNERSequenceClassifier.readEntries parses each non-blank mapping line as TAB-separated fields: regex (1-3 columns accepted: 2 to 4 total fields — regex, type, optional overwritable types, optional priority). A line whose field count is outside 2-4 triggers this IllegalArgumentException, identifying the offending line.","triggerScenarios":"Loading a regexner mapping file containing lines with fewer than 2 or more than 4 tab-separated fields — e.g. lines with no type column, comment/header lines not starting with '#', spaces used instead of tabs, or stray tabs in descriptions.","commonSituations":"Hand-edited or CSV-exported rule files using spaces instead of tabs, Excel/Sheets exports introducing extra columns, Windows line endings with embedded tabs, or documentation example lines left in the file.","solutions":["Ensure each line has exactly 2-4 TAB-separated fields: regex, type, optional overwrite list, optional priority.","Replace space separators with real tab characters (awk -F'\\t' 'NF<2||NF>4' file to find bad lines).","Comment out or remove non-conforming lines (comments must start with #).","Check for double tabs or trailing tab characters creating empty extra fields."],"exampleFix":"// before (spaces, no type column)\nApple Inc is_a_company\n// after (tabs, regex + type)\nApple\\s+Inc\\tORGANIZATION","handlingStrategy":"validation","validationCode":"// lint mapping lines before loading\ntry (Stream<String> lines = Files.lines(Paths.get(mappingPath))) {\n  List<String> bad = lines.filter(l -> !l.trim().isEmpty() && !l.startsWith(\"#\"))\n      .filter(l -> { String[] p = l.split(\"\\t\", -1); return p.length < 2 || p.length > 4; })\n      .collect(Collectors.toList());\n  if (!bad.isEmpty()) throw new IllegalStateException(\"Bad mapping lines: \" + bad);\n}","typeGuard":null,"tryCatchPattern":"try {\n  classifier = new RegexNERSequenceClassifier(props, mapping, true, false);\n} catch (IllegalArgumentException e) {\n  if (e.getMessage().startsWith(\"Provided mapping file is in wrong format\")) {\n    log.severe(\"Fix mapping line: \" + e.getMessage());\n  }\n  throw e;\n}","preventionTips":["Author mapping files with real tab separators (spaces don't count).","Run a lint pass (field count check) in CI for mapping files.","Keep line format: regex<TAB>type[<TAB>overwritable][<TAB>priority].","Strip headers/extra columns from spreadsheet exports."],"tags":["mapping-file","format-validation","regexner","parsing"],"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"}