{"record":{"id":"bec5caaceac892ba","repo":"stanfordnlp/CoreNLP","slug":"parser-grammar-does-not-exist","errorCode":null,"errorMessage":": Parser grammar does not exist","messagePattern":": Parser grammar does not exist","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"critical","filePath":"src/edu/stanford/nlp/international/arabic/parsesegment/JointParsingModel.java","lineNumber":185,"sourceCode":"    Timing.tick(\"done.\");\n\n    Extractor<DependencyGrammar> dgExtractor = op.tlpParams.dependencyGrammarExtractor(op, wordIndex, tagIndex);\n    DependencyGrammar dg = null;\n    if (op.doDep) {\n      log.info(\"Extracting Dependencies...\");\n      dg = dgExtractor.extract(binaryTrainTrees);\n      dg.setLexicon(lex);\n      Timing.tick(\"done.\");\n    }\n\n    log.info(\"Done extracting grammars and lexicon.\");\n\n    return new LexicalizedParser(lex, bg, ug, dg, stateIndex, wordIndex, tagIndex, op);\n  }\n\n  private void makeParsers() {\n    if (lp == null)\n      throw new RuntimeException(this.getClass().getName() + \": Parser grammar does not exist\");\n\n    //a la (Klein and Manning, 2002)\n    pparser = new ExhaustivePCFGParser(lp.bg, lp.ug, lp.lex, op, lp.stateIndex, lp.wordIndex, lp.tagIndex);\n    dparser = new ExhaustiveDependencyParser(lp.dg, lp.lex, op, lp.wordIndex, lp.tagIndex);\n    bparser = new BiLexPCFGParser(new GenericLatticeScorer(), pparser, dparser, lp.bg, lp.ug, lp.dg, lp.lex, op, lp.stateIndex, lp.wordIndex, lp.tagIndex);\n  }\n\n  private boolean parse(InputStream inputStream) {\n    final LatticeXMLReader reader = new LatticeXMLReader();\n\n    if(!reader.load(inputStream,serInput)) {\n      System.err.printf(\"%s: Error loading input lattice xml from stdin%n\", this.getClass().getName());\n      return false;\n    }\n\n    System.err.printf(\"%s: Entering main parsing loop...%n\", this.getClass().getName());\n\n    int latticeNum = 0;","sourceCodeStart":167,"sourceCodeEnd":203,"githubUrl":"https://github.com/stanfordnlp/CoreNLP/blob/1b7edd19c4d0d7b1f13a2591425b9b60a0b1af7a/src/edu/stanford/nlp/international/arabic/parsesegment/JointParsingModel.java#L167-L203","documentation":"JointParsingModel.makeParsers builds the PCFG/dependency/bilex parsers from the loaded LexicalizedParser (lp) and throws this RuntimeException if lp is null — i.e. the parser grammar never loaded. This is an initialization-order invariant: the run() pipeline cannot proceed without a grammar, so construction of the parsing machinery is aborted.","triggerScenarios":"Running the parse-segment joint model when the parser grammar failed to load (missing or unreadable grammar file path in the options), so lp remains null when makeParsers is invoked from run().","commonSituations":"Incorrect -parserModel or grammar path configuration; grammar file not present on the machine (not shipped with the distribution); failed download/corrupt serialized grammar causing silent load failure before makeParsers runs.","solutions":["Verify the parser grammar path passed to the model and confirm the file exists and is readable.","Load the grammar explicitly with LexicalizedParser.loadModel(...) and check for load errors before running.","Re-download the Arabic parser grammar/model files for your CoreNLP version.","Log/inspect why lp stayed null (e.g. a swallowed exception during grammar loading) and fix that first."],"exampleFix":"// before\nJointParsingModel model = new JointParsingModel(...);\nmodel.run(words); // throws if grammar missing\n// after\nLexicalizedParser lp = LexicalizedParser.loadModel(grammarPath); // throws a clear error here\nif (lp == null) throw new IllegalStateException(\"Grammar failed to load: \" + grammarPath);\nJointParsingModel model = new JointParsingModel(...);","handlingStrategy":"validation","validationCode":"// java: confirm the grammar loads before running the joint model\nFile gf = new File(grammarPath);\nif (!gf.isFile() || !gf.canRead()) {\n  throw new FileNotFoundException(\"Parser grammar missing/unreadable: \" + grammarPath);\n}\nLexicalizedParser lp = LexicalizedParser.loadModel(grammarPath); // throws clearly on corrupt model","typeGuard":null,"tryCatchPattern":"try {\n  model.run(words);\n} catch (RuntimeException e) {\n  if (e.getMessage() != null && e.getMessage().endsWith(\"Parser grammar does not exist\")) {\n    throw new ConfigurationException(\"Set a valid -parserModel/grammar path and retry\");\n  } else throw e;\n}","preventionTips":["Verify grammar file existence and readability at pipeline startup, not at run time.","Ship/download Arabic parser models with checksum verification.","Load grammars explicitly (LexicalizedParser.loadModel) so load failures surface with clear messages."],"tags":["java","nlp","arabic","parser","missing-model"],"backgroundTag":"resource-not-found","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"}