Search in sources :

Example 1 with WordRepeatRule

use of org.languagetool.rules.WordRepeatRule in project languagetool by languagetool-org.

the class RuleLinkTest method testBuildReactivationLink.

@Test
public void testBuildReactivationLink() {
    Language language = new English();
    RuleLink ruleLink = RuleLink.buildReactivationLink(new WordRepeatRule(TestTools.getMessages(language.getShortCode()), language));
    assertEquals("WORD_REPEAT_RULE", ruleLink.getId());
    assertEquals("http://languagetool.org/reactivate/WORD_REPEAT_RULE", ruleLink.toString());
}
Also used : English(org.languagetool.language.English) Language(org.languagetool.Language) WordRepeatRule(org.languagetool.rules.WordRepeatRule) Test(org.junit.Test)

Example 2 with WordRepeatRule

use of org.languagetool.rules.WordRepeatRule in project languagetool by languagetool-org.

the class RuleLinkTest method testBuildDeactivationLink.

@Test
public void testBuildDeactivationLink() {
    Language language = new English();
    RuleLink ruleLink = RuleLink.buildDeactivationLink(new WordRepeatRule(TestTools.getMessages(language.getShortCode()), language));
    assertEquals("WORD_REPEAT_RULE", ruleLink.getId());
    assertEquals("http://languagetool.org/deactivate/WORD_REPEAT_RULE", ruleLink.toString());
}
Also used : English(org.languagetool.language.English) Language(org.languagetool.Language) WordRepeatRule(org.languagetool.rules.WordRepeatRule) Test(org.junit.Test)

Example 3 with WordRepeatRule

use of org.languagetool.rules.WordRepeatRule in project languagetool by languagetool-org.

the class CommandLineToolsTest method testCheck.

@Test
public void testCheck() throws IOException, ParserConfigurationException, SAXException {
    JLanguageTool tool = new JLanguageTool(TestTools.getDemoLanguage());
    int matches = CommandLineTools.checkText("Foo.", tool);
    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(), 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);
}
Also used : JLanguageTool(org.languagetool.JLanguageTool) WordRepeatRule(org.languagetool.rules.WordRepeatRule) Test(org.junit.Test)

Example 4 with WordRepeatRule

use of org.languagetool.rules.WordRepeatRule in project languagetool by languagetool-org.

the class WordRepeatRuleTest method testRulePolish.

@Test
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);
}
Also used : Polish(org.languagetool.language.Polish) RuleMatch(org.languagetool.rules.RuleMatch) JLanguageTool(org.languagetool.JLanguageTool) WordRepeatRule(org.languagetool.rules.WordRepeatRule) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)4 WordRepeatRule (org.languagetool.rules.WordRepeatRule)4 JLanguageTool (org.languagetool.JLanguageTool)2 Language (org.languagetool.Language)2 English (org.languagetool.language.English)2 Polish (org.languagetool.language.Polish)1 RuleMatch (org.languagetool.rules.RuleMatch)1