stanfordnlp/CoreNLP · error · java.lang.IllegalArgumentException

ERROR: Invalid line " + lineCount + " in regexner file " + m

Error message

ERROR: Invalid line " + lineCount + " in regexner file " + mapping + ": \"" + line + "\"!

What it means

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.

Solutions

  1. Open the mapping file, go to the line number in the message, and fix split[3] to be a plain double like 1.0.
  2. If the line should have no priority, remove the 4th column entirely so the line has 3 fields.
  3. Ensure the priority column uses '.' as decimal separator and contains no spaces or non-numeric characters.
  4. Validate the whole file before deployment with a script that checks each 4-field line parses with Double.parseDouble.

Example fix

// before (regexner file, line 42)
MyPattern	LOCATION	O	high
// after
MyPattern	LOCATION	O	1.0
Defensive patterns

Strategy: validation

Validate before calling

// java: validate a regexner mapping file before loading
for (int i = 0; i < lines.size(); i++) {
  String[] split = lines.get(i).split("\\t");
  if (split.length == 4) {
    try { Double.parseDouble(split[3].trim()); }
    catch (NumberFormatException e) {
      throw new IllegalStateException("Bad priority at line " + (i + 1) + ": " + split[3]);
    }
  }
}

Try / catch

try {
  classifier = new RegexNERSequenceClassifier(mapping, ignoreCase, overwrite);
} catch (IllegalArgumentException e) {
  LOG.error("RegexNER mapping invalid: " + e.getMessage());
  classifier = new RegexNERSequenceClassifier(validatedBackupMapping, ignoreCase, overwrite);
}

Prevention

When it happens

Trigger: 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".

Common situations: 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.

Understand the failure class

Background: "Invalid value" and "allowed values are" config errors: what your library rejected and how to fix it — this error's family across 41 libraries.

Related errors


AI-assisted analysis of stanfordnlp/CoreNLP@1b7edd19c4 (2026-09-10). Data as JSON: /api/errors/0214f0206f89870d. Report an issue: GitHub.

Appendix: source

Thrown at src/edu/stanford/nlp/ie/regexp/RegexNERSequenceClassifier.java:302

        throw new IllegalArgumentException("Provided mapping file is in wrong format: " + line);

      String[] regexes = split[0].trim().split("\\s+");
      String type = split[1].trim();
      Set<String> overwritableTypes = Generics.newHashSet();
      double priority = 0.0;
      List<Pattern> tokens = new ArrayList<>();

      if (split.length >= 3) {
        overwritableTypes.addAll(Arrays.asList(split[2].trim().split(",")));
      }
      // by default, always consider overwriting the background symbol
      overwritableTypes.add("O");

      if (split.length == 4) {
        try {
          priority = Double.parseDouble(split[3].trim());
        } catch(NumberFormatException e) {
          throw new IllegalArgumentException("ERROR: Invalid line " + lineCount + " in regexner file " + mapping + ": \"" + line + "\"!", e);
        }
      }

      try {
        for (String str : regexes) {
          if(ignoreCase) tokens.add(Pattern.compile(str, Pattern.CASE_INSENSITIVE | Pattern.UNICODE_CASE));
          else tokens.add(Pattern.compile(str));
        }
      } catch (PatternSyntaxException e) {
        throw new IllegalArgumentException("ERROR: Invalid line " + lineCount + " in regexner file " + mapping + ": \"" + line + "\"!", e);
      }

      entries.add(new Entry(tokens, type, overwritableTypes, priority));
    }

    Collections.sort(entries);
    // log.info("Read these entries:");
    // log.info(entries);

View on GitHub (pinned to 1b7edd19c4)