{"record":{"id":"54422969509f4f15","repo":"stanfordnlp/CoreNLP","slug":"couldn-t-read-regexner-from-mapping","errorCode":null,"errorMessage":"Couldn't read RegexNER from \" + mapping","messagePattern":"Couldn't read RegexNER from \" \\+ mapping","errorType":"exception","errorClass":"edu.stanford.nlp.util.RuntimeIOException","httpStatus":null,"severity":"error","filePath":"src/edu/stanford/nlp/ie/regexp/RegexNERSequenceClassifier.java","lineNumber":115,"sourceCode":"   *                          RegexNERSequenceClassifier is run successively over the same\n   *                          text (e.g., to overwrite some older annotations).\n   * @param validPosRegex May be null or an empty String, in which case any (or no) POS is valid\n   *                      in matching. Otherwise, this is a regex which is matched with find()\n   *                      [not matches()] and which must be matched by the POS of at least one\n   *                      word in the sequence for it to be labeled via any matching rules.\n   *                      (Note that this is a postfilter; using this will not speed up matching.)\n   */\n  public RegexNERSequenceClassifier(String mapping, boolean ignoreCase, boolean overwriteMyLabels, String validPosRegex) {\n    super(new Properties());\n    if (validPosRegex != null && !validPosRegex.equals(\"\")) {\n      validPosPattern = Pattern.compile(validPosRegex);\n    } else {\n      validPosPattern = null;\n    }\n    try (BufferedReader rd = IOUtils.readerFromString(mapping)) {\n      entries = readEntries(rd, ignoreCase);\n    } catch (IOException e) {\n      throw new RuntimeIOException(\"Couldn't read RegexNER from \" + mapping, e);\n    }\n\n    this.ignoreCase = ignoreCase;\n    myLabels = Generics.newHashSet();\n    // Can always override background or none.\n    myLabels.add(flags.backgroundSymbol);\n    myLabels.add(null);\n    if (overwriteMyLabels) {\n      for (Entry entry: entries) myLabels.add(entry.type);\n    }\n    // log.info(\"RegexNER using labels: \" +  myLabels);\n  }\n\n  /**\n   * Make a new instance of this classifier. The ignoreCase option allows case-insensitive\n   * regular expression matching, allowing the idea that the provided file might just\n   * be a manual list of the possible entities for each type.\n   *","sourceCodeStart":97,"sourceCodeEnd":133,"githubUrl":"https://github.com/stanfordnlp/CoreNLP/blob/1b7edd19c4d0d7b1f13a2591425b9b60a0b1af7a/src/edu/stanford/nlp/ie/regexp/RegexNERSequenceClassifier.java#L97-L133","documentation":"The string-mapping constructor of RegexNERSequenceClassifier opens the mapping (file path or classpath resource) with IOUtils.readerFromString; any IOException while opening or reading it is rethrown as RuntimeIOException with this message. Without the mapping entries, the classifier cannot be constructed.","triggerScenarios":"Constructing RegexNERSequenceClassifier (or setting regexner.mapping in a pipeline) with a path that doesn't exist, isn't readable, or isn't a valid classpath reference.","commonSituations":"Relative path that breaks when the pipeline runs from a different working directory, mapping resource missing from the jar, typo in the property regexner.mapping, or permission problems.","solutions":["Verify the mapping path exists and is readable; use an absolute path.","If it's a classpath resource, ensure it's packaged and the resource string is correct.","Validate the mapping file format (regex<TAB>type[<TAB>overwritable][<TAB>priority]) — malformed parse content can also surface as IOException in readEntries.","Check the wrapped IOException cause for the exact failure."],"exampleFix":"// before\nprops.setProperty(\"regexner.mapping\", \"my_rules.txt\");\n// after\nprops.setProperty(\"regexner.mapping\", \"/etc/stanford/my_rules.txt\");","handlingStrategy":"validation","validationCode":"Path mapping = Paths.get(mappingPath);\nif (!Files.isReadable(mapping))\n  throw new IllegalArgumentException(\"regexner mapping not readable: \" + mappingPath);\n// optional: validate format lines\nlong bad = Files.lines(mapping).filter(l -> !l.trim().isEmpty() && !l.startsWith(\"#\"))\n    .filter(l -> { String[] p = l.split(\"\\t\"); return p.length < 2 || p.length > 4; }).count();\nif (bad > 0) throw new IllegalStateException(bad + \" malformed mapping lines\");","typeGuard":null,"tryCatchPattern":"try {\n  classifier = new RegexNERSequenceClassifier(props, mapping, true, false);\n} catch (RuntimeIOException e) {\n  log.severe(\"RegexNER mapping unreadable: \" + mapping + \" cause: \" + e.getCause());\n  throw e;\n}","preventionTips":["Use absolute paths or verified classpath resources for regexner.mapping.","Validate mapping file format before pipeline construction.","Include mapping files in CI artifact checks."],"tags":["io","configuration","regexner","file-not-found"],"backgroundTag":"file-not-found","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"}