{"record":{"id":"483e7cd4cd7d3d49","repo":"stanfordnlp/CoreNLP","slug":"error-in-linearclassifierfactory-loading-from-fil","errorCode":null,"errorMessage":"Error in LinearClassifierFactory, loading from file=${file}","messagePattern":"Error in LinearClassifierFactory, loading from file=(.+?)","errorType":"exception","errorClass":"RuntimeIOException","httpStatus":null,"severity":"error","filePath":"src/edu/stanford/nlp/classify/LinearClassifierFactory.java","lineNumber":987,"sourceCode":"        int label = Integer.parseInt(tuples[1]);\n        double value = Double.parseDouble(tuples[2]);\n        weights[feature][label] = value;\n        line = in.readLine();\n      }\n\n      // First line in thresholds is the number of thresholds\n      int numThresholds = Integer.parseInt(in.readLine());\n      double[] thresholds = new double[numThresholds];\n      int curr = 0;\n      while ((line = in.readLine()) != null) {\n        double tval = Double.parseDouble(line.trim());\n        thresholds[curr++] = tval;\n      }\n      in.close();\n      LinearClassifier<String, String> classifier = new LinearClassifier<>(weights, featureIndex, labelIndex);\n      return classifier;\n    } catch (Exception e) {\n      throw new RuntimeIOException(\"Error in LinearClassifierFactory, loading from file=\" + file, e);\n    }\n  }\n\n  public void setEvaluators(int iters, Evaluator[] evaluators) {\n    this.evalIters = iters;\n    this.evaluators = evaluators;\n  }\n\n  public LinearClassifierCreator<L,F> getClassifierCreator(GeneralDataset<L, F> dataset) {\n//    LogConditionalObjectiveFunction<L, F> objective = new LogConditionalObjectiveFunction<L, F>(dataset, logPrior);\n    return new LinearClassifierCreator<>(dataset.featureIndex, dataset.labelIndex);\n  }\n\n  public static class LinearClassifierCreator<L,F> implements ClassifierCreator, ProbabilisticClassifierCreator\n  {\n    LogConditionalObjectiveFunction objective;\n    Index<F> featureIndex;\n    Index<L> labelIndex;","sourceCodeStart":969,"sourceCodeEnd":1005,"githubUrl":"https://github.com/stanfordnlp/CoreNLP/blob/1b7edd19c4d0d7b1f13a2591425b9b60a0b1af7a/src/edu/stanford/nlp/classify/LinearClassifierFactory.java#L969-L1005","documentation":"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.","triggerScenarios":"Thrown at src/edu/stanford/nlp/classify/LinearClassifierFactory.java:987 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","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"],"exampleFix":null,"handlingStrategy":"fallback","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"1b7edd19c4d0d7b1f13a2591425b9b60a0b1af7a","analyzedAt":"2026-09-10T02:24:07.274Z","contentChangedAt":"2026-09-10T02:24:07.274Z","schemaVersion":2},"datasetVersion":"2026-09-17T15:17:12.973Z"}