use of org.languagetool.language.German in project languagetool by languagetool-org.
the class IndexerSearcherTest method testForDebugging.
@Ignore("manual debugging only")
public void testForDebugging() throws Exception {
// Note that the second sentence ends with "lid" instead of "lids" (the inflated one)
//createIndex("I thin so");
useRealIndex();
German language = new German();
PatternRule rule = getFirstRule("I_THIN", language);
SearcherResult searcherResult = errorSearcher.findRuleMatchesOnIndex(rule, language);
System.out.println("Matches: " + searcherResult.getMatchingSentences());
}
use of org.languagetool.language.German in project languagetool by languagetool-org.
the class WikipediaQuickCheckTest method testCheckWikipediaMarkup.
@Test
public void testCheckWikipediaMarkup() throws IOException {
WikipediaQuickCheck check = new WikipediaQuickCheck();
String markup = "== Beispiele ==\n\n" + "Eine kleine Auswahl von Fehlern.\n\n" + "Das Komma ist richtig, wegen dem Leerzeichen.";
MediaWikiContent wikiContent = new MediaWikiContent(markup, "2012-11-11T20:00:00");
ErrorMarker errorMarker = new ErrorMarker("<err>", "</err>");
MarkupAwareWikipediaResult result = check.checkWikipediaMarkup(new URL("http://fake-url.org"), wikiContent, new German(), errorMarker);
assertThat(result.getLastEditTimestamp(), is("2012-11-11T20:00:00"));
List<AppliedRuleMatch> appliedMatches = result.getAppliedRuleMatches();
// even though this error has no suggestion, there's a (pseudo) correction:
assertThat(appliedMatches.size(), is(1));
AppliedRuleMatch firstAppliedMatch = appliedMatches.get(0);
assertThat(firstAppliedMatch.getRuleMatchApplications().size(), is(1));
RuleMatchApplication ruleMatchApplication = firstAppliedMatch.getRuleMatchApplications().get(0);
assertTrue("Got: " + ruleMatchApplication.getTextWithCorrection(), ruleMatchApplication.getTextWithCorrection().contains("<err>wegen dem</err> Leerzeichen."));
assertThat(ruleMatchApplication.getOriginalErrorContext(12), is("st richtig, <err>wegen dem</err> Leerz"));
assertThat(ruleMatchApplication.getCorrectedErrorContext(12), is("st richtig, <err>wegen dem</err> Leerz"));
}
use of org.languagetool.language.German in project languagetool by languagetool-org.
the class AtomFeedCheckerTest method testCheck.
@Test
public void testCheck() throws IOException {
AtomFeedChecker atomFeedChecker = new AtomFeedChecker(new German());
CheckResult checkResult = atomFeedChecker.checkChanges(getStream());
List<ChangeAnalysis> changeAnalysis = checkResult.getCheckResults();
assertThat(changeAnalysis.size(), is(3));
assertThat(changeAnalysis.get(0).getAddedMatches().size(), is(1));
assertThat(changeAnalysis.get(0).getAddedMatches().get(0).getRule().getId(), is("DE_AGREEMENT"));
assertTrue(changeAnalysis.get(0).getAddedMatches().get(0).getErrorContext().contains("Fehler: <err>der Haus</err>"));
assertThat(changeAnalysis.get(0).getRemovedMatches().size(), is(0));
assertThat(changeAnalysis.get(1).getAddedMatches().size(), is(0));
assertThat(changeAnalysis.get(1).getRemovedMatches().size(), is(0));
assertThat(changeAnalysis.get(2).getAddedMatches().size(), is(0));
assertThat(changeAnalysis.get(2).getRemovedMatches().size(), is(0));
CheckResult checkResult2 = atomFeedChecker.checkChanges(getStream());
List<ChangeAnalysis> changeAnalysis2 = checkResult2.getCheckResults();
// not skipped because no database is used
assertThat(changeAnalysis2.size(), is(3));
}
use of org.languagetool.language.German in project languagetool by languagetool-org.
the class AtomFeedCheckerTest method testCheckToDatabase.
@Test
public void testCheckToDatabase() throws IOException, SQLException {
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm");
dateFormat.setTimeZone(TimeZone.getTimeZone("Europe/Berlin"));
initDatabase();
DatabaseConfig databaseConfig = new DatabaseConfig(DB_URL, "user", "pass");
AtomFeedChecker atomFeedChecker1 = new AtomFeedChecker(new German(), databaseConfig);
CheckResult checkResult = atomFeedChecker1.runCheck(getStream());
List<ChangeAnalysis> changeAnalysis = checkResult.getCheckResults();
assertThat(changeAnalysis.size(), is(3));
assertThat(changeAnalysis.get(0).getAddedMatches().size(), is(1));
assertThat(changeAnalysis.get(0).getAddedMatches().get(0).getRule().getId(), is("DE_AGREEMENT"));
assertTrue(changeAnalysis.get(0).getAddedMatches().get(0).getErrorContext().contains("Fehler: <err>der Haus</err>"));
assertThat(changeAnalysis.get(0).getRemovedMatches().size(), is(0));
assertThat(changeAnalysis.get(1).getAddedMatches().size(), is(0));
assertThat(changeAnalysis.get(1).getRemovedMatches().size(), is(0));
assertThat(changeAnalysis.get(2).getAddedMatches().size(), is(0));
assertThat(changeAnalysis.get(2).getRemovedMatches().size(), is(0));
Date latestCheckDate1 = atomFeedChecker1.getDatabase().getCheckDates().get("de");
assertThat(dateFormat.format(latestCheckDate1), is("2013-12-03 10:48"));
AtomFeedChecker atomFeedChecker2 = new AtomFeedChecker(new German(), databaseConfig);
CheckResult checkResult2 = atomFeedChecker2.runCheck(getStream());
List<ChangeAnalysis> changeAnalysis2 = checkResult2.getCheckResults();
// All articles could be skipped as they have been checked in the previous run:
assertThat(changeAnalysis2.size(), is(0));
assertThat(atomFeedChecker2.getDatabase().getCheckDates().size(), is(1));
Date latestCheckDate2 = atomFeedChecker2.getDatabase().getCheckDates().get("de");
assertThat(dateFormat.format(latestCheckDate2), is("2013-12-03 10:48"));
}
use of org.languagetool.language.German in project languagetool by languagetool-org.
the class HunspellRuleTest method testRuleWithAustrianGerman.
@Test
public void testRuleWithAustrianGerman() throws Exception {
HunspellRule rule = new HunspellRule(TestTools.getMessages("de"), new AustrianGerman());
JLanguageTool langTool = new JLanguageTool(new German());
commonGermanAsserts(rule, langTool);
// umlauts
assertEquals(0, rule.match(langTool.getAnalyzedSentence("Der äußere Übeltäter.")).length);
assertEquals(1, rule.match(langTool.getAnalyzedSentence("Der äussere Übeltäter.")).length);
}
Aggregations