use of org.languagetool.JLanguageTool in project languagetool by languagetool-org.
the class KhmerSpaceBeforeRuleTest method testSpaceBeforeRule.
@Test
public void testSpaceBeforeRule() throws IOException {
final Khmer language = new Khmer();
KhmerSpaceBeforeRule rule = new KhmerSpaceBeforeRule(TestTools.getEnglishMessages(), language);
JLanguageTool langTool = new JLanguageTool(language);
// correct sentences:
assertEquals(0, rule.match(langTool.getAnalyzedSentence("គាត់បានទៅ ដើម្បីទិញម្ហូប។")).length);
assertEquals(0, rule.match(langTool.getAnalyzedSentence("ខ្ញុំ និងគាត់។")).length);
assertEquals(0, rule.match(langTool.getAnalyzedSentence("គាត់ចង់បាន ពីព្រោះគាត់អត់មាន។")).length);
// incorrect sentences:
assertEquals(1, rule.match(langTool.getAnalyzedSentence("គាត់បានទៅដើម្បីទិញម្ហូប។")).length);
assertEquals(1, rule.match(langTool.getAnalyzedSentence("ខ្ញុំនិងគាត់។")).length);
assertEquals(1, rule.match(langTool.getAnalyzedSentence("គាត់ចង់បានពីព្រោះគាត់អត់មាន។")).length);
}
use of org.languagetool.JLanguageTool in project languagetool by languagetool-org.
the class MorfologikPolishSpellerRuleTest method testMorfologikSpeller.
@Test
public void testMorfologikSpeller() throws IOException {
final MorfologikPolishSpellerRule rule = new MorfologikPolishSpellerRule(TestTools.getMessages("pl"), new Polish());
final JLanguageTool langTool = new JLanguageTool(new Polish());
// correct sentences:
assertEquals(0, rule.match(langTool.getAnalyzedSentence("To jest test bez jakiegokolwiek błędu.")).length);
assertEquals(0, rule.match(langTool.getAnalyzedSentence("Żółw na starość wydziela dziwną woń.")).length);
assertEquals(0, rule.match(langTool.getAnalyzedSentence("Żółw na starość wydziela dziwną woń numer 1234.")).length);
assertEquals(0, rule.match(langTool.getAnalyzedSentence("W MI-6 pracuje 15-letni agent.")).length);
//test for "LanguageTool":
assertEquals(0, rule.match(langTool.getAnalyzedSentence("LanguageTool jest świetny!")).length);
//test for the ignored uppercase word "Gdym":
assertEquals(0, rule.match(langTool.getAnalyzedSentence("Gdym to zobaczył, zdębiałem.")).length);
assertEquals(0, rule.match(langTool.getAnalyzedSentence(",")).length);
assertEquals(0, rule.match(langTool.getAnalyzedSentence("123454")).length);
//compound word with ignored part "techniczno"
assertEquals(0, rule.match(langTool.getAnalyzedSentence("Bogactwo nie rośnie proporcjonalnie do jej rozwoju techniczno-terytorialnego.")).length);
//compound word with one of the compound prefixes:
assertEquals(0, rule.match(langTool.getAnalyzedSentence("Antypostmodernistyczna batalia hiperfilozofów")).length);
//compound words: "trzynastobitowy", "zgniłożółty"
assertEquals(0, rule.match(langTool.getAnalyzedSentence("Trzynastobitowe przystawki w kolorze zgniłożółtym")).length);
//incorrect sentences:
final RuleMatch[] matches = rule.match(langTool.getAnalyzedSentence("Zolw"));
// check match positions:
assertEquals(1, matches.length);
assertEquals(0, matches[0].getFromPos());
assertEquals(4, matches[0].getToPos());
assertEquals("Żółw", matches[0].getSuggestedReplacements().get(0));
assertEquals(1, rule.match(langTool.getAnalyzedSentence("aõh")).length);
//tokenizing on prefixes niby- and quasi-
assertEquals(0, rule.match(langTool.getAnalyzedSentence("Niby-artysta spotkał się z quasi-opiekunem i niby-Francuzem.")).length);
final RuleMatch[] prunedMatches = rule.match(langTool.getAnalyzedSentence("Clarkem"));
assertEquals(1, prunedMatches.length);
assertEquals(5, prunedMatches[0].getSuggestedReplacements().size());
assertEquals("Clarke", prunedMatches[0].getSuggestedReplacements().get(0));
assertEquals("Clarkiem", prunedMatches[0].getSuggestedReplacements().get(1));
assertEquals("Ciarkę", prunedMatches[0].getSuggestedReplacements().get(2));
assertEquals("Clarkom", prunedMatches[0].getSuggestedReplacements().get(3));
assertEquals("Czarkę", prunedMatches[0].getSuggestedReplacements().get(4));
// There should be a match, this is not a prefix!
assertEquals(1, rule.match(langTool.getAnalyzedSentence("premoc")).length);
// "0" instead "o"...
assertEquals(1, rule.match(langTool.getAnalyzedSentence("dziwneg0")).length);
}
use of org.languagetool.JLanguageTool in project languagetool by languagetool-org.
the class PolishUnpairedBracketsRuleTest method testRulePolish.
@Test
public void testRulePolish() throws IOException {
Polish language = new Polish();
PolishUnpairedBracketsRule rule = new PolishUnpairedBracketsRule(TestTools.getEnglishMessages(), language);
JLanguageTool lt = new JLanguageTool(language);
assertEquals(0, getMatches("(To jest zdanie do testowania).", rule, lt));
assertEquals(0, getMatches("Piosenka ta trafiła na wiele list \"Best of...\", włączając w to te, które zostały utworzone przez magazyn Rolling Stone.", rule, lt));
assertEquals(0, getMatches("A \"B\" C.", rule, lt));
assertEquals(0, getMatches("\"A\" B \"C\".", rule, lt));
assertEquals(1, getMatches("W tym zdaniu jest niesparowany „cudzysłów.", rule, lt));
}
use of org.languagetool.JLanguageTool in project languagetool by languagetool-org.
the class PolishWordRepeatRuleTest method testRule.
@Test
public void testRule() throws IOException {
final PolishWordRepeatRule rule = new PolishWordRepeatRule(TestTools.getEnglishMessages());
RuleMatch[] matches;
JLanguageTool langTool = new JLanguageTool(new Polish());
//correct
matches = rule.match(langTool.getAnalyzedSentence("To jest zdanie próbne."));
assertEquals(0, matches.length);
matches = rule.match(langTool.getAnalyzedSentence("On tak się bardzo nie martwił, bo przecież musiał się umyć."));
assertEquals(0, matches.length);
//repeated prepositions, don't count'em
matches = rule.match(langTool.getAnalyzedSentence("Na dyskotece tańczył jeszcze, choć był na bani."));
assertEquals(0, matches.length);
// sf bug report:
matches = rule.match(langTool.getAnalyzedSentence("Żadnych „ale”."));
assertEquals(0, matches.length);
//incorrect
matches = rule.match(langTool.getAnalyzedSentence("Był on bowiem pięknym strzelcem bowiem."));
assertEquals(1, matches.length);
matches = rule.match(langTool.getAnalyzedSentence("Mówiła długo, żeby tylko mówić długo."));
assertEquals(2, matches.length);
}
use of org.languagetool.JLanguageTool in project languagetool by languagetool-org.
the class SimpleReplaceRuleTest method setUp.
@Before
public void setUp() throws Exception {
rule = new SimpleReplaceRule(TestTools.getMessages("pl"));
langTool = new JLanguageTool(new Polish());
}
Aggregations