{"record":{"id":"9219c4f65bc68810","repo":"stanfordnlp/CoreNLP","slug":"expected-nprune-found","errorCode":null,"errorMessage":"Expected nPrune, found: ","messagePattern":"Expected nPrune, found: ","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"src/edu/stanford/nlp/parser/lexparser/Options.java","lineNumber":1265,"sourceCode":"    freeDependencies = Boolean.parseBoolean(value);\n    line = in.readLine();\n    value = line.substring(line.indexOf(' ') + 1);\n    directional = Boolean.parseBoolean(value);\n    line = in.readLine();\n    value = line.substring(line.indexOf(' ') + 1);\n    genStop = Boolean.parseBoolean(value);\n    line = in.readLine();\n    value = line.substring(line.indexOf(' ') + 1);\n    distance = Boolean.parseBoolean(value);\n    line = in.readLine();\n    value = line.substring(line.indexOf(' ') + 1);\n    coarseDistance = Boolean.parseBoolean(value);\n    line = in.readLine();\n    value = line.substring(line.indexOf(' ') + 1);\n    dcTags = Boolean.parseBoolean(value);\n    line = in.readLine();\n    if ( ! line.matches(\"^nPrune.*\")) {\n      throw new RuntimeException(\"Expected nPrune, found: \" + line);\n    }\n    value = line.substring(line.indexOf(' ') + 1);\n    nodePrune = Boolean.parseBoolean(value);\n    line = in.readLine(); // get rid of last line\n    if (line.length() != 0) {\n      throw new RuntimeException(\"Expected blank line, found: \" + line);\n    }\n  }\n\n  private static final long serialVersionUID = 4L;\n\n} // end class Options\n","sourceCodeStart":1247,"sourceCodeEnd":1278,"githubUrl":"https://github.com/stanfordnlp/CoreNLP/blob/1b7edd19c4d0d7b1f13a2591425b9b60a0b1af7a/src/edu/stanford/nlp/parser/lexparser/Options.java#L1247-L1278","documentation":"Options.readData reads a serialized (text-format) parser Options block line by line and expects a fixed schema. Each section must start with an expected prefix; when the line does not match '^nPrune.*' it throws RuntimeException('Expected nPrune, found: ...'), meaning the file's option section is out of order or written by an incompatible format version.","triggerScenarios":"Loading a parser model/grammar text file (via readData during parser loading) whose options section has a line where the 'nPrune' field is expected but a different field appears — typically a stale or corrupted model file, or a file written by a different parser version.","commonSituations":"Mixing model files and library versions (e.g., loading a model trained with an older/newer Stanford Parser), manually edited grammar files, or truncated/mangled file transfers.","solutions":["Use a parser model file that matches your library version (re-download the official model jar for your release).","Retrain/regenerate the grammar file with the current parser version.","Check that the file was not truncated or edited; restore from a clean copy.","Pin the library version to the one the model was built with (check the Options serialVersionUID / release notes)."],"exampleFix":"// before\nLexicalizedParser.loadModel(\"old-v1-englishPCFG.ser.gz\"); // with parser 3.9.x\n// after\nLexicalizedParser.loadModel(\"edu/stanford/nlp/models/lexparser/englishPCFG.ser.gz\"); // matching version","handlingStrategy":"validation","validationCode":"try (BufferedReader in = Files.newBufferedReader(modelPath)) {\n  String line;\n  boolean ok = false;\n  while ((line = in.readLine()) != null) if (line.startsWith(\"nPrune\")) { ok = true; break; }\n  if (!ok) throw new IllegalStateException(\"Model file options section missing nPrune line: \" + modelPath);\n}","typeGuard":null,"tryCatchPattern":"try {\n  parser = LexicalizedParser.loadModel(path);\n} catch (RuntimeException e) {\n  if (e.getMessage().startsWith(\"Expected nPrune\")) {\n    throw new IOException(\"Incompatible/corrupt model file: \" + path, e);\n  }\n  throw e;\n}","preventionTips":["Load model files shipped for your exact parser version.","Never hand-edit serialized grammar/option text files.","Verify checksums of downloaded model artifacts.","Record which library version produced any custom-trained models."],"tags":["model-loading","file-format","parser"],"backgroundTag":"schema-validation-failed","analyzedSha":"1b7edd19c4d0d7b1f13a2591425b9b60a0b1af7a","analyzedAt":"2026-09-10T02:24:07.274Z","contentChangedAt":"2026-09-10T02:24:07.274Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}