.create();
try {
Parser parser = new Parser();
parser.setGroup(group);
CommandLine cmdLine = parser.parse(args);
if (cmdLine.hasOption(helpOpt)) {
CommandLineUtil.printHelp(group);
return;
}
File inputDir = new File(cmdLine.getValue(inputOpt).toString());
if (!inputDir.isDirectory()) {
throw new IllegalArgumentException(inputDir + " does not exist or is not a directory");
}
File categoryFile = new File(cmdLine.getValue(categoryOpt).toString());
if (!categoryFile.isFile()) {
throw new IllegalArgumentException(categoryFile + " does not exist or is not a directory");
}
File outputDir = new File(cmdLine.getValue(outputOpt).toString());
outputDir.mkdirs();
if (!outputDir.isDirectory()) {
throw new IllegalArgumentException(outputDir + " is not a directory or could not be created");
}
Collection<String> categoryFields = stringToList(cmdLine.getValue(categoryFieldsOpt).toString());
if (categoryFields.size() < 1) {
throw new IllegalArgumentException("At least one category field must be spcified.");
}
Collection<String> textFields = stringToList(cmdLine.getValue(textFieldsOpt).toString());
if (categoryFields.size() < 1) {
throw new IllegalArgumentException("At least one text field must be spcified.");
}
boolean useTermVectors = cmdLine.hasOption(useTermVectorsOpt);
extractTraininingData(inputDir, categoryFile, categoryFields, textFields, outputDir, useTermVectors);
} catch (OptionException e) {
log.error("Exception", e);