{"record":{"id":"aed8cd79c2d54ede","repo":"stanfordnlp/CoreNLP","slug":"o-argument-output-path-for-built-tagger-is-requ","errorCode":null,"errorMessage":"-o argument (output path for built tagger) is required","messagePattern":"-o argument \\(output path for built tagger\\) is required","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"src/edu/stanford/nlp/international/spanish/pipeline/AnCoraPOSStats.java","lineNumber":89,"sourceCode":"  private static final String usage =\n    String.format(\"Usage: java %s -o <output_path> file(s)%n%n\", AnCoraPOSStats.class.getName());\n\n  private static final Map<String, Integer> argOptionDefs = new HashMap<>();\n  static {\n    argOptionDefs.put(\"o\", 1);\n  }\n\n  public static void main(String[] args) throws IOException {\n    if (args.length < 1) {\n      log.info(usage);\n      System.exit(1);\n    }\n\n    Properties options = StringUtils.argsToProperties(args, argOptionDefs);\n\n    String outputPath = options.getProperty(\"o\");\n    if (outputPath == null)\n      throw new IllegalArgumentException(\"-o argument (output path for built tagger) is required\");\n\n    String[] remainingArgs = options.getProperty(\"\").split(\" \");\n    List<File> fileList = new ArrayList<>();\n    for (String arg : remainingArgs)\n      fileList.add(new File(arg));\n\n    AnCoraPOSStats stats = new AnCoraPOSStats(fileList, outputPath);\n    stats.process();\n\n    ObjectOutputStream oos = new ObjectOutputStream(new FileOutputStream(outputPath));\n    TwoDimensionalCounter<String, String> tagger = stats.getUnigramTagger();\n    oos.writeObject(tagger);\n\n    System.out.printf(\"Wrote tagger to %s%n\", outputPath);\n  }\n\n}\n","sourceCodeStart":71,"sourceCodeEnd":107,"githubUrl":"https://github.com/stanfordnlp/CoreNLP/blob/1b7edd19c4d0d7b1f13a2591425b9b60a0b1af7a/src/edu/stanford/nlp/international/spanish/pipeline/AnCoraPOSStats.java#L71-L107","documentation":"AnCoraPOSStats is a command-line tool that builds a Spanish POS tagger from AnCora corpus files. It parses CLI options via StringUtils.argsToProperties and requires the '-o' flag to know where to write the resulting tagger model. If '-o' is absent it throws this IllegalArgumentException immediately after option parsing.","triggerScenarios":"Running the AnCoraPOSStats main method without the '-o' flag, or passing options misspelled so they are not recognized (e.g. '--output' or '-output' instead of '-o'), so options.getProperty(\"o\") returns null.","commonSituations":"Invocation scripts or README commands copied without the output flag; shell wrappers that drop empty-string args; users assuming a default output path exists; calling main() programmatically from tests or other code with an args array lacking '-o'.","solutions":["Add the required flag: pass -o /path/to/output.tagger when running AnCoraPOSStats.","Check for typos in the flag (single dash, single letter 'o').","If invoking programmatically, include \"-o\" and its value in the args array.","Wrap the call in a catch for IllegalArgumentException to surface a friendly usage message if you control the launcher."],"exampleFix":"// before\njava edu.stanford.nlp.international.spanish.pipeline.AnCoraPOSStats -t -f trainFiles.txt\n// after\njava edu.stanford.nlp.international.spanish.pipeline.AnCoraPOSStats -o /models/ancora.tagger -t -f trainFiles.txt","handlingStrategy":"validation","validationCode":"// before calling main(args)\nProperties opts = StringUtils.argsToProperties(args);\nif (opts.getProperty(\"o\") == null)\n  throw new IllegalArgumentException(\"Usage: AnCoraPOSStats -o <outputPath> [corpus files...]\");","typeGuard":null,"tryCatchPattern":"try {\n  AnCoraPOSStats.main(args);\n} catch (IllegalArgumentException e) {\n  if (e.getMessage().contains(\"-o argument\")) {\n    System.err.println(\"Missing required -o flag. Usage: AnCoraPOSStats -o <outputPath> ...\");\n    System.exit(2);\n  }\n  throw e;\n}","preventionTips":["Always include -o in launch scripts for AnCoraPOSStats.","Centralize CLI parsing and validate required flags before invoking main.","Add a smoke test that runs the tool with minimal valid args.","Document required flags in a usage/help text."],"tags":["java","cli","stanford-nlp","missing-argument"],"backgroundTag":"missing-required-flag","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"}