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));
}
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());
}
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);
}
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));
}
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);
}
Aggregations