{"record":{"id":"db0962c7033532bb","repo":"stanfordnlp/CoreNLP","slug":"must-specify-a-treebank-to-train-from-with-traint","errorCode":null,"errorMessage":"Must specify a treebank to train from with -trainTreebank or a parser to load with -serializedPath","messagePattern":"Must specify a treebank to train from with -trainTreebank or a parser to load with -serializedPath","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"src/edu/stanford/nlp/parser/shiftreduce/ShiftReduceParser.java","lineNumber":642,"sourceCode":"        serializedPath = args[argIndex + 1];\n        argIndex += 2;\n      } else if (args[argIndex].equalsIgnoreCase(\"-tlpp\")) {\n        tlppClass = args[argIndex + 1];\n        argIndex += 2;\n      } else if (args[argIndex].equalsIgnoreCase(\"-continueTraining\")) {\n        continueTraining = args[argIndex + 1];\n        argIndex += 2;\n      } else {\n        remainingArgs.add(args[argIndex]);\n        ++argIndex;\n      }\n    }\n\n    String[] newArgs = new String[remainingArgs.size()];\n    newArgs = remainingArgs.toArray(newArgs);\n\n    if (trainTreebankPath == null && serializedPath == null) {\n      throw new IllegalArgumentException(\"Must specify a treebank to train from with -trainTreebank or a parser to load with -serializedPath\");\n    }\n\n    ShiftReduceParser parser = null;\n\n    if (trainTreebankPath != null) {\n      log.info(\"Training ShiftReduceParser\");\n      log.info(\"Initial arguments:\");\n      log.info(\"   \" + StringUtils.join(args));\n      if (continueTraining != null) {\n        parser = ShiftReduceParser.loadModel(continueTraining, ArrayUtils.concatenate(BASIC_TRAINING_OPTIONS, newArgs));\n      } else {\n        ShiftReduceOptions op = buildTrainingOptions(tlppClass, newArgs);\n        parser = new ShiftReduceParser(op);\n      }\n      Timing trainingTimer = new Timing();\n      parser.train(trainTreebankPath, devTreebankPath, serializedPath);\n      trainingTimer.done(\"Overall training process\");\n      parser.saveModel(serializedPath);","sourceCodeStart":624,"sourceCodeEnd":660,"githubUrl":"https://github.com/stanfordnlp/CoreNLP/blob/1b7edd19c4d0d7b1f13a2591425b9b60a0b1af7a/src/edu/stanford/nlp/parser/shiftreduce/ShiftReduceParser.java#L624-L660","documentation":"ShiftReduceParser.main is the command-line entry point for training or loading a shift-reduce parser. It requires either a training treebank path (-trainTreebank) to train a new model, or a serialized parser path (-serializedPath) to load an existing one. If neither is given it cannot do anything meaningful and throws IllegalArgumentException.","triggerScenarios":"Running java edu.stanford.nlp.parser.shiftreduce.ShiftReduceParser (or Main) with neither -trainTreebank nor -serializedPath on the command line.","commonSituations":"Mis-typed CLI flags (e.g. -trainTreeBank with wrong case), an options file whose values weren't passed through, or a script that dropped the model path argument.","solutions":["Pass -trainTreebank <path> to train a new parser from treebank data","Or pass -serializedPath <model.ser.gz> to load an existing parser","Verify flag spelling and that your launcher script actually forwards the arguments"],"exampleFix":"// before\njava edu.stanford.nlp.parser.shiftreduce.ShiftReduceParser -trainingMethod BEAM\n\n// after\njava edu.stanford.nlp.parser.shiftreduce.ShiftReduceParser -serializedPath model.ser.gz -testTreebank tests/treebank","handlingStrategy":"validation","validationCode":"if (args == null || (Arrays.stream(args).noneMatch(a -> a.startsWith(\"-trainTreebank\"))\n    && Arrays.stream(args).noneMatch(a -> a.startsWith(\"-serializedPath\")))) {\n  throw new IllegalArgumentException(\"Usage: ShiftReduceParser -trainTreebank <path> | -serializedPath <model>\");\n}","typeGuard":null,"tryCatchPattern":"try {\n  ShiftReduceParser.main(args);\n} catch (IllegalArgumentException e) {\n  log.severe(\"Usage: must pass -trainTreebank or -serializedPath\");\n  System.exit(2);\n}","preventionTips":["Wrap the CLI in a script that validates required flags","Watch for flag case-sensitivity typos","Document both invocation modes (train vs load)"],"tags":["parser","cli","missing-argument","configuration"],"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"}