Search in sources :

Example 76 with JLanguageTool

use of org.languagetool.JLanguageTool in project languagetool by languagetool-org.

the class RussianSimpleReplaceRuleTest method testRule.

@Test
public void testRule() throws IOException {
    RussianSimpleReplaceRule rule = new RussianSimpleReplaceRule(TestTools.getMessages("ru"));
    RuleMatch[] matches;
    JLanguageTool langTool = new JLanguageTool(new Russian());
    // correct sentences:
    matches = rule.match(langTool.getAnalyzedSentence("Рост кораллов тут самый быстрый,"));
    assertEquals(0, matches.length);
    matches = rule.match(langTool.getAnalyzedSentence("Книга была порвана."));
    assertEquals(0, matches.length);
    // incorrect sentences:
    matches = rule.match(langTool.getAnalyzedSentence("Книга была порвата."));
    assertEquals(1, matches.length);
    assertEquals(1, matches[0].getSuggestedReplacements().size());
    assertEquals("порвана", matches[0].getSuggestedReplacements().get(0));
}
Also used : RuleMatch(org.languagetool.rules.RuleMatch) Russian(org.languagetool.language.Russian) JLanguageTool(org.languagetool.JLanguageTool) Test(org.junit.Test)

Example 77 with JLanguageTool

use of org.languagetool.JLanguageTool in project languagetool by languagetool-org.

the class CompoundRuleTest method setUp.

@Before
public void setUp() throws Exception {
    lt = new JLanguageTool(new Slovak());
    rule = new CompoundRule(TestTools.getEnglishMessages());
}
Also used : Slovak(org.languagetool.language.Slovak) JLanguageTool(org.languagetool.JLanguageTool) Before(org.junit.Before)

Example 78 with JLanguageTool

use of org.languagetool.JLanguageTool in project languagetool by languagetool-org.

the class CompoundRuleTest method setUp.

@Before
public void setUp() throws Exception {
    lt = new JLanguageTool(new Polish());
    rule = new CompoundRule(TestTools.getEnglishMessages());
}
Also used : Polish(org.languagetool.language.Polish) JLanguageTool(org.languagetool.JLanguageTool) Before(org.junit.Before)

Example 79 with JLanguageTool

use of org.languagetool.JLanguageTool in project languagetool by languagetool-org.

the class ToolsTest method testCheck.

@Test
public void testCheck() throws IOException, ParserConfigurationException, SAXException {
    final JLanguageTool tool = new JLanguageTool(new Polish());
    List<RuleMatch> matches = tool.check("To jest całkowicie prawidłowe zdanie.");
    assertEquals(0, matches.size());
    List<RuleMatch> matches2 = tool.check("To jest problem problem.");
    assertEquals(1, matches2.size());
    assertEquals("WORD_REPEAT_RULE", matches2.get(0).getRule().getId());
}
Also used : Polish(org.languagetool.language.Polish) RuleMatch(org.languagetool.rules.RuleMatch) JLanguageTool(org.languagetool.JLanguageTool) Test(org.junit.Test)

Example 80 with JLanguageTool

use of org.languagetool.JLanguageTool in project languagetool by languagetool-org.

the class PortugueseWikipediaRuleTest method setUp.

@Before
public void setUp() throws Exception {
    rule = new PortugueseWikipediaRule(TestTools.getMessages("pt"));
    langTool = new JLanguageTool(new Portuguese());
}
Also used : Portuguese(org.languagetool.language.Portuguese) JLanguageTool(org.languagetool.JLanguageTool) Before(org.junit.Before)

Aggregations

JLanguageTool (org.languagetool.JLanguageTool)184 Test (org.junit.Test)109 RuleMatch (org.languagetool.rules.RuleMatch)57 Before (org.junit.Before)38 German (org.languagetool.language.German)16 Rule (org.languagetool.rules.Rule)16 Catalan (org.languagetool.language.Catalan)14 Ukrainian (org.languagetool.language.Ukrainian)14 English (org.languagetool.language.English)13 Polish (org.languagetool.language.Polish)12 Language (org.languagetool.Language)10 GermanyGerman (org.languagetool.language.GermanyGerman)9 PatternRule (org.languagetool.rules.patterns.PatternRule)9 AnalyzedSentence (org.languagetool.AnalyzedSentence)8 File (java.io.File)7 AnalyzedTokenReadings (org.languagetool.AnalyzedTokenReadings)6 Dutch (org.languagetool.language.Dutch)5 French (org.languagetool.language.French)5 ArrayList (java.util.ArrayList)4 FakeLanguage (org.languagetool.FakeLanguage)4