stanfordnlp/CoreNLP · error · edu.stanford.nlp.util.RuntimeIOException
Error reading threshold file
Error message
Error reading threshold file
What it means
When reading the thresholds file, any IOException is wrapped and rethrown as RuntimeIOException with message 'Error reading threshold file', preserving the cause. The threshold file path comes from the classifier's flags, so a bad path or unreadable file surfaces here.
Solutions
- Check the file exists and is readable (Files.isReadable) before training/semi-supervised runs
- Correct the thresholds-file flag/property to the absolute path of the real file
- Copy the thresholds file alongside the serialized model
- Inspect the wrapped cause (e.getCause()) to distinguish missing file vs parse failure
Example fix
// before
String path = "thresholds.txt"; // not present in CWD -> RuntimeIOException
// after
String path = "/models/eng/thresholds.txt";
if (!new File(path).canRead()) throw new IllegalStateException("Thresholds file missing: " + path); Defensive patterns
Strategy: try-catch
Validate before calling
File f = new File(thresholdsPath);
if (!f.isFile() || !f.canRead()) throw new IllegalStateException("Thresholds file missing/unreadable: " + f); Try / catch
try { thresholds = loadThresholds(); } catch (RuntimeIOException e) { throw new IllegalStateException("Fix thresholds file path: " + thresholdsPath, e); } Prevention
- Ship the thresholds file together with the serialized model
- Use absolute paths for the thresholds flag
- Check the wrapped cause for the underlying IOException
When it happens
Trigger: trainSemiSup / threshold-loading path where the thresholds file path (flags.thresholdsFile or equivalent) does not exist, is a directory, or cannot be read due to permissions; also truncated/corrupt files causing parse IOExceptions.
Common situations: Copying a serialized classifier without the thresholds file; relative path resolved against the wrong working directory; read-protected file in a cluster environment; misconfigured flag after a model move.
Understand the failure class
Background: "failed to read file", EACCES, ENOENT and "could not read <path>" errors: when a program can't read a file from disk — this error's family across 49 libraries.
Related errors
- TokensRegexNERAnnotator
- IOException reading CEDict from file
- propFileToProperties could not read properties file: " +…
- Could not read Regex mapping
- Error loading classifier from
AI-assisted analysis of stanfordnlp/CoreNLP@1b7edd19c4 (2026-09-10).
Data as JSON: /api/errors/a396808605b839db.
Report an issue: GitHub.
Appendix: source
Thrown at src/edu/stanford/nlp/ie/ner/CMMClassifier.java:1309
private static List<Pair<Pattern, Integer>> getThresholds(String filename) {
BufferedReader in = null;
try {
in = IOUtils.readerFromString(filename);
List<Pair<Pattern, Integer>> thresholds = new ArrayList<>();
for (String line; (line = in.readLine()) != null; ) {
int i = line.lastIndexOf(' ');
Pattern p = Pattern.compile(line.substring(0, i));
//log.info(":"+line.substring(0,i)+":");
Integer t = Integer.valueOf(line.substring(i + 1));
Pair<Pattern, Integer> pair = new Pair<>(p, t);
thresholds.add(pair);
}
in.close();
return thresholds;
} catch (IOException e) {
throw new RuntimeIOException("Error reading threshold file", e);
} finally {
IOUtils.closeIgnoringExceptions(in);
}
}
public void trainSemiSup() {
DocumentReaderAndWriter<IN> readerAndWriter = makeReaderAndWriter();
String filename = flags.trainFile;
String biasedFilename = flags.biasedTrainFile;
ObjectBank<List<IN>> data =
makeObjectBankFromFile(filename, readerAndWriter);
ObjectBank<List<IN>> biasedData =
makeObjectBankFromFile(biasedFilename, readerAndWriter);
Index<String> featureIndex = new HashIndex<>();
Index<String> classIndex = new HashIndex<>();View on GitHub (pinned to 1b7edd19c4)