stanfordnlp/CoreNLP · error · RuntimeException
Could not find either " + binaryName + " or " + textName
Error message
Could not find either " + binaryName + " or " + textName
What it means
ConvertMatlabModel.loadMatrix looks for a matrix file in binary (binaryName) or text (textName) form under the base path; if neither file exists it throws RuntimeException. It is a hard failure because the model cannot be converted without the source matrix data.
Solutions
- Place the matrix files (binary or text) under the expected basePath with the expected names
- Edit the basePath/naming in ConvertMatlabModel (or its caller) to point at where your files actually are
- Check file existence and permissions before running, e.g. ls the directory
Example fix
// before String basePath = "/user/socherr/scr/projects/semComp/RNTN/src/params/"; // after String basePath = "/data/rntn/params/"; // actual location of W.txt, U.txt etc.
Defensive patterns
Strategy: validation
Validate before calling
for (String name : new String[]{"W", "Wcat", "U", "combinedWV"}) {
File bin = new File(basePath, name + binaryExt);
File txt = new File(basePath, name + ".txt");
if (!bin.exists() && !txt.exists()) throw new FileNotFoundException(name + " missing in " + basePath);
} Type guard
static boolean matrixAvailable(String base, String name) {
return new File(base, name + ".bin").exists() || new File(base, name + ".txt").exists();
} Try / catch
try {
ConvertMatlabModel.main(args);
} catch (RuntimeException e) {
log.error("Model matrix files missing: " + e.getMessage());
} Prevention
- Replace the hard-coded basePath with a configurable path/argument
- Verify all expected matrix files exist before running conversion
- Copy model parameter files alongside the code when moving machines
When it happens
Trigger: Calling loadMatrix (directly or via main/W/Wcat/combinedWV conversion) with a basePath or matrix name where neither <name>.bin-style binary file nor the text file exists.
Common situations: Hard-coded basePath (/user/socherr/scr/...) pointing to a path that does not exist on your machine; wrong matrix name; data files not copied along with the code.
Understand the failure class
Background: "File not found" and ENOENT errors: why libraries can't find a file that should exist — this error's family across 50 libraries.
Related errors
- No model specified for Sentiment annotator
- Can only create a model using this method if…
- Cannot create random word vectors for an unknown numHid
- Error reading threshold file
- Found line with label " + line + " but no tokens to…
AI-assisted analysis of stanfordnlp/CoreNLP@1b7edd19c4 (2026-09-10).
Data as JSON: /api/errors/360c91f2b01b33db.
Report an issue: GitHub.
Appendix: source
Thrown at src/edu/stanford/nlp/sentiment/ConvertMatlabModel.java:66
if (!wordVectors.containsKey(source)) {
return;
}
wordVectors.put(target, new SimpleMatrix(wordVectors.get(source)));
}
public static SimpleMatrix loadMatrix(String binaryName, String textName) throws IOException {
File matrixFile = new File(binaryName);
if (matrixFile.exists()) {
return SimpleMatrix.loadBinary(matrixFile.getPath());
}
matrixFile = new File(textName);
if (matrixFile.exists()) {
return NeuralUtils.loadTextMatrix(matrixFile);
}
throw new RuntimeException("Could not find either " + binaryName + " or " + textName);
}
public static void main(String[] args) throws IOException {
String basePath = "/user/socherr/scr/projects/semComp/RNTN/src/params/";
int numSlices = 25;
boolean useEscapedParens = false;
for (int argIndex = 0; argIndex < args.length; ) {
if (args[argIndex].equalsIgnoreCase("-slices")) {
numSlices = Integer.parseInt(args[argIndex + 1]);
argIndex += 2;
} else if (args[argIndex].equalsIgnoreCase("-path")) {
basePath = args[argIndex + 1];
argIndex += 2;
} else if (args[argIndex].equalsIgnoreCase("-useEscapedParens")) {
useEscapedParens = true;
argIndex += 1;View on GitHub (pinned to 1b7edd19c4)