stanfordnlp/CoreNLP · error · java.lang.RuntimeException

Unknown argument

Error message

Unknown argument ${args[argIndex]}

What it means

AverageDVModels.main() throws this RuntimeException when it encounters a command-line argument it does not recognize during option parsing. Only flags like -output and -input are supported; any other token aborts the program.

Solutions

  1. Use only the supported flags: -output <name> and -input <comma-separated model files>
  2. Fix the typo in the unrecognized argument
  3. Check shell quoting so values stay attached to their flags

Example fix

// before
java AverageDVModels -model parser.gz -output avg.gz
// after
java AverageDVModels -input parser1.gz,parser2.gz -output avg.gz
Defensive patterns

Strategy: validation

Validate before calling

Set<String> allowed = Set.of("-output", "-input");
for (String a : args) if (a.startsWith("-") && !allowed.contains(a)) throw new IllegalArgumentException("unsupported flag: " + a);

Try / catch

try { AverageDVModels.main(args); } catch (RuntimeException e) { System.err.println("Bad dvparser arguments: " + e.getMessage()); System.exit(1); }

Prevention

When it happens

Trigger: Running java edu.stanford.nlp.parser.dvparser.AverageDVModels with a typo'd or unsupported flag, or with a value accidentally separated from its flag so the value itself is parsed as a flag.

Common situations: Misspelling -input or -output; copying flags from another dvparser tool that supports more options; shell quoting dropping a value so its flag consumes the wrong tokens.

Understand the failure class

Background: "Unknown argument", "Invalid value", and "must be one of": invalid CLI argument errors explained — this error's family across 35 libraries.

Related errors


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

Appendix: source

Thrown at src/edu/stanford/nlp/parser/dvparser/AverageDVModels.java:117

   * Command line arguments for this program:
   * <br>
   * -output: the model file to output
   * -input: a list of model files to input
   */
  public static void main(String[] args) {
    String outputModelFilename = null;
    List<String> inputModelFilenames = Generics.newArrayList();
    
    for (int argIndex = 0; argIndex < args.length; ) {
      if (args[argIndex].equalsIgnoreCase("-output")) {
        outputModelFilename = args[argIndex + 1];
        argIndex += 2;
      } else if (args[argIndex].equalsIgnoreCase("-input")) {
        for (++argIndex; argIndex < args.length && !args[argIndex].startsWith("-"); ++argIndex) {
          inputModelFilenames.addAll(Arrays.asList(args[argIndex].split(",")));
        }
      } else {
        throw new RuntimeException("Unknown argument " + args[argIndex]);
      }
    }

    if (outputModelFilename == null) {
      log.info("Need to specify output model name with -output");
      System.exit(2);
    }

    if (inputModelFilenames.size() == 0) {
      log.info("Need to specify input model names with -input");
      System.exit(2);
    }

    log.info("Averaging " + inputModelFilenames);
    log.info("Outputting result to " + outputModelFilename);

    LexicalizedParser lexparser = null;
    List<DVModel> models = Generics.newArrayList();

View on GitHub (pinned to 1b7edd19c4)