Package org.languagetool.rules

Examples of org.languagetool.rules.WordRepeatRule


    String output = new String(this.out.toByteArray());
    assertEquals(0, output.indexOf("Time:"));
    assertEquals(0, matches);

    tool.disableRule("test_unification_with_negation");
    tool.addRule(new WordRepeatRule(TestTools.getEnglishMessages(), Language.DEMO));
    matches = Tools.checkText("To jest problem problem.", tool);
    output = new String(this.out.toByteArray());
    assertTrue(output.contains("Rule ID: WORD_REPEAT_RULE"));
    assertEquals(1, matches);
  }
View Full Code Here


public class WordRepeatRuleTest extends TestCase {

  public void testRuleGerman() throws IOException {
    final German german = new German();
    final WordRepeatRule rule = new GermanWordRepeatRule(TestTools.getEnglishMessages(), german);
    RuleMatch[] matches;
    final JLanguageTool langTool = new JLanguageTool(german);
    // correct sentences:
    matches = rule.match(langTool.getAnalyzedSentence("Das sind die Sätze, die die testen sollen."));
    assertEquals(0, matches.length);
    matches = rule.match(langTool.getAnalyzedSentence("Sätze, die die testen."));
    assertEquals(0, matches.length);
    matches = rule.match(langTool.getAnalyzedSentence("Das Haus, auf das das Mädchen zeigt."));
    assertEquals(0, matches.length);
    matches = rule.match(langTool.getAnalyzedSentence("Warum fragen Sie sie nicht selbst?"));
    assertEquals(0, matches.length);
    // incorrect sentences:
    matches = rule.match(langTool.getAnalyzedSentence("Die die Sätze zum testen."));
    assertEquals(1, matches.length);
    matches = rule.match(langTool.getAnalyzedSentence("Und die die Sätze zum testen."));
    assertEquals(1, matches.length);
    matches = rule.match(langTool.getAnalyzedSentence("Auf der der Fensterbank steht eine Blume."));
    assertEquals(1, matches.length);
    matches = rule.match(langTool.getAnalyzedSentence("Das Buch, in in dem es steht."));
    assertEquals(1, matches.length);
    matches = rule.match(langTool.getAnalyzedSentence("Das Haus, auf auf das Mädchen zurennen."));
    assertEquals(1, matches.length);
    matches = rule.match(langTool.getAnalyzedSentence("Sie sie gehen nach Hause."));
    assertEquals(1, matches.length);
  }
View Full Code Here

public class WordRepeatRuleTest extends TestCase {

  public void testRulePolish() throws IOException {
    final Polish polish = new Polish();
    final WordRepeatRule rule = new WordRepeatRule(TestTools.getEnglishMessages(), polish);
    RuleMatch[] matches;
    final JLanguageTool langTool = new JLanguageTool(polish);
    // correct sentences:
    matches = rule.match(langTool.getAnalyzedSentence("To jest zdanie."));
    assertEquals(0, matches.length);
    // incorrect sentences:
    matches = rule.match(langTool.getAnalyzedSentence("To jest jest zdanie."));
    assertEquals(1, matches.length);
  }
View Full Code Here

public class RuleLinkTest extends TestCase {

  public void testBuildDeactivationLink() {
    final Language language = new English();
    final RuleLink ruleLink = RuleLink.buildDeactivationLink(new WordRepeatRule(TestTools.getMessages(language.getShortName()), language));
    assertEquals("WORD_REPEAT_RULE", ruleLink.getId());
    assertEquals("http://languagetool.org/deactivate/WORD_REPEAT_RULE", ruleLink.toString());
  }
View Full Code Here

    assertEquals("http://languagetool.org/deactivate/WORD_REPEAT_RULE", ruleLink.toString());
  }

  public void testBuildReactivationLink() {
    final Language language = new English();
    final RuleLink ruleLink = RuleLink.buildReactivationLink(new WordRepeatRule(TestTools.getMessages(language.getShortName()), language));
    assertEquals("WORD_REPEAT_RULE", ruleLink.getId());
    assertEquals("http://languagetool.org/reactivate/WORD_REPEAT_RULE", ruleLink.toString());
  }
View Full Code Here

    String output = new String(this.out.toByteArray());
    assertEquals(0, output.indexOf("Time:"));
    assertEquals(0, matches);

    tool.disableRule("test_unification_with_negation");
    tool.addRule(new WordRepeatRule(getMessages("en"), TestTools.getDemoLanguage()));
    matches = CommandLineTools.checkText("To jest problem problem.", tool);
    output = new String(this.out.toByteArray());
    assertTrue(output.contains("Rule ID: WORD_REPEAT_RULE"));
    assertEquals(1, matches);
  }
View Full Code Here

public class WordRepeatRuleTest extends TestCase {

  public void testRulePolish() throws IOException {
    final Polish polish = new Polish();
    final WordRepeatRule rule = new WordRepeatRule(TestTools.getEnglishMessages(), polish);
    RuleMatch[] matches;
    final JLanguageTool langTool = new JLanguageTool(polish);
    // correct sentences:
    matches = rule.match(langTool.getAnalyzedSentence("To jest zdanie."));
    assertEquals(0, matches.length);
    // with immunized words:
    assertEquals(0, rule.match(langTool.getAnalyzedSentence("W w. XVI język jest jak kipiący kocioł.")).length);
    assertEquals(0, rule.match(langTool.getAnalyzedSentence("Co jeszcze było smutniejsze, to to, że im się jeść chciało potężnie.")).length);
    assertEquals(0, rule.match(langTool.getAnalyzedSentence("Tra ta ta!")).length);
    // incorrect sentences:
    matches = rule.match(langTool.getAnalyzedSentence("To jest jest zdanie."));
    assertEquals(1, matches.length);
  }
View Full Code Here

public class WordRepeatRuleTest extends TestCase {

  public void testRule() throws IOException {
    final English english = new English();
    final WordRepeatRule rule = new WordRepeatRule(TestTools.getEnglishMessages(), english);
    RuleMatch[] matches;
    final JLanguageTool langTool = new JLanguageTool(english);
    // correct sentences:
    matches = rule.match(langTool.getAnalyzedSentence("This is a test sentence."));
    assertEquals(0, matches.length);
    matches = rule.match(langTool.getAnalyzedSentence("This is a test sentence..."));
    assertEquals(0, matches.length);
    // incorrect sentences:
    matches = rule.match(langTool.getAnalyzedSentence("This this is a test sentence."));
    assertEquals(1, matches.length);
    matches = rule.match(langTool.getAnalyzedSentence("This is a test sentence sentence."));
    assertEquals(1, matches.length);
    matches = rule.match(langTool.getAnalyzedSentence("This is is a a test sentence sentence."));
    assertEquals(3, matches.length);
  }
View Full Code Here

TOP

Related Classes of org.languagetool.rules.WordRepeatRule

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.