Search in sources :

Example 91 with JLanguageTool

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

the class MorfologikSpanishSpellerRuleTest method testMorfologikSpeller.

@Test
public void testMorfologikSpeller() throws IOException {
    Spanish language = new Spanish();
    MorfologikSpanishSpellerRule rule = new MorfologikSpanishSpellerRule(TestTools.getMessages("en"), language);
    JLanguageTool langTool = new JLanguageTool(language);
    assertEquals(0, rule.match(langTool.getAnalyzedSentence("Escriba un texto aquí. LanguageTool le ayudará a afrontar algunas dificultades propias de la escritura.")).length);
    RuleMatch[] matches = rule.match(langTool.getAnalyzedSentence("Se a hecho un esfuerzo para detectar errores tipográficos, ortograficos y incluso gramaticales."));
    assertEquals(1, matches.length);
    assertEquals(59, matches[0].getFromPos());
    assertEquals(71, matches[0].getToPos());
    assertEquals("ortográficos", matches[0].getSuggestedReplacements().get(0));
}
Also used : RuleMatch(org.languagetool.rules.RuleMatch) JLanguageTool(org.languagetool.JLanguageTool) Spanish(org.languagetool.language.Spanish) Test(org.junit.Test)

Example 92 with JLanguageTool

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

the class PersianSpaceBeforeRuleTest method setUp.

@Before
public void setUp() throws IOException {
    rule = new PersianSpaceBeforeRule(TestTools.getEnglishMessages(), TestTools.getDemoLanguage());
    langTool = new JLanguageTool(TestTools.getDemoLanguage());
}
Also used : JLanguageTool(org.languagetool.JLanguageTool) Before(org.junit.Before)

Example 93 with JLanguageTool

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

the class LanguageToolTest method testFrench.

@Test
public void testFrench() throws Exception {
    JLanguageTool lt = new JLanguageTool(new French());
    List<RuleMatch> matches = lt.check("Directeur production du groupe");
    assertEquals(1, matches.size());
    assertTrue(matches.get(0).getRule() instanceof PatternRule);
}
Also used : French(org.languagetool.language.French) RuleMatch(org.languagetool.rules.RuleMatch) PatternRule(org.languagetool.rules.patterns.PatternRule) JLanguageTool(org.languagetool.JLanguageTool) Test(org.junit.Test)

Example 94 with JLanguageTool

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

the class MorfologikAsturianSpellerRuleTest method testMorfologikSpeller.

@Test
public void testMorfologikSpeller() throws IOException {
    Asturian language = new Asturian();
    MorfologikAsturianSpellerRule rule = new MorfologikAsturianSpellerRule(TestTools.getMessages("en"), language);
    JLanguageTool langTool = new JLanguageTool(language);
    assertEquals(0, rule.match(langTool.getAnalyzedSentence("¿Festeyate colos correutores gramaticales?")).length);
    RuleMatch[] matches = rule.match(langTool.getAnalyzedSentence("¿Afáyeste colos correutores gramaticales?"));
    assertEquals(1, matches.length);
    assertEquals(1, matches[0].getFromPos());
    assertEquals(9, matches[0].getToPos());
    assertEquals("Afayesti", matches[0].getSuggestedReplacements().get(0));
}
Also used : RuleMatch(org.languagetool.rules.RuleMatch) Asturian(org.languagetool.language.Asturian) JLanguageTool(org.languagetool.JLanguageTool) Test(org.junit.Test)

Example 95 with JLanguageTool

use of org.languagetool.JLanguageTool 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)

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