stanfordnlp/CoreNLP · error · RuntimeException
Error reading saved links
Error message
Error reading saved links
What it means
FromFileCorefAlgorithm reads gold coref merges from a file in its constructor and wraps any IOException in RuntimeException("Error reading saved links"). It treats the merge-link file as mandatory input that must be readable.
Solutions
- Verify the path to the links file is correct and the file exists at runtime (print/resolve the path)
- Run the JVM from a working directory where the relative path resolves correctly, or use an absolute path
- Check file read permissions
- Validate the file format (pairs like 'id1,id2' lines) — malformed content can also trigger the wrapped exception
Example fix
// before
props.setProperty("coref.algorithm.file", "links.txt");
// after
File f = new File("/abs/path/links.txt");
if (!f.canRead()) throw new IllegalArgumentException("links file missing: " + f);
props.setProperty("coref.algorithm.file", f.getAbsolutePath()); Defensive patterns
Strategy: validation
Validate before calling
String linksPath = props.getProperty("coref.algorithm.file", "");
java.io.File f = new java.io.File(linksPath);
if (linksPath.isEmpty() || !f.isFile() || !f.canRead())
throw new IllegalArgumentException("Coref links file not readable: " + f.getAbsolutePath()); Try / catch
try {
FromFileCorefAlgorithm algo = new FromFileCorefAlgorithm(props, dictionaries);
} catch (RuntimeException e) {
if ("Error reading saved links".equals(e.getMessage()))
throw new IllegalStateException("Check coref links file path/contents", e);
throw e;
} Prevention
- Use absolute paths for the links file
- Check file existence and readability at startup, before building the pipeline
- Run the process from a known working directory or resolve paths programmatically
- Validate the file format (integer,id pairs) before use
When it happens
Trigger: Constructing FromFileCorefAlgorithm when the file of saved coref links cannot be opened/read — missing file, wrong path, or unreadable contents (IOException from the readLines/consumer processing).
Common situations: Wrong value for the coref algorithm file property (typo or relative path resolved against unexpected working directory); file deleted or not packaged with the model distribution; running from a different CWD.
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
- edu.stanford.nlp.io.RuntimeIOException
- Error creating data exporter
- Error setting up training
- RuntimeException wrapping IOException
- RuntimeIOException wrapping IOException
AI-assisted analysis of stanfordnlp/CoreNLP@1b7edd19c4 (2026-09-10).
Data as JSON: /api/errors/00e7ccc5393b5f2d.
Report an issue: GitHub.
Appendix: source
Thrown at src/edu/stanford/nlp/coref/misc/FromFileCorefAlgorithm.java:53
String[] split = line.split("\t");
int did = Integer.valueOf(split[0]);
List<Pair<Integer, Integer>> docMerges = toMerge.get(did);
if (docMerges == null) {
docMerges = new ArrayList<>();
toMerge.put(did, docMerges);
}
if (split.length > 1) {
String[] pairs = split[1].split(" ");
for (String pair : pairs) {
String[] ms = pair.split(",");
docMerges.add(new Pair<>(Integer.valueOf(ms[0]), Integer.valueOf(ms[1])));
}
}
});
} catch (IOException e) {
throw new RuntimeException("Error reading saved links", e);
}
}
@Override
public void runCoref(Document document) {
if (toMerge.containsKey(currentDocId)) {
for (Pair<Integer, Integer> pair : toMerge.get(currentDocId)) {
CorefUtils.mergeCoreferenceClusters(pair, document);
}
}
currentDocId += 1;
}
public static void main(String[] args) throws Exception {
Properties props = StringUtils.argsToProperties(new String[] {"-props", args[0]});
new CorefSystem(new DocumentMaker(props, new Dictionaries(props)),
new FromFileCorefAlgorithm(args[1]), true, false).runOnConll(props);
}View on GitHub (pinned to 1b7edd19c4)