{"record":{"id":"0214f0206f89870d","repo":"stanfordnlp/CoreNLP","slug":"error-invalid-line-linecount-in-regexner","errorCode":null,"errorMessage":"ERROR: Invalid line \" + lineCount + \" in regexner file \" + mapping + \": \\\"\" + line + \"\\\"!","messagePattern":"ERROR: Invalid line \" \\+ lineCount \\+ \" in regexner file \" \\+ mapping \\+ \": \\\\\"\" \\+ line \\+ \"\\\\\"!","errorType":"exception","errorClass":"java.lang.IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"src/edu/stanford/nlp/ie/regexp/RegexNERSequenceClassifier.java","lineNumber":302,"sourceCode":"        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);\n        }\n      }\n\n      try {\n        for (String str : regexes) {\n          if(ignoreCase) tokens.add(Pattern.compile(str, Pattern.CASE_INSENSITIVE | Pattern.UNICODE_CASE));\n          else tokens.add(Pattern.compile(str));\n        }\n      } catch (PatternSyntaxException e) {\n        throw new IllegalArgumentException(\"ERROR: Invalid line \" + lineCount + \" in regexner file \" + mapping + \": \\\"\" + line + \"\\\"!\", e);\n      }\n\n      entries.add(new Entry(tokens, type, overwritableTypes, priority));\n    }\n\n    Collections.sort(entries);\n    // log.info(\"Read these entries:\");\n    // log.info(entries);","sourceCodeStart":284,"sourceCodeEnd":320,"githubUrl":"https://github.com/stanfordnlp/CoreNLP/blob/1b7edd19c4d0d7b1f13a2591425b9b60a0b1af7a/src/edu/stanford/nlp/ie/regexp/RegexNERSequenceClassifier.java#L284-L320","documentation":"RegexNERSequenceClassifier.readEntries parses a TSV mapping file of regex rules and throws this IllegalArgumentException when the optional 4th column (priority) cannot be parsed as a double. The mapping file is the model input for rule-based NER, so a malformed numeric field makes the whole file unloadable. The original line and its number are included to let the user locate and fix the bad row.","triggerScenarios":"Calling new RegexNERSequenceClassifier(mapping, ...) where a line in the mapping file has 4 tab-separated fields but split[3] is not a valid double, e.g. \"high\" or \"1.5.2\" instead of \"1.0\".","commonSituations":"Hand-edited RegexNER mapping files where a priority was typed as text or with a stray character; files exported from spreadsheets with locale-formatted decimals (comma as decimal separator); copy-paste artifacts such as trailing spaces in the wrong column or a tab accidentally splitting the priority field.","solutions":["Open the mapping file, go to the line number in the message, and fix split[3] to be a plain double like 1.0.","If the line should have no priority, remove the 4th column entirely so the line has 3 fields.","Ensure the priority column uses '.' as decimal separator and contains no spaces or non-numeric characters.","Validate the whole file before deployment with a script that checks each 4-field line parses with Double.parseDouble."],"exampleFix":"// before (regexner file, line 42)\nMyPattern\tLOCATION\tO\thigh\n// after\nMyPattern\tLOCATION\tO\t1.0","handlingStrategy":"validation","validationCode":"// java: validate a regexner mapping file before loading\nfor (int i = 0; i < lines.size(); i++) {\n  String[] split = lines.get(i).split(\"\\\\t\");\n  if (split.length == 4) {\n    try { Double.parseDouble(split[3].trim()); }\n    catch (NumberFormatException e) {\n      throw new IllegalStateException(\"Bad priority at line \" + (i + 1) + \": \" + split[3]);\n    }\n  }\n}","typeGuard":null,"tryCatchPattern":"try {\n  classifier = new RegexNERSequenceClassifier(mapping, ignoreCase, overwrite);\n} catch (IllegalArgumentException e) {\n  LOG.error(\"RegexNER mapping invalid: \" + e.getMessage());\n  classifier = new RegexNERSequenceClassifier(validatedBackupMapping, ignoreCase, overwrite);\n}","preventionTips":["Keep priorities in a fixed numeric format (e.g. 1.0) and validate files in CI before deployment.","Never hand-edit production mapping files without a numeric-format check.","Watch for spreadsheet locale decimal commas when exporting TSV mappings."],"tags":["java","config-file","number-format","nlp"],"backgroundTag":"invalid-config-value","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"}