{"record":{"id":"70baa12c7b48f86e","repo":"stanfordnlp/CoreNLP","slug":"could-not-read-regex-mapping-mappingfile","errorCode":null,"errorMessage":"Could not read Regex mapping: ${mappingFile}","messagePattern":"Could not read Regex mapping: (.+?)","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"src/edu/stanford/nlp/ie/NERClassifierCombiner.java","lineNumber":403,"sourceCode":"  /**\n   * Read a gazette mapping in TokensRegex format from the given path\n   * The format is: 'case_sensitive_word \\t target_ner_class' (additional info is ignored).\n   *\n   * @param mappingFile The mapping file to read from, as a path either on the filesystem or in your classpath.\n   *\n   * @return The mapping from word to NER tag.\n   */\n  private static Map<String, String> readRegexnerGazette(String mappingFile) {\n    Map<String, String> mapping = new HashMap<>();\n    try (BufferedReader reader = IOUtils.readerFromString(mappingFile.trim())){\n      for (String line : IOUtils.slurpReader(reader).split(\"\\n\")) {\n        String[] fields = line.split(\"\\t\");\n        String key = fields[0];\n        String target = fields[1];\n        mapping.put(key, target);\n      }\n    } catch (IOException e) {\n      log.warn(\"Could not read Regex mapping: \" + mappingFile);\n    }\n    return Collections.unmodifiableMap(mapping);\n  }\n\n\n\n  /** The main method. */\n  public static void main(String[] args) throws Exception {\n    StringUtils.logInvocationString(log, args);\n    Properties props = StringUtils.argsToProperties(args);\n    SeqClassifierFlags flags = new SeqClassifierFlags(props, false); // false for print probs as printed in next code block\n\n    String loadPath = props.getProperty(\"loadClassifier\");\n    NERClassifierCombiner ncc;\n    if (loadPath != null) {\n      // note that when loading a serialized classifier, the philosophy is override\n      // any settings in props with those given in the commandline\n      // so if you dumped it with useSUTime = false, and you say -useSUTime at","sourceCodeStart":385,"sourceCodeEnd":421,"githubUrl":"https://github.com/stanfordnlp/CoreNLP/blob/1b7edd19c4d0d7b1f13a2591425b9b60a0b1af7a/src/edu/stanford/nlp/ie/NERClassifierCombiner.java#L385-L421","documentation":"readRegexnerGazette loads a TSV regexner mapping file line by line (key TAB target). The file could not be read (missing path, unreadable, or IO problem), so the parser logs a warning and returns whatever partial map was accumulated (possibly empty). This is non-fatal by design: the NER pipeline continues with fewer/no regexner entries.","triggerScenarios":"Calling NERClassifierCombiner setup with a regexner.mapping property pointing to a nonexistent, unreadable, or empty file; or a file with a bad encoding/unreadable permissions that throws IOException during readLines.","commonSituations":"Relative path resolved against the wrong working directory when launching from an IDE or service; model jar path typo (resource inside jar not addressable as a file path); file deleted after config was written.","solutions":["Verify the regexner.mapping path exists and is readable from the process working directory (ls -l the file).","Use an absolute path or a classpath-qualified resource URL in the ner.regexner.mapping property.","Check file permissions and that the user running the JVM can read it.","If intentional absence, silence is fine — but confirm the map contents by logging mapping.size() and ensure downstream NER quality is acceptable."],"exampleFix":"// before\nner.regexner.mapping=gazetteers/regexner.txt\n// after\nner.regexner.mapping=/absolute/path/to/gazetteers/regexner.txt","handlingStrategy":"validation","validationCode":"File f = new File(mappingPath);\nif (!f.isFile() || !f.canRead()) {\n  throw new IllegalArgumentException(\"regexner mapping not readable: \" + mappingPath);\n}","typeGuard":null,"tryCatchPattern":"try {\n  Map<String,String> m = readRegexnerGazette(path);\n  if (m.isEmpty()) log.warn(\"regexner map empty — check path \" + path);\n} catch (IOException e) {\n  log.warn(\"falling back to default gazetteer\", e);\n}","preventionTips":["Use absolute paths for mapping files in production configs.","Check file existence/readability at startup before building the pipeline.","Load gazetteer resources via getResourceAsStream when shipping inside a jar."],"tags":["java","io","ner","config"],"backgroundTag":"file-read-failed","analyzedSha":"1b7edd19c4d0d7b1f13a2591425b9b60a0b1af7a","analyzedAt":"2026-09-10T02:24:07.274Z","contentChangedAt":"2026-09-10T02:24:07.274Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}