use of org.languagetool.JLanguageTool in project languagetool by languagetool-org.
the class PortugueseWordRepeatBeginningRuleTest method testRule.
@Test
public void testRule() throws IOException {
JLanguageTool langTool = new JLanguageTool(new Portuguese());
// correct sentences:
assertEquals(0, langTool.check("Este exemplo está correto. Este exemplo também.").size());
assertEquals(0, langTool.check("Certo, isto está bem. Este exemplo está correto. Certo que este também.").size());
assertEquals(0, langTool.check("2011: Setembro já passou. 2011: Outubro também. 2011: Novembro já se foi.").size());
// errors:
assertEquals(1, langTool.check("Este exemplo está correto. Este segundo também. Este terceiro exemplo não.").size());
assertEquals(1, langTool.check("Então, este está correto. Então, este está errado, por causa da repetição.").size());
// this used to cause false alarms because reset() was not implemented
assertEquals(0, langTool.check("Então, este deve ser considerado uma nova frase.").size());
}
use of org.languagetool.JLanguageTool in project languagetool by languagetool-org.
the class HunspellRuleTest method testImmunizedFrenchWord.
@Test
public void testImmunizedFrenchWord() throws Exception {
final French french = new French();
final HunspellRule rule = new HunspellRule(TestTools.getMessages("fr"), french);
JLanguageTool langTool = new JLanguageTool(french);
assertEquals(1, rule.match(langTool.getAnalyzedSentence("languageTool est génial.")).length);
final French frenchWithDisambiguator = new French() {
@Override
public Disambiguator getDisambiguator() {
return new TestFrenchDisambiguator();
}
};
langTool = new JLanguageTool(frenchWithDisambiguator);
assertEquals(0, rule.match(langTool.getAnalyzedSentence("languageTool est génial.")).length);
}
use of org.languagetool.JLanguageTool in project languagetool by languagetool-org.
the class MorfologikMalayalamSpellerRuleTest method testMorfologikSpeller.
@Test
public void testMorfologikSpeller() throws IOException {
final Malayalam language = new Malayalam();
final MorfologikMalayalamSpellerRule rule = new MorfologikMalayalamSpellerRule(TestTools.getMessages("ml"), language);
RuleMatch[] matches;
final JLanguageTool langTool = new JLanguageTool(language);
// correct sentences:
assertEquals(0, rule.match(langTool.getAnalyzedSentence("എന്തുകൊണ്ട് അംഗത്വം")).length);
assertEquals(0, rule.match(langTool.getAnalyzedSentence("എങ്ങനെ അംഗമാകാം?")).length);
//test for "LanguageTool":
assertEquals(0, rule.match(langTool.getAnalyzedSentence("LanguageTool")).length);
assertEquals(0, rule.match(langTool.getAnalyzedSentence(",")).length);
assertEquals(0, rule.match(langTool.getAnalyzedSentence("123454")).length);
//incorrect sentences:
matches = rule.match(langTool.getAnalyzedSentence("Zolw"));
// check match positions:
assertEquals(1, matches.length);
assertEquals(0, matches[0].getFromPos());
assertEquals(4, matches[0].getToPos());
assertEquals(matches[0].getSuggestedReplacements().isEmpty(), true);
matches = rule.match(langTool.getAnalyzedSentence("എaങ്ങനെ"));
assertEquals(1, matches.length);
assertEquals(0, matches[0].getFromPos());
assertEquals(7, matches[0].getToPos());
assertEquals(matches[0].getSuggestedReplacements().get(0), "എങ്ങനെ");
assertEquals(1, rule.match(langTool.getAnalyzedSentence("aõh")).length);
assertEquals(1, rule.match(langTool.getAnalyzedSentence("a")).length);
}
use of org.languagetool.JLanguageTool in project languagetool by languagetool-org.
the class GenericUnpairedBracketsRuleTest method testDutchRule.
@Test
public void testDutchRule() throws IOException {
langTool = new JLanguageTool(new Dutch());
rule = org.languagetool.rules.GenericUnpairedBracketsRuleTest.getBracketsRule(langTool);
// correct sentences:
assertMatches("Het centrale probleem van het werk is de ‘dichterlijke kuischheid’.", 0);
//this was a bug as there are several pairs that start with the same char:
assertMatches(" Eurlings: “De gegevens van de dienst zijn van cruciaal belang voor de veiligheid van de luchtvaart en de scheepvaart”.", 0);
assertMatches(" Eurlings: „De gegevens van de dienst zijn van cruciaal belang voor de veiligheid van de luchtvaart en de scheepvaart”.", 0);
// incorrect sentences:
assertMatches("Het centrale probleem van het werk is de „dichterlijke kuischheid.", 1);
assertMatches(" Eurlings: “De gegevens van de dienst zijn van cruciaal belang voor de veiligheid van de luchtvaart en de scheepvaart.", 1);
}
use of org.languagetool.JLanguageTool in project languagetool by languagetool-org.
the class UppercaseSentenceStartRuleTest method testDutchSpecialCases.
@Test
public void testDutchSpecialCases() throws IOException {
final JLanguageTool lt = new JLanguageTool(new Dutch() {
@Override
protected synchronized List<AbstractPatternRule> getPatternRules() {
return Collections.emptyList();
}
});
assertEquals(1, lt.check("A sentence.").size());
assertEquals(0, lt.check("'s Morgens...").size());
assertEquals(2, lt.check("a sentence.").size());
assertEquals(1, lt.check("'s morgens...").size());
assertEquals(2, lt.check("s sentence.").size());
}
Aggregations