{"record":{"id":"d2637398cffc82d7","repo":"stanfordnlp/CoreNLP","slug":"need-to-supply-a-treebank-with-treebank","errorCode":null,"errorMessage":"Need to supply a treebank with -treebank","messagePattern":"Need to supply a treebank with -treebank","errorType":"exception","errorClass":"java.lang.IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"src/edu/stanford/nlp/parser/dvparser/CacheParseHypotheses.java","lineNumber":239,"sourceCode":"        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\n      treebank = treebank.transform(transformer);\n      sentences.addAll(treebank);\n    }","sourceCodeStart":221,"sourceCodeEnd":257,"githubUrl":"https://github.com/stanfordnlp/CoreNLP/blob/1b7edd19c4d0d7b1f13a2591425b9b60a0b1af7a/src/edu/stanford/nlp/parser/dvparser/CacheParseHypotheses.java#L221-L257","documentation":"CacheParseHypotheses.main throws IllegalArgumentException when the parsed treebank list is empty, meaning no -treebank argument was given. The tool needs source trees to generate hypothesis trees for, so it cannot proceed without one. This is the third mandatory-argument check in main.","triggerScenarios":"Running CacheParseHypotheses with -model and -output but no -treebank flag, or passing -treebank with no following path so the collection ends up empty.","commonSituations":"Omitting the treebank path in scripted invocations; pointing at a flag-only argument; misunderstanding that the treebank must be supplied as a file path (optionally with file ranges like file.txt 0 100).","solutions":["Add -treebank /path/to/treebank (e.g. a Penn Treebank file) to the command line","Verify the flag spelling is exactly -treebank","Confirm the treebank path exists and is readable"],"exampleFix":"// before\njava edu.stanford.nlp.parser.dvparser.CacheParseHypotheses -model parser.ser.gz -output out.txt.gz\n// after\njava edu.stanford.nlp.parser.dvparser.CacheParseHypotheses -model parser.ser.gz -output out.txt.gz -treebank wsj-train.txt","handlingStrategy":"validation","validationCode":"List<String> args = Arrays.asList(cmdArgs);\nif (!args.contains(\"-treebank\")) {\n    throw new IllegalArgumentException(\"CacheParseHypotheses requires -treebank <path>\");\n}","typeGuard":null,"tryCatchPattern":"try {\n    CacheParseHypotheses.main(args);\n} catch (IllegalArgumentException e) {\n    if (e.getMessage().contains(\"-treebank\")) {\n        System.err.println(\"Usage: add -treebank /path/to/treebank.txt\");\n    }\n}","preventionTips":["Always pass -treebank with a real treebank file path","Check file existence and readability before invocation","Remember treebank paths can include start/stop index arguments"],"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"}