Search in sources :

Example 1 with HunspellRule

use of org.languagetool.rules.spelling.hunspell.HunspellRule 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 2 with HunspellRule

use of org.languagetool.rules.spelling.hunspell.HunspellRule 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 3 with HunspellRule

use of org.languagetool.rules.spelling.hunspell.HunspellRule in project languagetool by languagetool-org.

the class GermanSpellerRuleTest method testDashAndHyphen.

@Test
public void testDashAndHyphen() throws Exception {
    HunspellRule rule = new GermanSpellerRule(TestTools.getMessages("de"), GERMAN_DE);
    JLanguageTool lt = new JLanguageTool(GERMAN_DE);
    assertEquals(0, rule.match(lt.getAnalyzedSentence("Ist doch - gut")).length);
    assertEquals(0, rule.match(lt.getAnalyzedSentence("Ist doch -- gut")).length);
    assertEquals(0, rule.match(lt.getAnalyzedSentence("Stil- und Grammatikprüfung gut")).length);
    assertEquals(0, rule.match(lt.getAnalyzedSentence("Stil-, Text- und Grammatikprüfung gut")).length);
    assertEquals(0, rule.match(lt.getAnalyzedSentence("Er liebt die Stil-, Text- und Grammatikprüfung.")).length);
    assertEquals(0, rule.match(lt.getAnalyzedSentence("Stil-, Text- und Grammatikprüfung")).length);
    assertEquals(0, rule.match(lt.getAnalyzedSentence("Stil-, Text- oder Grammatikprüfung")).length);
    assertEquals(0, rule.match(lt.getAnalyzedSentence("Miet- und Zinseinkünfte")).length);
    assertEquals(0, rule.match(lt.getAnalyzedSentence("Haupt- und Nebensatz")).length);
    // compound with ignored word from spelling.txt
    assertEquals(0, rule.match(lt.getAnalyzedSentence("Au-pair-Agentur")).length);
    // compound with ignored word from spelling.txt
    assertEquals(0, rule.match(lt.getAnalyzedSentence("Netflix-Film")).length);
    assertEquals(0, rule.match(lt.getAnalyzedSentence("Bund-Länder-Kommission")).length);
    assertEquals(0, rule.match(lt.getAnalyzedSentence("Der westperuanische Ferienort.")).length);
    assertEquals(1, rule.match(lt.getAnalyzedSentence("Miet und Zinseinkünfte")).length);
    assertEquals(1, rule.match(lt.getAnalyzedSentence("Stil- und Grammatik gut")).length);
    assertEquals(1, rule.match(lt.getAnalyzedSentence("Flasch- und Grammatikprüfung gut")).length);
//assertEquals(1, rule.match(langTool.getAnalyzedSentence("Haupt- und Neben")).length);  // hunspell accepts this :-(
}
Also used : HunspellRule(org.languagetool.rules.spelling.hunspell.HunspellRule) JLanguageTool(org.languagetool.JLanguageTool) Test(org.junit.Test)

Example 4 with HunspellRule

use of org.languagetool.rules.spelling.hunspell.HunspellRule in project languagetool by languagetool-org.

the class GermanSpellerRuleTest method testRuleWithGermanyGerman.

// note: copied from HunspellRuleTest
@Test
public void testRuleWithGermanyGerman() throws Exception {
    HunspellRule rule = new GermanSpellerRule(TestTools.getMessages("de"), GERMAN_DE);
    JLanguageTool lt = new JLanguageTool(GERMAN_DE);
    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);
// TODO: this is a false alarm:
//assertEquals(0, rule.match(langTool.getAnalyzedSentence("Die Mozart'sche Sonate.")).length);
}
Also used : HunspellRule(org.languagetool.rules.spelling.hunspell.HunspellRule) JLanguageTool(org.languagetool.JLanguageTool) Test(org.junit.Test)

Example 5 with HunspellRule

use of org.languagetool.rules.spelling.hunspell.HunspellRule in project languagetool by languagetool-org.

the class GermanSpellerRuleTest method testGetSuggestionOrder.

@Test
public void testGetSuggestionOrder() throws Exception {
    HunspellRule rule = new GermanSpellerRule(TestTools.getMessages("de"), GERMAN_DE);
    // "heißt" should be first
    assertCorrectionsByOrder(rule, "heisst", "heißt");
    assertCorrectionsByOrder(rule, "heissen", "heißen");
    assertCorrectionsByOrder(rule, "müßte", "müsste");
    assertCorrectionsByOrder(rule, "schmohren", "schmoren");
    assertCorrectionsByOrder(rule, "Fänomen", "Phänomen");
    assertCorrectionsByOrder(rule, "homofob", "homophob");
    assertCorrectionsByOrder(rule, "ueber", "über");
    assertCorrectionsByOrder(rule, "uebel", "übel");
    assertCorrectionsByOrder(rule, "Aerger", "Ärger");
    assertCorrectionsByOrder(rule, "Walt", "Wald");
    assertCorrectionsByOrder(rule, "Rythmus", "Rhythmus");
    assertCorrectionsByOrder(rule, "Rytmus", "Rhythmus");
    // 'ist' should actually be preferred...
    assertCorrectionsByOrder(rule, "is", "iss", "in", "im", "ist");
}
Also used : HunspellRule(org.languagetool.rules.spelling.hunspell.HunspellRule) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)6 HunspellRule (org.languagetool.rules.spelling.hunspell.HunspellRule)6 JLanguageTool (org.languagetool.JLanguageTool)4 AustrianGerman (org.languagetool.language.AustrianGerman)1 SwissGerman (org.languagetool.language.SwissGerman)1