stanfordnlp/CoreNLP · error · RuntimeException

No test treebank path specified...

Error message

No test treebank path specified...

What it means

Same pattern as the tune path check: a test filter or test path was requested in the order-dependent LexicalizedParser constructor, but testPath was null and no treebankPath (train path) was available to fall back to. The constructor throws "No test treebank path specified..." because evaluation cannot proceed without a test treebank location.

Solutions

  1. Add a -testTreebank <path> argument to your command
  2. Or place -treebank <trainPath> before the test options so testPath defaults to the train path
  3. Remove -testFilter/test flags if no held-out evaluation is needed

Example fix

// before
String[] args = {"-testFilter", "regex:.*23.*", "-train", "/data/ptb/wsj/02-21"};
// after
String[] args = {"-train", "/data/ptb/wsj/02-21", "-testTreebank", "/data/ptb/wsj/22"};
Defensive patterns

Strategy: validation

Validate before calling

// Before invoking the constructor: verify test options carry a path
if ((testFilter != null || testTreebankFlag) && testPath == null && treebankPath == null)
  throw new IllegalArgumentException("-testTreebank (or -treebank before test options) is required");

Prevention

When it happens

Trigger: Passing -testFilter or a test-treebank flag to the training/evaluation constructor without -testTreebank, and with treebankPath still null at that point in argument processing.

Common situations: Setting up an eval script and including -testFilter but omitting -testTreebank; reordering arguments so -treebank comes after the test options; copying training flags into an eval script incompletely.

Understand the failure class

Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.

Related errors


AI-assisted analysis of stanfordnlp/CoreNLP@1b7edd19c4 (2026-09-10). Data as JSON: /api/errors/22db5db77908eb05. Report an issue: GitHub.

Appendix: source

Thrown at src/edu/stanford/nlp/parser/lexparser/LexicalizedParser.java:1421

        log.info("Couldn't instantiate TokenizerFactory " + tokenizerFactoryClass + " with options " + tokenizerOptions);
        throw new RuntimeException(e);
      }
    }


    // the following has to go after reading parser to make sure
    // op and tlpParams are the same for train and test
    // THIS IS BUTT UGLY BUT IT STOPS USER SPECIFIED ENCODING BEING
    // OVERWRITTEN BY ONE SPECIFIED IN SERIALIZED PARSER
    if (encoding != null) {
      op.tlpParams.setInputEncoding(encoding);
      op.tlpParams.setOutputEncoding(encoding);
    }

    if (testFilter != null || testPath != null) {
      if (testPath == null) {
        if (treebankPath == null) {
          throw new RuntimeException("No test treebank path specified...");
        } else {
          log.info("No test treebank path specified.  Using train path: \"" + treebankPath + '\"');
          testPath = treebankPath;
        }
      }
      testTreebank = op.tlpParams.testMemoryTreebank();
      testTreebank.loadPath(testPath, testFilter);
    }

    op.trainOptions.sisterSplitters = Generics.newHashSet(Arrays.asList(op.tlpParams.sisterSplitters()));

    // at this point we should be sure that op.tlpParams is
    // set appropriately (from command line, or from grammar file),
    // and will never change again.  -- Roger

    // Now what do we do with the parser we've made
    if (saveToTextFile) {
      // save the parser to textGrammar format

View on GitHub (pinned to 1b7edd19c4)