use of org.languagetool.Language in project languagetool by languagetool-org.
the class PatternRuleTest method runGrammarRulesFromXmlTest.
/**
* To be called from language modules. Languages.get() knows only the languages that's in the classpath.
* @param ignoredLanguage ignore this language - useful to speed up tests from languages that
* have another language as a dependency
*/
protected void runGrammarRulesFromXmlTest(Language ignoredLanguage) throws IOException {
int count = 0;
for (Language lang : Languages.get()) {
if (ignoredLanguage.getShortCodeWithCountryAndVariant().equals(lang.getShortCodeWithCountryAndVariant())) {
continue;
}
runGrammarRuleForLanguage(lang);
count++;
}
if (count == 0) {
System.err.println("Warning: no languages found in classpath - cannot run any grammar rule tests");
}
}
use of org.languagetool.Language in project languagetool by languagetool-org.
the class MorfologikAmericanSpellerRuleTest method testSuggestions.
@Test
public void testSuggestions() throws IOException {
Language language = new AmericanEnglish();
Rule rule = new MorfologikAmericanSpellerRule(TestTools.getMessages("en"), language);
super.testNonVariantSpecificSuggestions(rule, language);
}
use of org.languagetool.Language in project languagetool by languagetool-org.
the class MorfologikAustralianSpellerRuleTest method testSuggestions.
@Test
public void testSuggestions() throws IOException {
Language language = new AustralianEnglish();
Rule rule = new MorfologikAustralianSpellerRule(TestTools.getMessages("en"), language);
super.testNonVariantSpecificSuggestions(rule, language);
}
use of org.languagetool.Language in project languagetool by languagetool-org.
the class MorfologikNewZealandSpellerRuleTest method testSuggestions.
@Test
public void testSuggestions() throws IOException {
Language language = new NewZealandEnglish();
Rule rule = new MorfologikNewZealandSpellerRule(TestTools.getMessages("en"), language);
super.testNonVariantSpecificSuggestions(rule, language);
}
use of org.languagetool.Language in project languagetool by languagetool-org.
the class AtomFeedCheckerCmd method main.
public static void main(String[] args) throws IOException, InterruptedException {
if (args.length < 2 || args.length > 4) {
System.out.println("Usage: " + AtomFeedCheckerCmd.class.getSimpleName() + " <atomFeedUrl> <sleepTime> [database.properties] [languageModelDir]");
System.out.println(" <atomFeedUrl> is a Wikipedia URL to the latest changes, for example:");
System.out.println(" https://de.wikipedia.org/w/index.php?title=Spezial:Letzte_%C3%84nderungen&feed=atom&namespace=0");
System.out.println(" <sleepTime> -1: don't loop at all (run once), 0: run in loop, other number: run in loop and");
System.out.println(" wait this many milliseconds between runs");
System.out.println(" [database.properties] (optional) is a file that defines dbUrl, dbUser, and dbPassword,");
System.out.println(" used to write the results to a database via JDBC");
System.out.println(" [languageModelDir] (optional, use only together with database.properties) a directory with ngram");
System.out.println(" sub directories, activates the confusion rule if supported");
System.out.println("");
System.out.println(" When the database.properties file is specified, this command will store all feed changes that");
System.out.println(" cause LanguageTool rule matches to the database. If an error is then fixed later, this will");
System.out.println(" usually also be detected and the rule match in the database will be marked as fixed. One case");
System.out.println(" where this does not work is if the context of the error gets modified before the error is fixed.");
System.out.println("");
System.out.println(" Run this command regularly so that you don't miss any changes from the feed.");
System.out.println(" As the feed may contain only the latest 50 changes, running it more often than");
System.out.println(" once per minute may be needed for active Wikipedias.");
System.exit(1);
}
String url = args[0];
String langCode = url.substring(url.indexOf("//") + 2, url.indexOf("."));
System.out.println("Using URL: " + url);
System.out.println("Language code: " + langCode);
int sleepTimeMillis = Integer.parseInt(args[1]);
System.out.println("Sleep time: " + sleepTimeMillis + "ms (-1 = don't loop)");
System.out.println("LanguageTool version: " + JLanguageTool.VERSION + " (" + JLanguageTool.BUILD_DATE + ")");
DatabaseConfig databaseConfig = null;
if (args.length >= 3) {
String propFile = args[2];
databaseConfig = new DatabaseConfig(propFile);
System.out.println("Writing results to database at: " + databaseConfig.getUrl());
}
AtomFeedChecker atomFeedChecker;
Language language = Languages.getLanguageForShortCode(langCode);
if (args.length == 4) {
String languageModelDir = args[3];
atomFeedChecker = new AtomFeedChecker(language, databaseConfig, new File(languageModelDir));
} else {
atomFeedChecker = new AtomFeedChecker(language, databaseConfig);
}
while (true) {
long startTime = System.currentTimeMillis();
try {
atomFeedChecker.runCheck(url);
System.out.println("Run time: " + (System.currentTimeMillis() - startTime) + "ms");
if (sleepTimeMillis == -1) {
// don't loop at all
break;
} else {
System.out.println("Sleeping " + sleepTimeMillis + "ms...");
Thread.sleep(sleepTimeMillis);
}
} catch (Exception e) {
// e.g. 50x HTTP errors, network problems
e.printStackTrace();
System.out.println("Sleeping " + sleepTimeMillis + "ms...");
Thread.sleep(sleepTimeMillis);
}
}
}
Aggregations