use of org.languagetool.FakeLanguage in project languagetool by languagetool-org.
the class DifferentPunctuationRuleTest method testRule.
@Test
public void testRule() throws IOException {
DifferentPunctuationRule rule = new DifferentPunctuationRule();
RuleMatch[] matches;
JLanguageTool srcLangTool = new JLanguageTool(TestTools.getDemoLanguage());
JLanguageTool trgLangTool = new JLanguageTool(new FakeLanguage());
rule.setSourceLanguage(TestTools.getDemoLanguage());
// correct sentences:
matches = rule.match(srcLangTool.getAnalyzedSentence("This is a test sentence!"), trgLangTool.getAnalyzedSentence("C'est la vie!"));
assertEquals(0, matches.length);
matches = rule.match(srcLangTool.getAnalyzedSentence("one sentence"), trgLangTool.getAnalyzedSentence("jedno zdanie"));
assertEquals(0, matches.length);
// incorrect sentences:
matches = rule.match(srcLangTool.getAnalyzedSentence("This this is a test sentence."), trgLangTool.getAnalyzedSentence("This this is a test sentence!"));
assertEquals(1, matches.length);
}
use of org.languagetool.FakeLanguage in project languagetool by languagetool-org.
the class ConfusionProbabilityRuleTest method testRule.
@Test
public void testRule() throws IOException {
assertMatch("Their are new ideas to explore.");
assertGood("There are new ideas to explore.");
assertMatch("Why is there car broken again?");
assertGood("Why is their car broken again?");
assertGood("Is this their useful test?");
// error not found b/c no data
assertGood("Is this there useful test?");
ConfusionProbabilityRule ruleWithException = new FakeRule(new FakeLanguageModel(), new FakeLanguage()) {
@Override
protected boolean isException(String sentenceText) {
return sentenceText.contains("Their are");
}
};
assertGood("Their are new ideas to explore.", ruleWithException);
// bug with the special char 'İ' which, when lowercased becomes a regular 'i'
assertMatch("İm dabei gut auszusehen.");
}
use of org.languagetool.FakeLanguage in project languagetool by languagetool-org.
the class SameTranslationRuleTest method testRule.
@Test
public void testRule() throws IOException {
SameTranslationRule rule = new SameTranslationRule();
RuleMatch[] matches;
JLanguageTool srcLangTool = new JLanguageTool(TestTools.getDemoLanguage());
JLanguageTool trgLangTool = new JLanguageTool(new FakeLanguage());
rule.setSourceLanguage(TestTools.getDemoLanguage());
// correct sentences:
matches = rule.match(srcLangTool.getAnalyzedSentence("This is a test sentence."), trgLangTool.getAnalyzedSentence("C'est la vie !"));
assertEquals(0, matches.length);
//tricky: proper names should be left as is!
matches = rule.match(srcLangTool.getAnalyzedSentence("Elvis Presley"), trgLangTool.getAnalyzedSentence("Elvis Presley"));
assertEquals(0, matches.length);
// incorrect sentences:
matches = rule.match(srcLangTool.getAnalyzedSentence("This this is a test sentence."), trgLangTool.getAnalyzedSentence("This this is a test sentence."));
assertEquals(1, matches.length);
}
use of org.languagetool.FakeLanguage in project languagetool by languagetool-org.
the class GenericUnpairedBracketsRuleTest method testRule.
@Test
public void testRule() throws IOException {
setUpRule(new FakeLanguage());
assertMatches(0, "This is »correct«.");
assertMatches(0, "»Correct«\n»And »here« it ends.«");
assertMatches(0, "»Correct. This is more than one sentence.«");
assertMatches(0, "»Correct. This is more than one sentence.«\n»And »here« it ends.«");
assertMatches(0, "»Correct«\n\n»And here it ends.«\n\nMore text.");
assertMatches(0, "»Correct, he said. This is the next sentence.« Here's another sentence.");
assertMatches(0, "»Correct, he said.\n\nThis is the next sentence.« Here's another sentence.");
assertMatches(0, "»Correct, he said.\n\n\n\nThis is the next sentence.« Here's another sentence.");
assertMatches(0, "This »is also »correct««.");
assertMatches(0, "Good.\n\nThis »is also »correct««.");
assertMatches(0, "Good.\n\n\nThis »is also »correct««.");
assertMatches(0, "Good.\n\n\n\nThis »is also »correct««.");
assertMatches(1, "This is not correct«");
assertMatches(1, "This is »not correct");
assertMatches(1, "This is correct.\n\n»But this is not.");
assertMatches(1, "This is correct.\n\nBut this is not«");
assertMatches(1, "»This is correct«\n\nBut this is not«");
assertMatches(1, "»This is correct«\n\nBut this »is« not«");
assertMatches(1, "This is not correct. No matter if it's more than one sentence«");
assertMatches(1, "»This is not correct. No matter if it's more than one sentence");
assertMatches(1, "Correct, he said. This is the next sentence.« Here's another sentence.");
assertMatches(1, "»Correct, he said. This is the next sentence. Here's another sentence.");
assertMatches(1, "»Correct, he said. This is the next sentence.\n\nHere's another sentence.");
assertMatches(1, "»Correct, he said. This is the next sentence.\n\n\n\nHere's another sentence.");
}
use of org.languagetool.FakeLanguage in project languagetool by languagetool-org.
the class SentenceWhitespaceRuleTest method testMatch.
@Test
public void testMatch() throws Exception {
SentenceWhitespaceRule rule = new SentenceWhitespaceRule(TestTools.getEnglishMessages());
JLanguageTool lt = new JLanguageTool(new FakeLanguage());
lt.addRule(rule);
assertGood("This is a text. And there's the next sentence.", rule, lt);
assertGood("This is a text! And there's the next sentence.", rule, lt);
assertGood("This is a text\nAnd there's the next sentence.", rule, lt);
assertGood("This is a text\n\nAnd there's the next sentence.", rule, lt);
assertBad("This is a text.And there's the next sentence.", rule, lt);
assertBad("This is a text!And there's the next sentence.", rule, lt);
assertBad("This is a text?And there's the next sentence.", rule, lt);
}
Aggregations