{"record":{"id":"fee7d280f5ccdaa0","repo":"stanfordnlp/CoreNLP","slug":"no-test-treebank-path-specified","errorCode":null,"errorMessage":"No test treebank path specified...","messagePattern":"No test treebank path specified\\.\\.\\.","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"src/edu/stanford/nlp/parser/lexparser/ChineseLexiconAndWordSegmenter.java","lineNumber":572,"sourceCode":"        serializedInputFileOrUrl = args[argIndex];\n        argIndex++;\n      }\n      try {\n        cs = new ChineseLexiconAndWordSegmenter(serializedInputFileOrUrl, op);\n      } catch (IllegalArgumentException e) {\n        log.info(\"Error loading segmenter, exiting...\");\n        System.exit(0);\n      }\n    }\n\n    // the following has to go after reading parser to make sure\n    // op and tlpParams are the same for train and test\n    TreePrint treePrint = op.testOptions.treePrint(tlpParams);\n\n    if (testFilter != null) {\n      if (testPath == null) {\n        if (treebankPath == null) {\n          throw new RuntimeException(\"No test treebank path specified...\");\n        } else {\n          log.info(\"No test treebank path specified.  Using train path: \\\"\" + treebankPath + \"\\\"\");\n          testPath = treebankPath;\n        }\n      }\n      testTreebank = tlpParams.testMemoryTreebank();\n      testTreebank.loadPath(testPath, testFilter);\n    }\n\n    op.trainOptions.sisterSplitters = Generics.newHashSet(Arrays.asList(tlpParams.sisterSplitters()));\n\n    // at this point we should be sure that op.tlpParams is\n    // set appropriately (from command line, or from grammar file),\n    // and will never change again.  We also set the tlpParams of the\n    // LexicalizedParser instance to be the same object.  This is\n    // redundancy that we probably should take out eventually.\n    //\n    // -- Roger","sourceCodeStart":554,"sourceCodeEnd":590,"githubUrl":"https://github.com/stanfordnlp/CoreNLP/blob/1b7edd19c4d0d7b1f13a2591425b9b60a0b1af7a/src/edu/stanford/nlp/parser/lexparser/ChineseLexiconAndWordSegmenter.java#L554-L590","documentation":"During testing in ChineseLexiconAndWordSegmenter.main, a test treebank path is required. When -testTreebank/-testPath was not given and no training treebank path exists to fall back on, main throws RuntimeException telling the user to specify a test treebank path. If a train path exists, it is reused with just a log message instead.","triggerScenarios":"Running main() with a test filter configured but neither testPath nor treebankPath set — i.e., testing was requested without ever supplying a path to the test treebank and no train path is available.","commonSituations":"Running a test-only invocation (no -train) but forgetting -testTreebank path; misspelled path option so it was never parsed; scripting that builds arguments dynamically and drops the test path.","solutions":["Pass the test treebank path explicitly, e.g. -testTreebank /path/to/testTreebank or -testPath ...","Or include a -train option with a valid treebankPath so the code can default testPath to the train path","Verify the option spelling matches what main() parses"],"exampleFix":"// before\njava ... -testFilter 0-100\n// after\njava ... -testTreebank /path/to/testTreebank -testFilter 0-100","handlingStrategy":"validation","validationCode":"boolean hasTestPath = argList.contains(\"-testPath\") || argList.contains(\"-testTreebank\"); boolean hasTrainPath = argList.contains(\"-train\"); if (!hasTestPath && !hasTrainPath) throw new IllegalArgumentException(\"specify test treebank path\");","typeGuard":null,"tryCatchPattern":"try { main(args); } catch (RuntimeException e) { if (e.getMessage().startsWith(\"No test treebank path\")) { args = add(args, \"-testPath\", defaultTestPath); main(args); } }","preventionTips":["Always set -testTreebank/-testPath explicitly for test runs","Or include -train so the train path can be reused as the test path"],"tags":["java","parser","cli","missing-argument"],"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-17T15:17:12.973Z"}