Search in sources :

Example 1 with German

use of org.languagetool.language.German in project languagetool by languagetool-org.

the class GermanTaggerEnhancer method run.

private void run() throws IOException {
    final Dictionary dictionary = Dictionary.read(JLanguageTool.getDataBroker().getFromResourceDirAsUrl("/de/german.dict"));
    final DictionaryLookup dl = new DictionaryLookup(dictionary);
    Tagger tagger = new German().getTagger();
    String prev = null;
    for (WordData wd : dl) {
        String word = wd.getWord().toString();
        if (word.endsWith("er") && StringTools.startsWithUppercase(word)) {
            if (!hasAdjReading(tagger, word) && isEigenname(tagger, word.substring(0, word.length() - 2)) && !word.equals(prev)) {
                for (String newTags : ADJ_READINGS) {
                    System.out.println(word + "\t" + word + "\t" + newTags + ":DEF");
                    System.out.println(word + "\t" + word + "\t" + newTags + ":IND");
                    System.out.println(word + "\t" + word + "\t" + newTags + ":SOL");
                }
                prev = word;
            }
        }
    }
}
Also used : Dictionary(morfologik.stemming.Dictionary) Tagger(org.languagetool.tagging.Tagger) WordData(morfologik.stemming.WordData) German(org.languagetool.language.German) DictionaryLookup(morfologik.stemming.DictionaryLookup)

Example 2 with German

use of org.languagetool.language.German 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 3 with German

use of org.languagetool.language.German 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)

Example 4 with German

use of org.languagetool.language.German in project languagetool by languagetool-org.

the class HunspellRuleTest method testRuleWithGerman.

@Test
public void testRuleWithGerman() throws Exception {
    HunspellRule rule = new HunspellRule(TestTools.getMessages("de"), new GermanyGerman());
    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);
    // ignore URLs:
    assertEquals(0, rule.match(langTool.getAnalyzedSentence("Unter http://foo.org/bar steht was.")).length);
    assertEquals(1, rule.match(langTool.getAnalyzedSentence("dasdassda http://foo.org/bar steht was.")).length);
    assertEquals(1, rule.match(langTool.getAnalyzedSentence("Unter http://foo.org/bar steht dasdassda.")).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) GermanyGerman(org.languagetool.language.GermanyGerman) Test(org.junit.Test)

Example 5 with German

use of org.languagetool.language.German in project languagetool by languagetool-org.

the class SentenceWhitespaceRuleTest method testMatch.

@Test
public void testMatch() throws Exception {
    JLanguageTool lt = new JLanguageTool(new German());
    TestTools.disableAllRulesExcept(lt, "DE_SENTENCE_WHITESPACE");
    assertGood("Das ist ein Satz. Und hier der nächste.", lt);
    assertGood("Das ist ein Satz! Und hier der nächste.", lt);
    assertGood("Ist das ein Satz? Hier der nächste.", lt);
    assertBad("Das ist ein Satz.Und hier der nächste.", lt);
    assertBad("Das ist ein Satz!Und hier der nächste.", lt);
    assertBad("Ist das ein Satz?Hier der nächste.", lt);
    assertGood("Am 28. September.", lt);
    assertBad("Am 28.September.", lt);
    assertTrue(lt.check("Am 7.September 2014.").get(0).getMessage().contains("nach Ordnungszahlen"));
    assertTrue(lt.check("Im September.Dann der nächste Satz.").get(0).getMessage().contains("zwischen Sätzen"));
}
Also used : JLanguageTool(org.languagetool.JLanguageTool) German(org.languagetool.language.German) 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