{"record":{"id":"79a055f0d1344170","repo":"stanfordnlp/CoreNLP","slug":"need-to-specify-output","errorCode":null,"errorMessage":"Need to specify -output","messagePattern":"Need to specify -output","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"src/edu/stanford/nlp/parser/dvparser/FindNearestNeighbors.java","lineNumber":94,"sourceCode":"        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      }\n      testTreebank = lexparser.getOp().tlpParams.memoryTreebank();;\n      testTreebank.loadPath(testTreebankPath, testTreebankFilter);\n      log.info(\"Read in \" + testTreebank.size() + \" trees for testing\");\n    }\n\n    FileWriter out = new FileWriter(outputPath);","sourceCodeStart":76,"sourceCodeEnd":112,"githubUrl":"https://github.com/stanfordnlp/CoreNLP/blob/1b7edd19c4d0d7b1f13a2591425b9b60a0b1af7a/src/edu/stanford/nlp/parser/dvparser/FindNearestNeighbors.java#L76-L112","documentation":"FindNearestNeighbors writes its nearest-neighbor results to a file given by -output. main() throws this IllegalArgumentException when outputPath is null. It is the last of the three mandatory option checks before any processing.","triggerScenarios":"Running FindNearestNeighbors.main() with -model and -testTreebank but without -output.","commonSituations":"Redirecting stdout instead of using -output; forgetting the flag in batch scripts; confusing this tool's output flag with DVParser's -model output naming.","solutions":["Add -output <path-to-result-file> to the command","Ensure the directory for the output path exists and is writable","Supply all three flags: -model, -testTreebank, -output"],"exampleFix":"// before\nFindNearestNeighbors -model dvparser.ser.gz -testTreebank test.gold\n// after\nFindNearestNeighbors -model dvparser.ser.gz -testTreebank test.gold -output neighbors.txt","handlingStrategy":"validation","validationCode":"if (!Arrays.asList(args).contains(\"-output\")) {\n  throw new IllegalArgumentException(\"FindNearestNeighbors requires -output <file>\");\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 specify -output; stdout redirection is not supported by this tool","Create the output directory beforehand","Check all three required flags in a pre-run validation step"],"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-17T15:17:12.973Z"}