{"record":{"id":"a1c70d8d7fd61e7a","repo":"stanfordnlp/CoreNLP","slug":"error-output-tree-format","errorCode":null,"errorMessage":"Error: output tree format ","messagePattern":"Error: output tree format ","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"src/edu/stanford/nlp/trees/TreePrint.java","lineNumber":151,"sourceCode":"   *                CC propagation, which we generally recommend.)\n   * @param optionsString Options that additionally specify how trees are to\n   *                be printed (for instance, whether stemming should be done).\n   *                Known options are: {@code stem, lexicalize, markHeadNodes,\n   *                xml, removeTopBracket, transChinese,\n   *                includePunctuationDependencies, basicDependencies, treeDependencies,\n   *                CCPropagatedDependencies, collapsedDependencies, nonCollapsedDependencies,\n   *                nonCollapsedDependenciesSeparated, includeTags}.\n   * @param tlp     The TreebankLanguagePack used to do things like delete\n   *                or ignore punctuation in output\n   * @param hf      The HeadFinder used in printing output\n   */\n  public TreePrint(String formatString, String optionsString, TreebankLanguagePack tlp, HeadFinder hf, HeadFinder typedDependencyHF) {\n    formats = StringUtils.stringToPropertiesMap(formatString);\n    options = StringUtils.stringToPropertiesMap(optionsString);\n    List<String> okOutputs = Arrays.asList(outputTreeFormats);\n    for (String format : formats.keySet()) {\n      if ( ! okOutputs.contains(format)) {\n        throw new RuntimeException(\"Error: output tree format \" + format + \" not supported. Known formats are: \" + okOutputs);\n      }\n    }\n\n    this.hf = hf;\n    this.tlp = tlp;\n    boolean includePunctuationDependencies;\n    includePunctuationDependencies = propertyToBoolean(this.options,\n                                                       \"includePunctuationDependencies\");\n\n    boolean generateOriginalDependencies = tlp.generateOriginalDependencies();\n\n    Predicate<String> puncFilter;\n    if (includePunctuationDependencies) {\n      dependencyFilter = Filters.acceptFilter();\n      dependencyWordFilter = Filters.acceptFilter();\n      puncFilter = Filters.acceptFilter();\n    } else {\n      dependencyFilter = new Dependencies.DependentPuncTagRejectFilter<>(tlp.punctuationTagRejectFilter());","sourceCodeStart":133,"sourceCodeEnd":169,"githubUrl":"https://github.com/stanfordnlp/CoreNLP/blob/1b7edd19c4d0d7b1f13a2591425b9b60a0b1af7a/src/edu/stanford/nlp/trees/TreePrint.java#L133-L169","documentation":"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.","triggerScenarios":"Constructing TreePrint (directly or via -writeOutputFormat / pennPrint options) with a misspelled or nonexistent format name such as \"TypedDependency\" instead of \"typedDependencies\".","commonSituations":"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.","solutions":["Use one of the supported formats exactly, e.g. penn, oneline, words, wordsAndTags, typedDependencies, typedDependenciesCollapsed, conll, xml, etc.","Check the accepted list printed in the exception message and fix spelling/case.","Validate user config against Arrays.asList(TreePrint.outputTreeFormats) before constructing."],"exampleFix":"// before\nTreePrint tp = new TreePrint(\"TypedDependencies\");\n// after\nTreePrint tp = new TreePrint(\"typedDependencies\");","handlingStrategy":"validation","validationCode":"List<String> ok = Arrays.asList(TreePrint.outputTreeFormats);\nfor (String f : formatString.split(\",\")) { if (!ok.contains(f.trim())) throw new IllegalArgumentException(\"bad format: \" + f); }","typeGuard":null,"tryCatchPattern":"try { return new TreePrint(format); } catch (RuntimeException e) { return new TreePrint(\"penn\"); }","preventionTips":["Copy format names exactly from the exception's known-formats list.","Whitelist user-supplied output formats against outputTreeFormats.","Test CLI -outputFormat values before deploying scripts."],"tags":["nlp","configuration","invalid-enum"],"backgroundTag":"invalid-enum-value","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"}