Search in sources :

Example 1 with Spanish

use of org.languagetool.language.Spanish 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 2 with Spanish

use of org.languagetool.language.Spanish in project languagetool by languagetool-org.

the class GenericUnpairedBracketsRuleTest method testSpanishRule.

@Test
public void testSpanishRule() throws IOException {
    langTool = new JLanguageTool(new Spanish());
    rule = org.languagetool.rules.GenericUnpairedBracketsRuleTest.getBracketsRule(langTool);
    // correct sentences:
    assertMatches("Soy un hombre (muy honrado).", 0);
    // incorrect sentences:
    assertMatches("De dónde vas?", 1);
    assertMatches("¡Atención", 1);
}
Also used : JLanguageTool(org.languagetool.JLanguageTool) Spanish(org.languagetool.language.Spanish) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)2 JLanguageTool (org.languagetool.JLanguageTool)2 Spanish (org.languagetool.language.Spanish)2 RuleMatch (org.languagetool.rules.RuleMatch)1