{"record":{"id":"fdc3fef5b2c1c45d","repo":"stanfordnlp/CoreNLP","slug":"unknown-output-format","errorCode":null,"errorMessage":"Unknown output format ","messagePattern":"Unknown output format ","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"src/edu/stanford/nlp/sentiment/SentimentPipeline.java","lineNumber":180,"sourceCode":"        Tree copy = tree.deepCopy();\n        setIndexLabels(copy, 0);\n        out.println(copy);\n        outputTreeVectors(out, tree, 0);\n        break;\n      }\n      case ROOT: {\n        out.println(\"  \" + sentence.get(SentimentCoreAnnotations.SentimentClass.class));\n        break;\n      }\n      case PROBABILITIES: {\n        Tree copy = tree.deepCopy();\n        setIndexLabels(copy, 0);\n        out.println(copy);\n        outputTreeScores(out, tree, 0);\n        break;\n      }\n      default:\n        throw new IllegalArgumentException(\"Unknown output format \" + output);\n      }\n    }\n  }\n\n  private static final String DEFAULT_TLPP_CLASS = \"edu.stanford.nlp.parser.lexparser.EnglishTreebankParserParams\";\n\n  private static void help() {\n    log.info(\"Known command line arguments:\");\n    log.info(\"  -sentimentModel <model>: Which model to use\");\n    log.info(\"  -parserModel <model>: Which parser to use\");\n    log.info(\"  -file <filename>: Which file to process\");\n    log.info(\"  -fileList <file>,<file>,...: Comma separated list of files to process.  Output goes to file.out\");\n    log.info(\"  -stdin: Process stdin instead of a file\");\n    log.info(\"  -input <format>: Which format to input, TEXT or TREES.  Will not process stdin as trees.  If trees are not already binarized, they will be binarized with -tlppClass's headfinder, which means they must have labels in that treebank's tagset.\");\n    log.info(\"  -output <format>: Which format to output, PENNTREES, VECTORS, PROBABILITIES, or ROOT.  Multiple formats can be specified as a comma separated list.\");\n    log.info(\"  -filterUnknown: remove unknown trees from the input.  Only applies to TREES input, in which case the trees must be binarized with sentiment labels\");\n    log.info(\"  -tlppClass: a class to use for building the binarizer if using non-binarized TREES as input.  Defaults to \" + DEFAULT_TLPP_CLASS);\n  }","sourceCodeStart":162,"sourceCodeEnd":198,"githubUrl":"https://github.com/stanfordnlp/CoreNLP/blob/1b7edd19c4d0d7b1f13a2591425b9b60a0b1af7a/src/edu/stanford/nlp/sentiment/SentimentPipeline.java#L162-L198","documentation":"In outputTree, after printing trees the code switches on the user-selected output format (e.g. root-only, scores); any value outside the known enum of formats falls into the default branch and throws IllegalArgumentException(\"Unknown output format \" + output). The library validates the format only at output time, not at argument-parse time.","triggerScenarios":"Passing -output <value> to SentimentPipeline main with a value not among the recognized formats (c, root, scores), or invoking outputTree programmatically with an unrecognized Output output value.","commonSituations":"Typos like -output Scores or -output tree; copying a CLI invocation from docs of a different version where the flag values changed; wrapping the class in a script that interpolates an unset variable, producing an empty format string.","solutions":["Use one of the accepted -output values (e.g. c, root, or scores).","Check spelling/case and re-run with -help to list supported formats.","In wrapper scripts, validate/interpolate the output value before invoking the pipeline.","If a format you need is genuinely missing, extend the switch in outputTree with a new case instead of passing an ad-hoc string."],"exampleFix":"// before\njava edu.stanford.nlp.sentiment.SentimentPipeline -model model.ser.gz -output tree -file in.txt\n// after\njava edu.stanford.nlp.sentiment.SentimentPipeline -model model.ser.gz -output scores -file in.txt","handlingStrategy":"validation","validationCode":"Set<String> validOutputs = new HashSet<>(Arrays.asList(\"c\", \"root\", \"scores\"));\nif (!validOutputs.contains(outputArg)) {\n  throw new IllegalArgumentException(\"output must be one of \" + validOutputs);\n}","typeGuard":null,"tryCatchPattern":"try {\n  SentimentPipeline.main(args);\n} catch (IllegalArgumentException e) {\n  if (e.getMessage().startsWith(\"Unknown output format\")) {\n    System.err.println(\"Use -output with values: c, root, scores\");\n  } else throw e;\n}","preventionTips":["Check -help output for the exact -output values before scripting.","Keep flag values in constants, not inline strings, in wrapper scripts.","Beware version differences: verify format strings against the version you deploy.","Validate the interpolated variable in scripts before invoking the pipeline."],"tags":["java","cli","invalid-option","nlp"],"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-15T23:17:13.987Z"}