Search in sources :

Example 21 with German

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

the class GermanWordRepeatBeginningRuleTest method testRule.

@Test
public void testRule() throws IOException {
    JLanguageTool lt = new JLanguageTool(new German());
    // correct sentences:
    assertEquals(0, lt.check("Er ist nett. Er heißt Max.").size());
    assertEquals(0, lt.check("Außerdem kommt er. Ferner kommt sie. Außerdem kommt es.").size());
    assertEquals(0, lt.check("2011: Dieses passiert. 2011: Jenes passiert. 2011: Nicht passiert").size());
    // errors:
    assertEquals(1, lt.check("Er ist nett. Er heißt Max. Er ist 11.").size());
    assertEquals(1, lt.check("Außerdem kommt er. Außerdem kommt sie.").size());
    // this used to cause false alarms because reset() was not implemented
    assertEquals(0, lt.check("Außerdem ist das ein neuer Text.").size());
}
Also used : JLanguageTool(org.languagetool.JLanguageTool) German(org.languagetool.language.German) Test(org.junit.Test)

Example 22 with German

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

the class GermanWrongWordInContextRuleTest method setUp.

@Before
public void setUp() throws IOException {
    langTool = new JLanguageTool(new German());
    rule = new GermanWrongWordInContextRule(null);
}
Also used : JLanguageTool(org.languagetool.JLanguageTool) German(org.languagetool.language.German) Before(org.junit.Before)

Example 23 with German

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

the class JLanguageToolTest method testPositionsWithGerman.

@Test
public void testPositionsWithGerman() throws IOException {
    JLanguageTool tool = new JLanguageTool(new German());
    List<RuleMatch> matches = tool.check("Stundenkilometer");
    assertEquals(1, matches.size());
    RuleMatch match = matches.get(0);
    assertEquals(0, match.getLine());
    assertEquals(1, match.getColumn());
}
Also used : RuleMatch(org.languagetool.rules.RuleMatch) German(org.languagetool.language.German) GermanyGerman(org.languagetool.language.GermanyGerman) Test(org.junit.Test)

Example 24 with German

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

the class AgreementSuggestorTest method assertSuggestion.

private void assertSuggestion(String input, String expectedSuggestions) {
    String[] tokens = input.split(" ");
    List<AnalyzedTokenReadings> tokenReadings = new ArrayList<>();
    int pos = 0;
    for (String inputToken : tokens) {
        String[] parts = inputToken.split("/");
        String token = parts[0];
        String lemma = parts[1];
        String posTag = parts[2];
        tokenReadings.add(new AnalyzedTokenReadings(new AnalyzedToken(token, posTag, lemma), pos++));
    }
    if (tokenReadings.size() != 2) {
        throw new RuntimeException("Size of input not yet supported: " + tokenReadings.size());
    }
    AgreementSuggestor suggestor = new AgreementSuggestor(new German().getSynthesizer(), tokenReadings.get(0), tokenReadings.get(1));
    List<String> suggestions = suggestor.getSuggestions();
    assertThat(suggestions.toString(), is(expectedSuggestions));
}
Also used : AnalyzedToken(org.languagetool.AnalyzedToken) ArrayList(java.util.ArrayList) German(org.languagetool.language.German) AnalyzedTokenReadings(org.languagetool.AnalyzedTokenReadings)

Example 25 with German

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

the class DashRuleTest method testRule.

@Test
public void testRule() throws IOException {
    JLanguageTool lt = new JLanguageTool(new German());
    // correct sentences:
    assertGood("Die große Diäten-Erhöhung kam dann doch.", lt);
    assertGood("Die große Diätenerhöhung kam dann doch.", lt);
    assertGood("Die große Diäten-Erhöhungs-Manie kam dann doch.", lt);
    assertGood("Die große Diäten- und Gehaltserhöhung kam dann doch.", lt);
    assertGood("Die große Diäten- sowie Gehaltserhöhung kam dann doch.", lt);
    assertGood("Die große Diäten- oder Gehaltserhöhung kam dann doch.", lt);
    assertGood("Erst so - Karl-Heinz dann blah.", lt);
    assertGood("Erst so -- Karl-Heinz aber...", lt);
    // incorrect sentences:
    assertBad("Die große Diäten- Erhöhung kam dann doch.", lt);
    assertBad("Die große Diäten-  Erhöhung kam dann doch.", lt);
    assertBad("Die große Diäten-Erhöhungs- Manie kam dann doch.", lt);
    assertBad("Die große Diäten- Erhöhungs-Manie kam dann doch.", lt);
}
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