{"record":{"id":"8247000519c95a0c","repo":"stanfordnlp/CoreNLP","slug":"error-loading-prefixes-from-options-prefixfile","errorCode":null,"errorMessage":"Error loading prefixes from \" + options.prefixFilename","messagePattern":"Error loading prefixes from \" \\+ options\\.prefixFilename","errorType":"exception","errorClass":"java.lang.RuntimeException","httpStatus":null,"severity":"error","filePath":"src/edu/stanford/nlp/ie/qe/QuantifiableEntityExtractor.java","lineNumber":77,"sourceCode":"    return CoreMapExpressionExtractor.createExtractorFromFiles(env, filenames);\n  }\n\n  private void initEnv() {\n    env = TokenSequencePattern.getNewEnv();\n    env.setDefaultTokensAnnotationKey(CoreAnnotations.NumerizedTokensAnnotation.class);\n\n    // Do case insensitive matching\n    env.setDefaultStringMatchFlags(Pattern.CASE_INSENSITIVE | Pattern.UNICODE_CASE);\n    env.setDefaultStringPatternFlags(Pattern.CASE_INSENSITIVE | Pattern.UNICODE_CASE);\n    try {\n      Units.registerUnits(env, options.unitsFilename);\n    } catch (IOException ex)  {\n      throw new RuntimeException(\"Error loading units from \" + options.unitsFilename, ex);\n    }\n    try {\n      UnitPrefix.registerPrefixes(env, options.prefixFilename);\n    } catch (IOException ex)  {\n      throw new RuntimeException(\"Error loading prefixes from \" + options.prefixFilename, ex);\n    }\n    env.bind(\"options\", options);\n\n    env.bind(\"numcomptype\", CoreAnnotations.NumericCompositeTypeAnnotation.class);\n    env.bind(\"numcompvalue\", CoreAnnotations.NumericCompositeValueAnnotation.class);\n  }\n\n  private static void generatePrefixDefs(String infile, String outfile) throws IOException {\n    List<UnitPrefix> prefixes = UnitPrefix.loadPrefixes(infile);\n    PrintWriter pw = IOUtils.getPrintWriter(outfile);\n    pw.println(\"SI_PREFIX_MAP = {\");\n    List<String> items = new ArrayList<>();\n    for (UnitPrefix prefix : prefixes) {\n      if (\"SI\".equals(prefix.system)) {\n        items.add(\"\\\"\" + prefix.name + \"\\\": \" + prefix.getName().toUpperCase());\n      }\n    }\n    pw.println(StringUtils.join(items, \",\\n\"));","sourceCodeStart":59,"sourceCodeEnd":95,"githubUrl":"https://github.com/stanfordnlp/CoreNLP/blob/1b7edd19c4d0d7b1f13a2591425b9b60a0b1af7a/src/edu/stanford/nlp/ie/qe/QuantifiableEntityExtractor.java#L59-L95","documentation":"QuantifiableEntityExtractor.initEnv calls UnitPrefix.registerPrefixes(env, options.prefixFilename); an IOException reading that file is wrapped in a RuntimeException naming the prefix file. Unit prefix definitions (kilo, milli, etc.) are mandatory for quantity extraction, so init fails fast.","triggerScenarios":"Initializing the QE extractor with options.prefixFilename pointing to a missing/unreadable/malformed prefixes file.","commonSituations":"Missing QE models/resources directory, wrong working directory when launching the pipeline, or resource files not packaged in the jar.","solutions":["Verify options.prefixFilename resolves correctly; use an absolute path.","Check file existence/readability before constructing the extractor.","Include the prefixes file in the deployment and reference it via classpath.","Inspect the wrapped IOException cause for the underlying read error."],"exampleFix":"// before\nprops.setProperty(\"qe.prefixFile\", \"prefixes.txt\");\n// after\nprops.setProperty(\"qe.prefixFile\", \"/opt/models/qe/prefixes.txt\");","handlingStrategy":"validation","validationCode":"File prefixes = new File(options.prefixFilename);\nif (!prefixes.isFile() || !prefixes.canRead())\n  throw new IllegalArgumentException(\"Prefix file missing/unreadable: \" + options.prefixFilename);","typeGuard":null,"tryCatchPattern":"try {\n  extractor.init(props);\n} catch (RuntimeException e) {\n  if (e.getMessage().startsWith(\"Error loading prefixes from\")) {\n    log.severe(\"Fix qe prefix path: \" + e.getCause());\n  }\n  throw e;\n}","preventionTips":["Deploy the QE models/resources directory and point options at absolute paths.","Check both units and prefix files together; they ship as a pair.","Verify file permissions for the runtime user."],"tags":["io","configuration","resource-loading","qe"],"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-17T15:17:12.973Z"}