{"record":{"id":"b31c1d397450ec92","repo":"stanfordnlp/CoreNLP","slug":"error-no-training-file-provided-in-properties-or-b31c1d","errorCode":null,"errorMessage":"Error: No training file provided in properties or via command line.","messagePattern":"Error: No training file provided in properties or via command line\\.","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/edu/stanford/nlp/process/stattok/StatTokSentTrainer.java","lineNumber":421,"sourceCode":"   * Properties for the ColumnDataClassifier are specified in the same properties file, and follows properties of the original CoreNLP class.\n   */\n  public static void main(String[] args) throws IOException{\n\n    StatTokSentTrainer trainTokenizer = new StatTokSentTrainer(args);\n\n    Properties properties \t= StringUtils.argsToProperties(args);\n    String trainFile \t\t= properties.getProperty(\"trainFile\", null);\n    String multiWordRulesFile \t= properties.getProperty(\"multiWordRulesFile\", null);\n    int windowSize \t\t= Integer.parseInt(properties.getProperty(\"windowSize\", \"4\")); //must reflect actual n. of features\n    boolean inferMultiWordRules = Integer.parseInt(properties.getProperty(\"inferMultiWordRules\", \"0\")) != 0;\n\n    if (properties.getProperty(\"help\", null) != null) {\n      help();\n      return;\n    }\n\n    if (trainFile == null){\n      logger.err(\"Error: No training file provided in properties or via command line.\");\n      return;\n    }\n\n    Map<String, String[]> multiWordRules = new HashMap<String, String[]>();\n    // Read or generate multi-word rules\n    if (multiWordRulesFile != null){\n      if (inferMultiWordRules){\n        logger.warn(\"Conflicting properties. Multi-word rules file will be considered.\");\n      }\n      logger.info(\"Reading Multi-Word rules file ... \");\n      multiWordRules = trainTokenizer.readMultiWordRules(multiWordRulesFile);\n    } else {\n      if (inferMultiWordRules){\n        logger.info(\"Inferring Multi-Word rules from training set ... \");\n        multiWordRules = trainTokenizer.inferMultiWordRules(trainFile);\n      }\n      else{\n        logger.warn(\"No multi-word rules provided. No inferMultiWordRules flag validated. Not inferring rules from training.\");","sourceCodeStart":403,"sourceCodeEnd":439,"githubUrl":"https://github.com/stanfordnlp/CoreNLP/blob/1b7edd19c4d0d7b1f13a2591425b9b60a0b1af7a/src/edu/stanford/nlp/process/stattok/StatTokSentTrainer.java#L403-L439","documentation":"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.","triggerScenarios":"Running StatTokSentTrainer without -trainFile <path> (a CoNLL-U format file), so the parsed trainFile property is null at the check near line 421.","commonSituations":"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.","solutions":["Supply -trainFile path/to/train.conllu on the command line.","Confirm flag spelling is exactly 'trainFile'.","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.","Consult help() output (pass -help) for the full required flag set."],"exampleFix":"// before\njava -cp ... StatTokSentTrainer -serializeTo tok.model\n// after\njava -cp ... StatTokSentTrainer -trainFile train.conllu -serializeTo tok.model","handlingStrategy":"validation","validationCode":"Properties p = StringUtils.argsToProperties(args);\nString train = p.getProperty(\"trainFile\");\nif (train == null || !new File(train).canRead()) {\n    throw new IllegalArgumentException(\"-trainFile must point to a readable CoNLL-U file\");\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Assert input file existence and readability in the invoking script.","Keep one documented training command per language.","Remember trainFileIOB and trainFile are different flags for different tools."],"tags":["java","cli","missing-argument","training"],"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"}