Package org.languagetool.language

Examples of org.languagetool.language.German


import java.util.List;

public class JLanguageToolTest extends TestCase {

  public void testGerman() throws IOException {
    final JLanguageTool tool = new JLanguageTool(new German());
    assertEquals(0, tool.check("Ein Test, der keine Fehler geben sollte.").size());
    assertEquals(1, tool.check("Ein Test Test, der Fehler geben sollte.").size());
    tool.activateDefaultPatternRules();
    tool.setListUnknownWords(true);
    // no spelling mistakes as we have not created a variant:
View Full Code Here


    //test unknown words listing
    assertEquals("[I, can, detailed, give, more, you]", tool.getUnknownWords().toString());
  }

  public void testPositionsWithGerman() throws IOException {
    final JLanguageTool tool = new JLanguageTool(new German());
    tool.activateDefaultPatternRules();
    final List<RuleMatch> matches = tool.check("Stundenkilometer");
    assertEquals(1, matches.size());
    final RuleMatch match = matches.get(0);
    // TODO: values should be either 0-based or 1-based, it should not be mixed up!
View Full Code Here

    //final String urlString = "https://secure.wikimedia.org/wikipedia/de/wiki/Benutzer_Diskussion:Dnaber";
    final String urlString = args[0];
    final URL url = new URL(urlString);
    final String mediaWikiContent = check.getMediaWikiContent(url);
    final String plainText = check.getPlainText(mediaWikiContent);
    final WikipediaQuickCheckResult checkResult = check.checkPage(plainText, new German());
    final ContextTools contextTools = new ContextTools();
    contextTools.setContextSize(CONTEXT_SIZE);
    for (RuleMatch ruleMatch : checkResult.getRuleMatches()) {
      System.out.println(ruleMatch.getMessage());
      final String context = contextTools.getPlainTextContext(ruleMatch.getFromPos(), ruleMatch.getToPos(), checkResult.getText());
View Full Code Here

public class HunspellRuleTest {

  @Test
  public void testRuleWithGerman() throws Exception {
    final HunspellRule rule = new HunspellRule(TestTools.getMessages("German"), new GermanyGerman());
    final JLanguageTool langTool = new JLanguageTool(new German());
    commonGermanAsserts(rule, langTool);
    assertEquals(0, rule.match(langTool.getAnalyzedSentence("Der äußere Übeltäter.")).length)// umlauts
    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);
View Full Code Here

  }

  @Test
  public void testRuleWithAustrianGerman() throws Exception {
    final HunspellRule rule = new HunspellRule(TestTools.getMessages("German"), new AustrianGerman());
    final JLanguageTool langTool = new JLanguageTool(new German());
    commonGermanAsserts(rule, langTool);
    assertEquals(0, rule.match(langTool.getAnalyzedSentence("Der äußere Übeltäter.")).length)// umlauts
    assertEquals(1, rule.match(langTool.getAnalyzedSentence("Der äussere Übeltäter.")).length);
  }
View Full Code Here

  }

  @Test
  public void testRuleWithSwissGerman() throws Exception {
    final HunspellRule rule = new HunspellRule(TestTools.getMessages("German"), new SwissGerman());
    final JLanguageTool langTool = new JLanguageTool(new German());
    commonGermanAsserts(rule, langTool);
    assertEquals(1, rule.match(langTool.getAnalyzedSentence("Der äußere Übeltäter.")).length)// ß not allowed in Swiss
    assertEquals(0, rule.match(langTool.getAnalyzedSentence("Der äussere Übeltäter.")).length)// ss is used instead of ß
  }
View Full Code Here

*/
public class CaseRuleTest extends TestCase {

  public void testRuleActivation() throws IOException {
    CaseRule rule = new CaseRule(null);
    assertTrue(rule.supportsLanguage(new German()));
  }
View Full Code Here

    assertTrue(rule.supportsLanguage(new German()));
  }

  public void testRule() throws IOException {
    CaseRule rule = new CaseRule(null);
    JLanguageTool langTool = new JLanguageTool(new German());

    // correct sentences:
    assertEquals(0, rule.match(langTool.getAnalyzedSentence("Ein einfacher Satz zum Testen.")).length);
    assertEquals(0, rule.match(langTool.getAnalyzedSentence("Das Laufen fällt mir leicht.")).length);
    assertEquals(0, rule.match(langTool.getAnalyzedSentence("Das Winseln stört.")).length);
View Full Code Here

//     assertEquals(2, langTool.check("Karten werden vom Auswahlstapel gezogen. Auch [...] Der Auswahlstapel gehört zum Inhalt.").size());
  }

  public void testSubstantivierteVerben() throws IOException {
    CaseRule rule = new CaseRule(null);
    JLanguageTool langTool = new JLanguageTool(new German());

    // correct sentences:
    assertEquals(0, rule.match(langTool.getAnalyzedSentence("Das fahrende Auto.")).length);
    assertEquals(0, rule.match(langTool.getAnalyzedSentence("Das können wir so machen.")).length);
    assertEquals(0, rule.match(langTool.getAnalyzedSentence("Denn das Fahren ist einfach.")).length);
View Full Code Here

    // TODO: detect all the cases not preceded with 'das'
  }

  public void testPhraseExceptions() throws IOException {
    CaseRule rule = new CaseRule(null);
    JLanguageTool langTool = new JLanguageTool(new German());

    // correct sentences:
    assertEquals(0, rule.match(langTool.getAnalyzedSentence("Das gilt ohne Wenn und Aber.")).length);
    assertEquals(0, rule.match(langTool.getAnalyzedSentence("ohne Wenn und Aber")).length);
    assertEquals(0, rule.match(langTool.getAnalyzedSentence("Das gilt ohne Wenn und Aber bla blubb.")).length);
View Full Code Here

TOP

Related Classes of org.languagetool.language.German

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.