Search in sources :

Example 11 with German

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());
}
Also used : PatternRule(org.languagetool.rules.patterns.PatternRule) German(org.languagetool.language.German) Ignore(org.junit.Ignore)

Example 12 with German

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"));
}
Also used : German(org.languagetool.language.German) URL(java.net.URL) Test(org.junit.Test)

Example 13 with German

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));
}
Also used : German(org.languagetool.language.German) Test(org.junit.Test)

Example 14 with German

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"));
}
Also used : German(org.languagetool.language.German) SimpleDateFormat(java.text.SimpleDateFormat) Date(java.util.Date) Test(org.junit.Test)

Example 15 with German

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);
}
Also used : JLanguageTool(org.languagetool.JLanguageTool) SwissGerman(org.languagetool.language.SwissGerman) AustrianGerman(org.languagetool.language.AustrianGerman) German(org.languagetool.language.German) GermanyGerman(org.languagetool.language.GermanyGerman) AustrianGerman(org.languagetool.language.AustrianGerman) Test(org.junit.Test)

Aggregations

German (org.languagetool.language.German)26 Test (org.junit.Test)19 JLanguageTool (org.languagetool.JLanguageTool)16 GermanyGerman (org.languagetool.language.GermanyGerman)5 Before (org.junit.Before)3 AustrianGerman (org.languagetool.language.AustrianGerman)3 SwissGerman (org.languagetool.language.SwissGerman)3 Ignore (org.junit.Ignore)2 RuleMatch (org.languagetool.rules.RuleMatch)2 File (java.io.File)1 IOException (java.io.IOException)1 URL (java.net.URL)1 SimpleDateFormat (java.text.SimpleDateFormat)1 ArrayList (java.util.ArrayList)1 Date (java.util.Date)1 Dictionary (morfologik.stemming.Dictionary)1 DictionaryLookup (morfologik.stemming.DictionaryLookup)1 WordData (morfologik.stemming.WordData)1 BeforeClass (org.junit.BeforeClass)1 AnalyzedToken (org.languagetool.AnalyzedToken)1