{"record":{"id":"d9a2eda6732a8879","repo":"stanfordnlp/CoreNLP","slug":"need-to-supply-an-output-filename-with-output","errorCode":null,"errorMessage":"Need to supply an output filename with -output","messagePattern":"Need to supply an output filename with -output","errorType":"exception","errorClass":"java.lang.IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"src/edu/stanford/nlp/parser/dvparser/CacheParseHypotheses.java","lineNumber":236,"sourceCode":"      if (args[argIndex].equalsIgnoreCase(\"-treebank\")) {\n        Pair<String, FileFilter> treebankDescription = ArgUtils.getTreebankDescription(args, argIndex, \"-treebank\");\n        argIndex = argIndex + ArgUtils.numSubArgs(args, argIndex) + 1;\n        treebanks.add(treebankDescription);\n        continue;\n      }\n      if (args[argIndex].equalsIgnoreCase(\"-numThreads\")) {\n        numThreads = Integer.parseInt(args[argIndex + 1]);\n        argIndex += 2;\n        continue;\n      }\n      throw new IllegalArgumentException(\"Unknown argument \" + args[argIndex]);\n    }\n\n    if (parserModel == null) {\n      throw new IllegalArgumentException(\"Need to supply a parser model with -model\");\n    }\n    if (output == null) {\n      throw new IllegalArgumentException(\"Need to supply an output filename with -output\");\n    }\n    if (treebanks.isEmpty()) {\n      throw new IllegalArgumentException(\"Need to supply a treebank with -treebank\");\n    }\n\n    log.info(\"Writing output to \" + output);\n    log.info(\"Loading parser model \" + parserModel);\n    log.info(\"Writing \" + dvKBest + \" hypothesis trees for each tree\");\n\n    LexicalizedParser parser = LexicalizedParser.loadModel(parserModel, \"-dvKBest\", Integer.toString(dvKBest));\n    CacheParseHypotheses cacher = new CacheParseHypotheses(parser);\n    TreeTransformer transformer = DVParser.buildTrainTransformer(parser.getOp());\n    List<Tree> sentences = new ArrayList<>();\n    for (Pair<String, FileFilter> description : treebanks) {\n      log.info(\"Reading trees from \" + description.first);\n      Treebank treebank = parser.getOp().tlpParams.memoryTreebank();\n      treebank.loadPath(description.first, description.second);\n","sourceCodeStart":218,"sourceCodeEnd":254,"githubUrl":"https://github.com/stanfordnlp/CoreNLP/blob/1b7edd19c4d0d7b1f13a2591425b9b60a0b1af7a/src/edu/stanford/nlp/parser/dvparser/CacheParseHypotheses.java#L218-L254","documentation":"CacheParseHypotheses.main requires an output filename via the -output flag and throws IllegalArgumentException when it is null. The tool writes cached parse hypotheses to this file, so it refuses to run without a destination. Like the other checks in main, it fails fast after argument parsing.","triggerScenarios":"Invoking CacheParseHypotheses with -model and -treebank but no -output flag, or misspelling the flag (e.g. -out) so the output field remains null.","commonSituations":"Automation scripts that build the command dynamically and omit the output path; users familiar with tools that default to stdout expecting this tool to do the same.","solutions":["Add -output /path/to/file.txt (or .gz) to the command line","Check flag spelling: it must be exactly -output","Ensure the output directory exists and is writable"],"exampleFix":"// before\njava edu.stanford.nlp.parser.dvparser.CacheParseHypotheses -model parser.ser.gz -treebank treebank\n// after\njava edu.stanford.nlp.parser.dvparser.CacheParseHypotheses -model parser.ser.gz -output hypotheses.txt.gz -treebank treebank","handlingStrategy":"validation","validationCode":"List<String> args = Arrays.asList(cmdArgs);\nif (!args.contains(\"-output\")) {\n    throw new IllegalArgumentException(\"CacheParseHypotheses requires -output <file>\");\n}","typeGuard":null,"tryCatchPattern":"try {\n    CacheParseHypotheses.main(args);\n} catch (IllegalArgumentException e) {\n    if (e.getMessage().contains(\"-output\")) {\n        System.err.println(\"Usage: add -output /path/to/hypotheses.txt.gz\");\n    }\n}","preventionTips":["Supply -output explicitly; the tool has no stdout default","Verify the output path is writable before running","Keep a canonical command template in your scripts"],"tags":["cli","argument-validation","stanford-corenlp"],"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"}