{"record":{"id":"6d5abf26da5b8b0e","repo":"stanfordnlp/CoreNLP","slug":"args-treebankpath-trainnums-testnums","errorCode":null,"errorMessage":"args: treebankPath trainNums testNums","messagePattern":"args: treebankPath trainNums testNums","errorType":"console","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"src/edu/stanford/nlp/trees/international/pennchinese/CharacterLevelTagExtender.java","lineNumber":145,"sourceCode":"        pw.println(\"NOT EQUAL AFTER UNTRANSFORMATION!!!\");\n        pw.println();\n        oldTree.pennPrint(pw);\n        pw.println();\n        tree.pennPrint(pw);\n        pw.println(\"------------------\");\n      }\n    }\n  }\n\n  /**\n   * for testing -- CURRENTLY BROKEN!!!\n   *\n   * @param args input dir and output filename\n   * @throws IOException\n   */\n  public static void main(String[] args) throws IOException {\n    if (args.length != 3) {\n      throw new RuntimeException(\"args: treebankPath trainNums testNums\");\n    }\n\n    ChineseTreebankParserParams ctpp = new ChineseTreebankParserParams();\n    ctpp.charTags = true;\n    // TODO: these options are getting clobbered by reading in the\n    // parser object (unless it's a text file parser?)\n    Options op = new Options(ctpp);\n    op.doDep = false;\n    op.testOptions.maxLength = 90;\n\n    LexicalizedParser lp;\n    try {\n      FileFilter trainFilt = new NumberRangesFileFilter(args[1], false);\n\n      lp = LexicalizedParser.trainFromTreebank(args[0], trainFilt, op);\n      try {\n        String filename = \"chineseCharTagPCFG.ser.gz\";\n        log.info(\"Writing parser in serialized format to file \" + filename + \" \");","sourceCodeStart":127,"sourceCodeEnd":163,"githubUrl":"https://github.com/stanfordnlp/CoreNLP/blob/1b7edd19c4d0d7b1f13a2591425b9b60a0b1af7a/src/edu/stanford/nlp/trees/international/pennchinese/CharacterLevelTagExtender.java#L127-L163","documentation":"The CharacterLevelTagExtender main() requires exactly three command-line arguments: a treebank path, training file numbers, and test file numbers. When the argument count differs from 3, it deliberately aborts with this RuntimeException rather than guessing the caller's intent. It is a usage-guard error thrown before any parsing work begins.","triggerScenarios":"Running CharacterLevelTagExtender as a Java main class with fewer or more than 3 args, e.g. java edu.stanford.nlp.trees.international.pennchinese.CharacterLevelTagExtender /path/to/treebank 100 (missing testNums), or passing extra flags; a path containing unquoted spaces also splits into extra args and inflates the count.","commonSituations":"Command-line invocations of the Penn Chinese treebank tooling from shell scripts or docs where arguments were copied incompletely, or where a path containing unquoted spaces splits into multiple args and inflates the count.","solutions":["Pass exactly three arguments: treebankPath, trainNums, testNums, e.g. java CharacterLevelTagExtender /data/ctb 001-050 051-100","Quote any path containing spaces so it counts as one argument","Check the class's usage comments to confirm the expected invocation","Wrap the tool in a script that validates argument count before invoking the JVM"],"exampleFix":"// before\njava CharacterLevelTagExtender /data/ctb 100\n// after\njava CharacterLevelTagExtender /data/ctb 001-100 101-150","handlingStrategy":"validation","validationCode":"if (args == null || args.length != 3) {\n  System.err.println(\"usage: treebankPath trainNums testNums\");\n  System.exit(2);\n}","typeGuard":"boolean hasValidArgs(String[] args) { return args != null && args.length == 3; }","tryCatchPattern":null,"preventionTips":["Quote paths with spaces in shell scripts","Validate argument count in wrapper scripts before launching the JVM","Keep the documented usage line in your run scripts"],"tags":["java","cli","arguments"],"backgroundTag":"missing-required-argument","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"}