use of org.languagetool.JLanguageTool in project languagetool by languagetool-org.
the class HunspellRuleTest method testRuleWithGerman.
@Test
public void testRuleWithGerman() throws Exception {
HunspellRule rule = new HunspellRule(TestTools.getMessages("de"), new GermanyGerman());
JLanguageTool langTool = new JLanguageTool(new German());
commonGermanAsserts(rule, langTool);
// umlauts
assertEquals(0, rule.match(langTool.getAnalyzedSentence("Der äußere Übeltäter.")).length);
assertEquals(1, rule.match(langTool.getAnalyzedSentence("Der äussere Übeltäter.")).length);
// ignore URLs:
assertEquals(0, rule.match(langTool.getAnalyzedSentence("Unter http://foo.org/bar steht was.")).length);
assertEquals(1, rule.match(langTool.getAnalyzedSentence("dasdassda http://foo.org/bar steht was.")).length);
assertEquals(1, rule.match(langTool.getAnalyzedSentence("Unter http://foo.org/bar steht dasdassda.")).length);
}
use of org.languagetool.JLanguageTool in project languagetool by languagetool-org.
the class SpellingCheckRuleTest method testIgnoreSuggestionsWithHunspell.
@Test
public void testIgnoreSuggestionsWithHunspell() throws IOException {
JLanguageTool lt = new JLanguageTool(new GermanyGerman());
// no error, as this word is in ignore.txt
assertThat(lt.check("Das ist ein einPseudoWortFürLanguageToolTests").size(), is(0));
List<RuleMatch> matches = lt.check("Das ist ein Tibbfehla");
assertThat(matches.size(), is(1));
assertThat(matches.get(0).getRule().getId(), is(GermanSpellerRule.RULE_ID));
}
use of org.languagetool.JLanguageTool in project languagetool by languagetool-org.
the class NumeralStressRuleTest method setUp.
@Before
public void setUp() throws IOException {
rule = new NumeralStressRule(TestTools.getMessages("el"));
langTool = new JLanguageTool(new Greek());
}
use of org.languagetool.JLanguageTool in project languagetool by languagetool-org.
the class MorfologikBritishSpellerRuleTest method testMorfologikSpeller.
@Test
public void testMorfologikSpeller() throws IOException {
BritishEnglish language = new BritishEnglish();
MorfologikBritishSpellerRule rule = new MorfologikBritishSpellerRule(TestTools.getMessages("en"), language);
JLanguageTool langTool = new JLanguageTool(language);
// correct sentences:
assertEquals(0, rule.match(langTool.getAnalyzedSentence("This is an example: we get behaviour as a dictionary word.")).length);
assertEquals(0, rule.match(langTool.getAnalyzedSentence("Why don't we speak today.")).length);
//with doesn't
assertEquals(0, rule.match(langTool.getAnalyzedSentence("He doesn't know what to do.")).length);
//with diacritics
assertEquals(0, rule.match(langTool.getAnalyzedSentence("The entrée at the café.")).length);
//with an abbreviation:
assertEquals(0, rule.match(langTool.getAnalyzedSentence("This is my Ph.D. thesis.")).length);
assertEquals(0, rule.match(langTool.getAnalyzedSentence(",")).length);
assertEquals(0, rule.match(langTool.getAnalyzedSentence("123454")).length);
//incorrect sentences:
RuleMatch[] matches1 = rule.match(langTool.getAnalyzedSentence("Behavior"));
// check match positions:
assertEquals(1, matches1.length);
assertEquals(0, matches1[0].getFromPos());
assertEquals(8, matches1[0].getToPos());
assertEquals("Behaviour", matches1[0].getSuggestedReplacements().get(0));
assertEquals(1, rule.match(langTool.getAnalyzedSentence("aõh")).length);
assertEquals(0, rule.match(langTool.getAnalyzedSentence("a")).length);
//based on replacement pairs:
RuleMatch[] matches2 = rule.match(langTool.getAnalyzedSentence("He teached us."));
// check match positions:
assertEquals(1, matches2.length);
assertEquals(3, matches2[0].getFromPos());
assertEquals(10, matches2[0].getToPos());
assertEquals("taught", matches2[0].getSuggestedReplacements().get(0));
}
use of org.languagetool.JLanguageTool in project languagetool by languagetool-org.
the class MorfologikCanadianSpellerRuleTest method testMorfologikSpeller.
@Test
public void testMorfologikSpeller() throws IOException {
CanadianEnglish language = new CanadianEnglish();
MorfologikBritishSpellerRule rule = new MorfologikBritishSpellerRule(TestTools.getMessages("en"), language);
JLanguageTool langTool = new JLanguageTool(language);
// correct sentences:
assertEquals(0, rule.match(langTool.getAnalyzedSentence("This is an example: we get behaviour as a dictionary word.")).length);
assertEquals(0, rule.match(langTool.getAnalyzedSentence("Why don't we speak today.")).length);
//with doesn't
assertEquals(0, rule.match(langTool.getAnalyzedSentence("He doesn't know what to do.")).length);
assertEquals(0, rule.match(langTool.getAnalyzedSentence(",")).length);
assertEquals(0, rule.match(langTool.getAnalyzedSentence("123454")).length);
//incorrect sentences:
RuleMatch[] matches = rule.match(langTool.getAnalyzedSentence("arbor"));
// check match positions:
assertEquals(1, matches.length);
assertEquals(0, matches[0].getFromPos());
assertEquals(5, matches[0].getToPos());
assertEquals("arbour", matches[0].getSuggestedReplacements().get(0));
assertEquals(1, rule.match(langTool.getAnalyzedSentence("aõh")).length);
assertEquals(0, rule.match(langTool.getAnalyzedSentence("a")).length);
}
Aggregations