{"record":{"id":"444001d8e42b1c82","repo":"stanfordnlp/CoreNLP","slug":"need-to-specify-model","errorCode":null,"errorMessage":"Need to specify -model","messagePattern":"Need to specify -model","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"src/edu/stanford/nlp/parser/dvparser/FindNearestNeighbors.java","lineNumber":88,"sourceCode":"    for (int argIndex = 0; argIndex < args.length; ) {\n      if (args[argIndex].equalsIgnoreCase(\"-model\")) {\n        modelPath = args[argIndex + 1];\n        argIndex += 2;\n      } else if (args[argIndex].equalsIgnoreCase(\"-testTreebank\")) {\n        Pair<String, FileFilter> treebankDescription = ArgUtils.getTreebankDescription(args, argIndex, \"-testTreebank\");\n        argIndex = argIndex + ArgUtils.numSubArgs(args, argIndex) + 1;\n        testTreebankPath = treebankDescription.first();\n        testTreebankFilter = treebankDescription.second();\n      } else if (args[argIndex].equalsIgnoreCase(\"-output\")) {\n        outputPath = args[argIndex + 1];\n        argIndex += 2;\n      } else {\n        unusedArgs.add(args[argIndex++]);\n      }\n    }\n\n    if (modelPath == null) {\n      throw new IllegalArgumentException(\"Need to specify -model\");\n    }\n    if (testTreebankPath == null) {\n      throw new IllegalArgumentException(\"Need to specify -testTreebank\");\n    }\n    if (outputPath == null) {\n      throw new IllegalArgumentException(\"Need to specify -output\");\n    }\n\n    String[] newArgs = unusedArgs.toArray(new String[unusedArgs.size()]);\n\n    LexicalizedParser lexparser = LexicalizedParser.loadModel(modelPath, newArgs);\n\n    Treebank testTreebank = null;\n    if (testTreebankPath != null) {\n      log.info(\"Reading in trees from \" + testTreebankPath);\n      if (testTreebankFilter != null) {\n        log.info(\"Filtering on \" + testTreebankFilter);\n      }","sourceCodeStart":70,"sourceCodeEnd":106,"githubUrl":"https://github.com/stanfordnlp/CoreNLP/blob/1b7edd19c4d0d7b1f13a2591425b9b60a0b1af7a/src/edu/stanford/nlp/parser/dvparser/FindNearestNeighbors.java#L70-L106","documentation":"FindNearestNeighbors locates similar phrase vectors using a trained DVModel, which is only available inside a serialized DVParser model file. main() throws this IllegalArgumentException when -model is absent. It is the first of three mandatory-option checks.","triggerScenarios":"Running FindNearestNeighbors.main() without the -model flag, so modelPath stays null after argument parsing.","commonSituations":"Forgetting that the tool operates on a trained DV model, not a plain parser model; running with only -testTreebank and -output; scripting examples that assumed a default model path.","solutions":["Pass -model <path-to-serialized-DVParser> on the command line","Verify the file is a DVParser model (saved by DVParser), not a plain LexicalizedParser","Check flag spelling: it must be exactly -model"],"exampleFix":"// before\njava edu.stanford.nlp.parser.dvparser.FindNearestNeighbors -testTreebank tb -output out.txt\n// after\njava edu.stanford.nlp.parser.dvparser.FindNearestNeighbors -model dvparser.ser.gz -testTreebank tb -output out.txt","handlingStrategy":"validation","validationCode":"if (!Arrays.asList(args).contains(\"-model\")) {\n  throw new IllegalArgumentException(\"FindNearestNeighbors requires -model <serializedDVParser>\");\n}","typeGuard":null,"tryCatchPattern":"try {\n  FindNearestNeighbors.main(args);\n} catch (IllegalArgumentException e) {\n  System.err.println(\"Missing required option: \" + e.getMessage());\n}","preventionTips":["Always pass -model pointing at a DVParser-serialized model","Use a wrapper script listing all three required flags","Validate required flags in CI for tool invocations"],"tags":["java","cli","missing-argument"],"backgroundTag":"missing-required-option","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"}