use of org.languagetool.JLanguageTool in project languagetool by languagetool-org.
the class MorfologikTagalogSpellerRuleTest method testMorfologikSpeller.
@Test
public void testMorfologikSpeller() throws IOException {
Tagalog language = new Tagalog();
MorfologikTagalogSpellerRule rule = new MorfologikTagalogSpellerRule(TestTools.getMessages("en"), language);
JLanguageTool langTool = new JLanguageTool(language);
assertEquals(0, rule.match(langTool.getAnalyzedSentence("Ang talatang ito ay nagpapakita ng ng kakayahan ng LanguageTool at halimbawa kung paano ito gamitin.")).length);
RuleMatch[] matches = rule.match(langTool.getAnalyzedSentence("Ang talatang ito ay nagpapakita ng ng kakayahan ng LanguageTool at hinahalimbawa kung paano ito gamitin."));
assertEquals(1, matches.length);
assertEquals(67, matches[0].getFromPos());
assertEquals(80, matches[0].getToPos());
assertEquals("hina halimbawa", matches[0].getSuggestedReplacements().get(0));
}
use of org.languagetool.JLanguageTool in project languagetool by languagetool-org.
the class ConfigThread method run.
@Override
public void run() {
try {
JLanguageTool langTool = new JLanguageTool(docLanguage, config.getMotherTongue());
cfgDialog.show(langTool.getAllRules());
config.saveConfiguration(docLanguage);
if (mainThread != null) {
mainThread.resetDocument();
}
} catch (Throwable e) {
Main.showError(e);
}
}
use of org.languagetool.JLanguageTool in project languagetool by languagetool-org.
the class SimpleReplaceRuleTest method testRule.
@Test
public void testRule() throws IOException {
SimpleReplaceRule rule = new SimpleReplaceRule(TestTools.getEnglishMessages());
RuleMatch[] matches;
JLanguageTool langTool = new JLanguageTool(new Ukrainian());
// correct sentences:
matches = rule.match(langTool.getAnalyzedSentence("Ці рядки повинні збігатися."));
assertEquals(0, matches.length);
// incorrect sentences:
matches = rule.match(langTool.getAnalyzedSentence("Ці рядки повинні співпадати."));
assertEquals(1, matches.length);
assertEquals(2, matches[0].getSuggestedReplacements().size());
assertEquals(Arrays.asList("збігатися", "сходитися"), matches[0].getSuggestedReplacements());
matches = rule.match(langTool.getAnalyzedSentence("Нападаючий"));
assertEquals(1, matches.length);
assertEquals(Arrays.asList("Нападник", "Нападальний", "Нападний"), matches[0].getSuggestedReplacements());
matches = rule.match(langTool.getAnalyzedSentence("Нападаючого"));
assertEquals(1, matches.length);
assertEquals(Arrays.asList("Нападник", "Нападальний", "Нападний"), matches[0].getSuggestedReplacements());
// test ignoreTagged
matches = rule.match(langTool.getAnalyzedSentence("щедрота"));
assertEquals(1, matches.length);
assertEquals(Arrays.asList("щедрість", "гойність", "щедриня"), matches[0].getSuggestedReplacements());
matches = rule.match(langTool.getAnalyzedSentence("щедроти"));
assertEquals(0, matches.length);
}
use of org.languagetool.JLanguageTool in project languagetool by languagetool-org.
the class SimpleReplaceSoftRuleTest method testRule.
@Test
public void testRule() throws IOException {
SimpleReplaceSoftRule rule = new SimpleReplaceSoftRule(TestTools.getEnglishMessages());
RuleMatch[] matches;
JLanguageTool langTool = new JLanguageTool(new Ukrainian());
// correct sentences:
matches = rule.match(langTool.getAnalyzedSentence("Ці рядки повинні збігатися."));
assertEquals(0, matches.length);
matches = rule.match(langTool.getAnalyzedSentence("Цей брелок."));
assertEquals(1, matches.length);
assertEquals(Arrays.asList("дармовис"), matches[0].getSuggestedReplacements());
matches = rule.match(langTool.getAnalyzedSentence("Не знайде спасіння."));
assertEquals(1, matches.length);
assertEquals(Arrays.asList("рятування", "рятунок", "порятунок", "визволення"), matches[0].getSuggestedReplacements());
assertTrue(matches[0].getMessage().contains(": релігія"));
//refl
matches = rule.match(langTool.getAnalyzedSentence("відображаються"));
assertEquals(1, matches.length);
assertEquals(Arrays.asList("показуватися", "зображатися", "відбиватися"), matches[0].getSuggestedReplacements());
assertTrue("No context: " + matches[0].getMessage(), matches[0].getMessage().contains(": математика"));
// test ignoreTagged
// matches = rule.match(langTool.getAnalyzedSentence("щедрота"));
// assertEquals(1, matches.length);
// assertEquals(Arrays.asList("щедрість", "гойність", "щедриня"), matches[0].getSuggestedReplacements());
//
// matches = rule.match(langTool.getAnalyzedSentence("щедроти"));
// assertEquals(0, matches.length);
}
use of org.languagetool.JLanguageTool in project languagetool by languagetool-org.
the class TokenAgreementRuleTest method setUp.
@Before
public void setUp() throws IOException {
rule = new TokenAgreementRule(TestTools.getMessages("uk"));
langTool = new JLanguageTool(new Ukrainian());
}
Aggregations