{"record":{"id":"63b8cb0322229d63","repo":"stanfordnlp/CoreNLP","slug":"need-to-specify-testtreebank","errorCode":null,"errorMessage":"Need to specify -testTreebank","messagePattern":"Need to specify -testTreebank","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"src/edu/stanford/nlp/parser/dvparser/FindNearestNeighbors.java","lineNumber":91,"sourceCode":"        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      }\n      testTreebank = lexparser.getOp().tlpParams.memoryTreebank();;\n      testTreebank.loadPath(testTreebankPath, testTreebankFilter);\n      log.info(\"Read in \" + testTreebank.size() + \" trees for testing\");","sourceCodeStart":73,"sourceCodeEnd":109,"githubUrl":"https://github.com/stanfordnlp/CoreNLP/blob/1b7edd19c4d0d7b1f13a2591425b9b60a0b1af7a/src/edu/stanford/nlp/parser/dvparser/FindNearestNeighbors.java#L73-L109","documentation":"FindNearestNeighbors needs a test treebank of gold trees to parse and query for nearest neighbors. When -testTreebank is not supplied, main() throws this IllegalArgumentException. It is a required-input check performed before model loading.","triggerScenarios":"Running FindNearestNeighbors.main() with -model and -output set but no -testTreebank flag, leaving testTreebankPath null.","commonSituations":"Omitting the treebank when experimenting with small inputs; assuming a default evaluation set; typo-ing the flag (e.g. -test_treebank).","solutions":["Pass -testTreebank <path-to-treebank-file> pointing at gold trees","Ensure the path exists and is readable (the error fires before the file is opened, so fix the flag first)","Provide all three required flags together: -model, -testTreebank, -output"],"exampleFix":"// before\n-Dmodel=dvparser.ser.gz ... FindNearestNeighbors -output out.txt\n// after\nFindNearestNeighbors -model dvparser.ser.gz -testTreebank test.gold -output out.txt","handlingStrategy":"validation","validationCode":"if (!Arrays.asList(args).contains(\"-testTreebank\")) {\n  throw new IllegalArgumentException(\"FindNearestNeighbors requires -testTreebank <goldTrees>\");\n}","typeGuard":null,"tryCatchPattern":"try {\n  FindNearestNeighbors.main(args);\n} catch (IllegalArgumentException e) {\n  System.err.println(\"Missing required option: \" + e.getMessage());\n}","preventionTips":["Keep a canonical command template with -model, -testTreebank, -output","Verify the treebank file exists before running","Avoid flag-name typos by copying from working examples"],"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"}