stanfordnlp/CoreNLP · error · RuntimeIOException
Error in LinearClassifierFactory, loading from file=
Error message
Error in LinearClassifierFactory, loading from file=${file} What it means
Generic wrapper error from LinearClassifierFactory.loadFromFilename: any IOException or parse failure while reading a text-serialized LinearClassifier (missing file, bad number format, unexpected EOF) is rethrown with the file name attached.
Solutions
- Confirm the file path and format (label index, feature index, weights, thresholds)
- Ensure the file was written by saveToFilename in the same version
- Catch and fall back to a default or retrained model
Defensive patterns
Strategy: fallback
When it happens
Trigger: Thrown at src/edu/stanford/nlp/classify/LinearClassifierFactory.java:987 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of stanfordnlp/CoreNLP@1b7edd19c4 (2026-09-10).
Data as JSON: /api/errors/483e7cd4cd7d3d49.
Report an issue: GitHub.
Appendix: source
Thrown at src/edu/stanford/nlp/classify/LinearClassifierFactory.java:987
int label = Integer.parseInt(tuples[1]);
double value = Double.parseDouble(tuples[2]);
weights[feature][label] = value;
line = in.readLine();
}
// First line in thresholds is the number of thresholds
int numThresholds = Integer.parseInt(in.readLine());
double[] thresholds = new double[numThresholds];
int curr = 0;
while ((line = in.readLine()) != null) {
double tval = Double.parseDouble(line.trim());
thresholds[curr++] = tval;
}
in.close();
LinearClassifier<String, String> classifier = new LinearClassifier<>(weights, featureIndex, labelIndex);
return classifier;
} catch (Exception e) {
throw new RuntimeIOException("Error in LinearClassifierFactory, loading from file=" + file, e);
}
}
public void setEvaluators(int iters, Evaluator[] evaluators) {
this.evalIters = iters;
this.evaluators = evaluators;
}
public LinearClassifierCreator<L,F> getClassifierCreator(GeneralDataset<L, F> dataset) {
// LogConditionalObjectiveFunction<L, F> objective = new LogConditionalObjectiveFunction<L, F>(dataset, logPrior);
return new LinearClassifierCreator<>(dataset.featureIndex, dataset.labelIndex);
}
public static class LinearClassifierCreator<L,F> implements ClassifierCreator, ProbabilisticClassifierCreator
{
LogConditionalObjectiveFunction objective;
Index<F> featureIndex;
Index<L> labelIndex;View on GitHub (pinned to 1b7edd19c4)