}
private void run(File propFile, Set<String> disabledRules, String langCode, List<String> fileNames, String[] ruleIds,
String[] additionalCategoryIds, int maxSentences, int maxErrors, File languageModelDir) throws IOException {
final Language lang = Language.getLanguageForShortName(langCode);
final JLanguageTool languageTool = new MultiThreadedJLanguageTool(lang);
languageTool.activateDefaultPatternRules();
if (languageModelDir != null) {
languageTool.activateLanguageModelRules(languageModelDir);
}
if (ruleIds != null) {
enableOnlySpecifiedRules(ruleIds, languageTool);
} else {
applyRuleDeactivation(languageTool, disabledRules);
}
activateAdditionalCategories(additionalCategoryIds, languageTool);
disableSpellingRules(languageTool);
System.out.println("Working on: " + StringUtils.join(fileNames, ", "));
System.out.println("Sentence limit: " + (maxSentences > 0 ? maxSentences : "no limit"));
System.out.println("Error limit: " + (maxErrors > 0 ? maxErrors : "no limit"));
ResultHandler resultHandler = null;
int ruleMatchCount = 0;
int sentenceCount = 0;
try {
if (propFile != null) {
resultHandler = new DatabaseHandler(propFile, maxSentences, maxErrors);
} else {
resultHandler = new StdoutHandler(maxSentences, maxErrors);
}
MixingSentenceSource mixingSource = MixingSentenceSource.create(fileNames, lang);
while (mixingSource.hasNext()) {
Sentence sentence = mixingSource.next();
try {
List<RuleMatch> matches = languageTool.check(sentence.getText());
resultHandler.handleResult(sentence, matches, lang);
sentenceCount++;
if (sentenceCount % 5000 == 0) {
System.err.printf("%s sentences checked...\n", NumberFormat.getNumberInstance(Locale.US).format(sentenceCount));
}