stanfordnlp/CoreNLP · error · RuntimeException

Error: output tree format

Error message

Error: output tree format 

What it means

TreePrint's constructor parses a comma-separated format string into named output formats. Any format name not in the known outputTreeFormats list is rejected with a RuntimeException listing the valid formats.

Solutions

  1. Use one of the supported formats exactly, e.g. penn, oneline, words, wordsAndTags, typedDependencies, typedDependenciesCollapsed, conll, xml, etc.
  2. Check the accepted list printed in the exception message and fix spelling/case.
  3. Validate user config against Arrays.asList(TreePrint.outputTreeFormats) before constructing.

Example fix

// before
TreePrint tp = new TreePrint("TypedDependencies");
// after
TreePrint tp = new TreePrint("typedDependencies");
Defensive patterns

Strategy: validation

Validate before calling

List<String> ok = Arrays.asList(TreePrint.outputTreeFormats);
for (String f : formatString.split(",")) { if (!ok.contains(f.trim())) throw new IllegalArgumentException("bad format: " + f); }

Try / catch

try { return new TreePrint(format); } catch (RuntimeException e) { return new TreePrint("penn"); }

Prevention

When it happens

Trigger: Constructing TreePrint (directly or via -writeOutputFormat / pennPrint options) with a misspelled or nonexistent format name such as "TypedDependency" instead of "typedDependencies".

Common situations: Typo in command-line -outputFormat option; copying a format string from old documentation after formats were renamed; passing user-supplied configuration straight into the constructor.

Understand the failure class

Background: Invalid enum value errors: "Unknown type", "Invalid scope", "must be one of" — when a string is not on the library's allowed list — this error's family across 23 libraries.

Related errors


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

Appendix: source

Thrown at src/edu/stanford/nlp/trees/TreePrint.java:151

   *                CC propagation, which we generally recommend.)
   * @param optionsString Options that additionally specify how trees are to
   *                be printed (for instance, whether stemming should be done).
   *                Known options are: {@code stem, lexicalize, markHeadNodes,
   *                xml, removeTopBracket, transChinese,
   *                includePunctuationDependencies, basicDependencies, treeDependencies,
   *                CCPropagatedDependencies, collapsedDependencies, nonCollapsedDependencies,
   *                nonCollapsedDependenciesSeparated, includeTags}.
   * @param tlp     The TreebankLanguagePack used to do things like delete
   *                or ignore punctuation in output
   * @param hf      The HeadFinder used in printing output
   */
  public TreePrint(String formatString, String optionsString, TreebankLanguagePack tlp, HeadFinder hf, HeadFinder typedDependencyHF) {
    formats = StringUtils.stringToPropertiesMap(formatString);
    options = StringUtils.stringToPropertiesMap(optionsString);
    List<String> okOutputs = Arrays.asList(outputTreeFormats);
    for (String format : formats.keySet()) {
      if ( ! okOutputs.contains(format)) {
        throw new RuntimeException("Error: output tree format " + format + " not supported. Known formats are: " + okOutputs);
      }
    }

    this.hf = hf;
    this.tlp = tlp;
    boolean includePunctuationDependencies;
    includePunctuationDependencies = propertyToBoolean(this.options,
                                                       "includePunctuationDependencies");

    boolean generateOriginalDependencies = tlp.generateOriginalDependencies();

    Predicate<String> puncFilter;
    if (includePunctuationDependencies) {
      dependencyFilter = Filters.acceptFilter();
      dependencyWordFilter = Filters.acceptFilter();
      puncFilter = Filters.acceptFilter();
    } else {
      dependencyFilter = new Dependencies.DependentPuncTagRejectFilter<>(tlp.punctuationTagRejectFilter());

View on GitHub (pinned to 1b7edd19c4)