stanfordnlp/CoreNLP · error

Error: No training file provided in properties or via…

Error message

Error: No training file provided in properties or via command line.

What it means

StatTokSentTrainer.main trains the statistical tokenizer/sentence splitter and requires a training file via the 'trainFile' property. If it is null, it logs this error and returns. Unlike BuildMultiWordRules, the message has no --trainFile suffix but the requirement is the same: no training data, no training.

Solutions

  1. Supply -trainFile path/to/train.conllu on the command line.
  2. Confirm flag spelling is exactly 'trainFile'.
  3. Verify the file exists and is readable; a valid but missing file still won't satisfy this null check if the path arg was omitted entirely.
  4. Consult help() output (pass -help) for the full required flag set.

Example fix

// before
java -cp ... StatTokSentTrainer -serializeTo tok.model
// after
java -cp ... StatTokSentTrainer -trainFile train.conllu -serializeTo tok.model
Defensive patterns

Strategy: validation

Validate before calling

Properties p = StringUtils.argsToProperties(args);
String train = p.getProperty("trainFile");
if (train == null || !new File(train).canRead()) {
    throw new IllegalArgumentException("-trainFile must point to a readable CoNLL-U file");
}

Prevention

When it happens

Trigger: Running StatTokSentTrainer without -trainFile <path> (a CoNLL-U format file), so the parsed trainFile property is null at the check near line 421.

Common situations: Passing a generic properties file lacking trainFile; using -testFile or -trainFileIOB alone assuming they substitute for the training input; scripting the trainer with flags copied from a different Stanford tool.

Understand the failure class

Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.

Related errors


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

Appendix: source

Thrown at src/edu/stanford/nlp/process/stattok/StatTokSentTrainer.java:421

   * Properties for the ColumnDataClassifier are specified in the same properties file, and follows properties of the original CoreNLP class.
   */
  public static void main(String[] args) throws IOException{

    StatTokSentTrainer trainTokenizer = new StatTokSentTrainer(args);

    Properties properties 	= StringUtils.argsToProperties(args);
    String trainFile 		= properties.getProperty("trainFile", null);
    String multiWordRulesFile 	= properties.getProperty("multiWordRulesFile", null);
    int windowSize 		= Integer.parseInt(properties.getProperty("windowSize", "4")); //must reflect actual n. of features
    boolean inferMultiWordRules = Integer.parseInt(properties.getProperty("inferMultiWordRules", "0")) != 0;

    if (properties.getProperty("help", null) != null) {
      help();
      return;
    }

    if (trainFile == null){
      logger.err("Error: No training file provided in properties or via command line.");
      return;
    }

    Map<String, String[]> multiWordRules = new HashMap<String, String[]>();
    // Read or generate multi-word rules
    if (multiWordRulesFile != null){
      if (inferMultiWordRules){
        logger.warn("Conflicting properties. Multi-word rules file will be considered.");
      }
      logger.info("Reading Multi-Word rules file ... ");
      multiWordRules = trainTokenizer.readMultiWordRules(multiWordRulesFile);
    } else {
      if (inferMultiWordRules){
        logger.info("Inferring Multi-Word rules from training set ... ");
        multiWordRules = trainTokenizer.inferMultiWordRules(trainFile);
      }
      else{
        logger.warn("No multi-word rules provided. No inferMultiWordRules flag validated. Not inferring rules from training.");

View on GitHub (pinned to 1b7edd19c4)