{"record":{"id":"63dcb340a1ff36d4","repo":"stanfordnlp/CoreNLP","slug":"must-supply-either-a-base-parser-model-with-parse","errorCode":null,"errorMessage":"Must supply either a base parser model with -parser or a serialized DVParser with -model","messagePattern":"Must supply either a base parser model with -parser or a serialized DVParser with -model","errorType":"exception","errorClass":"java.lang.IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"src/edu/stanford/nlp/parser/dvparser/DVParser.java","lineNumber":551,"sourceCode":"        argIndex += 2;\n      } else if (args[argIndex].equalsIgnoreCase(\"-nofilter\")) {\n        filter = false;\n        argIndex++;\n      } else if (args[argIndex].equalsIgnoreCase(\"-continueTraining\")) {\n        runTraining = true;\n        filter = false;\n        initialModelPath = args[argIndex + 1];\n        argIndex += 2;\n      } else if (args[argIndex].equalsIgnoreCase(\"-resultsRecord\")) {\n        resultsRecordPath = args[argIndex + 1];\n        argIndex += 2;\n      } else {\n        unusedArgs.add(args[argIndex++]);\n      }\n    }\n\n    if (parserPath == null && modelPath == null) {\n      throw new IllegalArgumentException(\"Must supply either a base parser model with -parser or a serialized DVParser with -model\");\n    }\n\n    if (!runTraining && modelPath == null && !runGradientCheck) {\n      throw new IllegalArgumentException(\"Need to either train a new model, run the gradient check or specify a model to load with -model\");\n    }\n\n    String[] newArgs = unusedArgs.toArray(new String[unusedArgs.size()]);\n    DVParser dvparser = null;\n    LexicalizedParser lexparser = null;\n    if (initialModelPath != null) {\n      lexparser = LexicalizedParser.loadModel(initialModelPath, newArgs);\n      DVModel model = getModelFromLexicalizedParser(lexparser);\n      dvparser = new DVParser(model, lexparser);\n    } else if (runTraining || runGradientCheck) {\n      lexparser = LexicalizedParser.loadModel(parserPath, newArgs);\n      dvparser = new DVParser(lexparser);\n    } else if (modelPath != null) {\n      lexparser = LexicalizedParser.loadModel(modelPath, newArgs);","sourceCodeStart":533,"sourceCodeEnd":569,"githubUrl":"https://github.com/stanfordnlp/CoreNLP/blob/1b7edd19c4d0d7b1f13a2591425b9b60a0b1af7a/src/edu/stanford/nlp/parser/dvparser/DVParser.java#L533-L569","documentation":"DVParser's main() requires a starting point: either a base LexicalizedParser model via -parser or a previously serialized DVParser via -model. When neither path is set after argument parsing, it throws this IllegalArgumentException. This is an upfront configuration sanity check before any training or parsing work begins.","triggerScenarios":"Running DVParser.main() with neither the -parser flag nor the -model flag supplied (parserPath == null && modelPath == null after the argument loop).","commonSituations":"Invoking the class from the command line with only training flags like -trainTreebank but forgetting -parser; copying an example command and dropping the required model argument; scripting the tool without knowing the two entry points.","solutions":["Pass -parser <path-to-LexicalizedParser-model.gz> to start from a base parser for training","Or pass -model <path-to-serialized-DVParser> to load an existing DVParser","Run java edu.stanford.nlp.parser.dvparser.DVParser -help or read the source argument loop to confirm flag names"],"exampleFix":"// before\njava edu.stanford.nlp.parser.dvparser.DVParser -train trainTreebank.gz\n// after\njava edu.stanford.nlp.parser.dvparser.DVParser -parser englishPCFG.ser.gz -train trainTreebank.gz","handlingStrategy":"validation","validationCode":"if (parserPath == null && modelPath == null) {\n  throw new IllegalArgumentException(\"Supply -parser <baseParserModel> or -model <serializedDVParser>\");\n}","typeGuard":null,"tryCatchPattern":"try {\n  DVParser.main(args);\n} catch (IllegalArgumentException e) {\n  System.err.println(\"Missing model args: \" + e.getMessage());\n}","preventionTips":["Always include -parser or -model in DVParser command lines","Build a launcher script that enforces required flags","Validate flag presence before constructing the args array"],"tags":["java","cli","missing-argument","dvparser"],"backgroundTag":"missing-required-argument","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"}