stanfordnlp/CoreNLP · warning
ioe
Error message
ioe
What it means
EnglishPTBTreebankCorrector's constructor reads Tsurgeon operation files from the classpath/data path and catches IOException, logging it with log.warn(ioe). The correction operations list is left (partially) empty, so subsequent transformTree calls silently apply fewer corrections than intended.
Solutions
- Verify the Tsurgeon operation files are on the classpath and included in your build/jar (check the stanford-corenlp data resources)
- Run with the correct working directory / ensure paths resolve relative to where the JVM was launched
- Log/inspect the full IOException stack trace (enable debug logging) to identify the exact missing file
- If corrections are optional, accept the warning; otherwise fail fast by rethrowing instead of warn-and-continue
Defensive patterns
Strategy: try-catch
Try / catch
try (InputStream in = getClass().getResourceAsStream(OPS_FILE)) {
if (in == null) throw new FileNotFoundException("missing resource: " + OPS_FILE);
// load operations
} catch (IOException ioe) {
throw new IllegalStateException("Failed to load treebank correction operations", ioe);
} Prevention
- Include all stanford-nlp data resources in your jar/build (shade plugin excludes are a common cause)
- Fail fast on missing correction resources rather than silently degrading transformTree
- Pin and verify your stanford-corenlp artifact contents after upgrading
When it happens
Trigger: Instantiating EnglishPTBTreebankCorrector while its Tsurgeon operation script (and regex file it references) cannot be read — missing resource on classpath, wrong working directory, or corrupted/unreadable data file.
Common situations: Running the English parser pipeline from a jar/classpath layout missing the treebank correction resources; packaging the library without data files; running from a different working directory where relative data paths do not resolve.
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
- Error leading weights from
- Unable to open " " as class path, filename or URL
- No input file provided (use -textFile)
- Error opening output file
- Couldn't read TokensRegexNER from
AI-assisted analysis of stanfordnlp/CoreNLP@1b7edd19c4 (2026-09-10).
Data as JSON: /api/errors/8b649cd2db2387f5.
Report an issue: GitHub.
Appendix: source
Thrown at src/edu/stanford/nlp/trees/treebank/EnglishPTBTreebankCorrector.java:99
try {
BufferedReader br = getBufferedReader(editStr);
List<TsurgeonPattern> tsp = new ArrayList<>();
for (String line; (line = br.readLine()) != null; ) {
TregexPattern matchPattern = tpc.compile(line);
tsp.clear();
if (DEBUG) log.info("Pattern is " + line + " [" + matchPattern + ']');
while (continuing(line = br.readLine())) {
TsurgeonPattern p = Tsurgeon.parseOperation(line);
if (DEBUG) log.info("Operation is " + line + " [" + p + ']');
tsp.add(p);
}
if ( ! tsp.isEmpty()) {
TsurgeonPattern tp = Tsurgeon.collectOperations(tsp);
ops.add(new Pair<>(matchPattern, tp));
}
} // while not at end of file
} catch (IOException ioe) {
log.warn(ioe);
}
}
@Override
public Tree transformTree(Tree t) {
return Tsurgeon.processPatternsOnTree(ops, t);
}
/** Fix all the English Penn Treebank errors, or at least some of them (!).
*/
@Override
public MemoryTreebank transformTrees(Treebank tb) {
MemoryTreebank mtb = new MemoryTreebank(tb.treeReaderFactory(),
tb.encoding());
for (Tree t : tb) {
mtb.add(transformTree(t));
}
return mtb;View on GitHub (pinned to 1b7edd19c4)