Search in sources :

Example 26 with JLanguageTool

use of org.languagetool.JLanguageTool in project languagetool by languagetool-org.

the class AvsAnRuleTest method setUp.

@Before
public void setUp() throws IOException {
    rule = new AvsAnRule(TestTools.getEnglishMessages());
    langTool = new JLanguageTool(new English());
}
Also used : English(org.languagetool.language.English) JLanguageTool(org.languagetool.JLanguageTool) Before(org.junit.Before)

Example 27 with JLanguageTool

use of org.languagetool.JLanguageTool in project languagetool by languagetool-org.

the class GermanSpellerRuleTest method testRuleWithAustrianGerman.

// note: copied from HunspellRuleTest
@Test
public void testRuleWithAustrianGerman() throws Exception {
    AustrianGerman language = new AustrianGerman();
    HunspellRule rule = new GermanSpellerRule(TestTools.getMessages("de"), language);
    JLanguageTool lt = new JLanguageTool(language);
    commonGermanAsserts(rule, lt);
    // umlauts
    assertEquals(0, rule.match(lt.getAnalyzedSentence("Der äußere Übeltäter.")).length);
    assertEquals(1, rule.match(lt.getAnalyzedSentence("Der äussere Übeltäter.")).length);
}
Also used : HunspellRule(org.languagetool.rules.spelling.hunspell.HunspellRule) JLanguageTool(org.languagetool.JLanguageTool) AustrianGerman(org.languagetool.language.AustrianGerman) Test(org.junit.Test)

Example 28 with JLanguageTool

use of org.languagetool.JLanguageTool in project languagetool by languagetool-org.

the class GermanSpellerRuleTest method testRuleWithSwissGerman.

// note: copied from HunspellRuleTest
@Test
public void testRuleWithSwissGerman() throws Exception {
    SwissGerman language = new SwissGerman();
    HunspellRule rule = new GermanSpellerRule(TestTools.getMessages("de"), language);
    JLanguageTool lt = new JLanguageTool(language);
    commonGermanAsserts(rule, lt);
    // ß not allowed in Swiss
    assertEquals(1, rule.match(lt.getAnalyzedSentence("Der äußere Übeltäter.")).length);
    // ss is used instead of ß
    assertEquals(0, rule.match(lt.getAnalyzedSentence("Der äussere Übeltäter.")).length);
}
Also used : SwissGerman(org.languagetool.language.SwissGerman) HunspellRule(org.languagetool.rules.spelling.hunspell.HunspellRule) JLanguageTool(org.languagetool.JLanguageTool) Test(org.junit.Test)

Example 29 with JLanguageTool

use of org.languagetool.JLanguageTool in project languagetool by languagetool-org.

the class MissingVerbRuleTest method test.

@Test
public void test() throws IOException {
    JLanguageTool lt = new JLanguageTool(new German());
    assertGood("Da ist ein Verb, mal so zum testen.", lt);
    assertGood("Überschrift ohne Verb aber doch nicht zu kurz", lt);
    assertGood("Sprechen Sie vielleicht zufällig Türkisch?", lt);
    assertGood("Leg den Tresor in den Koffer im Kofferraum.", lt);
    assertGood("Bring doch einfach deine Kinder mit.", lt);
    // no verb, but very short
    assertGood("Gut so.", lt);
    // no verb, but very short
    assertGood("Ja!", lt);
    assertGood("Vielen Dank für alles, was Du für mich getan hast.", lt);
    assertGood("Herzlichen Glückwunsch zu Deinem zwanzigsten Geburtstag.", lt);
    assertBad("Dieser Satz kein Verb.", lt);
    assertBad("Aus einer Idee sich erste Wortgruppen, aus Wortgruppen einzelne Sätze, aus Sätzen ganze Texte.", lt);
    assertBad("Ich ein neues Rad.", lt);
//assertBad("Ich einen neuen Fehler gefunden.", lt);  // see issue #42
}
Also used : JLanguageTool(org.languagetool.JLanguageTool) German(org.languagetool.language.German) Test(org.junit.Test)

Example 30 with JLanguageTool

use of org.languagetool.JLanguageTool in project languagetool by languagetool-org.

the class MorfologikGermanyGermanSpellerRuleTest method testMorfologikSpeller.

@Test
public void testMorfologikSpeller() throws IOException {
    MorfologikGermanyGermanSpellerRule rule = new MorfologikGermanyGermanSpellerRule(TestTools.getMessages("en"), new German());
    JLanguageTool lt = new JLanguageTool(new German());
    assertEquals(0, rule.match(lt.getAnalyzedSentence("Hier stimmt jedes Wort!")).length);
    assertEquals(1, rule.match(lt.getAnalyzedSentence("Hir nicht so ganz.")).length);
    assertEquals(0, rule.match(lt.getAnalyzedSentence("Überall äußerst böse Umlaute!")).length);
    assertEquals(1, rule.match(lt.getAnalyzedSentence("Üperall äußerst böse Umlaute!")).length);
    RuleMatch[] matches = rule.match(lt.getAnalyzedSentence("daß"));
    assertEquals(1, matches.length);
    assertEquals("dass", matches[0].getSuggestedReplacements().get(0));
}
Also used : RuleMatch(org.languagetool.rules.RuleMatch) JLanguageTool(org.languagetool.JLanguageTool) German(org.languagetool.language.German) Test(org.junit.Test)

Aggregations

JLanguageTool (org.languagetool.JLanguageTool)184 Test (org.junit.Test)109 RuleMatch (org.languagetool.rules.RuleMatch)57 Before (org.junit.Before)38 German (org.languagetool.language.German)16 Rule (org.languagetool.rules.Rule)16 Catalan (org.languagetool.language.Catalan)14 Ukrainian (org.languagetool.language.Ukrainian)14 English (org.languagetool.language.English)13 Polish (org.languagetool.language.Polish)12 Language (org.languagetool.Language)10 GermanyGerman (org.languagetool.language.GermanyGerman)9 PatternRule (org.languagetool.rules.patterns.PatternRule)9 AnalyzedSentence (org.languagetool.AnalyzedSentence)8 File (java.io.File)7 AnalyzedTokenReadings (org.languagetool.AnalyzedTokenReadings)6 Dutch (org.languagetool.language.Dutch)5 French (org.languagetool.language.French)5 ArrayList (java.util.ArrayList)4 FakeLanguage (org.languagetool.FakeLanguage)4