stanfordnlp/CoreNLP · error · java.lang.IllegalArgumentException

Bad arguments after

Error message

Bad arguments after ${flag}

What it means

ArgUtils.getWeightedTreebankDescription() throws this IllegalArgumentException when the argument array following the description flag is malformed — the expected path/filter/optional-weight pattern could not be parsed. It signals that the command-line token layout for a treebank description is invalid.

Solutions

  1. Check the description syntax: path, filter, and optionally a weight argument after the flag
  2. Quote arguments containing spaces so the shell passes them as single tokens
  3. Inspect the parsed token sequence around the flag to find the unexpected token

Example fix

// before
-train treebank  (missing filter/weight)
// after
-train /data/treebank "" 1.0
Defensive patterns

Strategy: validation

Validate before calling

if (args.length < argIndex + 2) { throw new IllegalArgumentException("treebank description needs path and filter after " + flag); }

Try / catch

try { desc = ArgUtils.getWeightedTreebankDescription(args, argIndex, flag); } catch (IllegalArgumentException e) { System.err.println("Bad treebank description: " + e.getMessage()); System.exit(1); }

Prevention

When it happens

Trigger: Passing a malformed treebank description on the command line, e.g. a missing path or filter after the flag, or leftover unrecognized tokens where the weight should be (when hasWeight is set the parser consumes one extra arg and finds garbage).

Common situations: Typos in the treebank description syntax; quoting mistakes in the shell that split or drop tokens; copying an example with a different flag arity.

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/44c65c9ad196a58a. Report an issue: GitHub.

Appendix: source

Thrown at src/edu/stanford/nlp/parser/common/ArgUtils.java:84

          filter = new NumberRangesFileFilter(args[argIndex], true);
        }
        argIndex++;
      } else if (numSubArgs == 3) {
        try {
          int low = Integer.parseInt(args[argIndex]);
          int high = Integer.parseInt(args[argIndex + 1]);
          filter = new NumberRangeFileFilter(low, high, true);
          argIndex += 2;
        } catch (NumberFormatException e) {
          // maybe it's a ranges expression?
          filter = new NumberRangesFileFilter(args[argIndex++], true);
        }
      }
      if (hasWeight) {
        argIndex++;
      }
    } else {
      throw new IllegalArgumentException("Bad arguments after " + flag);
    }
    return Triple.makeTriple(path, filter, weight);
  }
}

View on GitHub (pinned to 1b7edd19c4)