use of org.languagetool.language.French 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.language.French in project languagetool by languagetool-org.
the class FrenchRuleDisambiguatorTest method setUp.
@Before
public void setUp() throws IOException {
tagger = new FrenchTagger();
tokenizer = new WordTokenizer();
French language = new French();
sentenceTokenizer = new SRXSentenceTokenizer(language);
disambiguator = new XmlRuleDisambiguator(language);
disamb2 = new DemoDisambiguator();
}
use of org.languagetool.language.French in project languagetool by languagetool-org.
the class GenericUnpairedBracketsRuleTest method testFrenchRule.
@Test
public void testFrenchRule() throws IOException {
langTool = new JLanguageTool(new French());
rule = org.languagetool.rules.GenericUnpairedBracketsRuleTest.getBracketsRule(langTool);
// correct sentences:
assertMatches("(Qu'est ce que c'est ?)", 0);
// incorrect sentences:
assertMatches("(Qu'est ce que c'est ?", 1);
}
use of org.languagetool.language.French in project languagetool by languagetool-org.
the class QuestionWhitespaceRuleTest method testRule.
@Test
public final void testRule() throws IOException {
QuestionWhitespaceRule rule = new QuestionWhitespaceRule(TestTools.getEnglishMessages());
RuleMatch[] matches;
JLanguageTool langTool = new JLanguageTool(new French());
// correct sentences:
assertEquals(0, rule.match(langTool.getAnalyzedSentence("C'est vrai !")).length);
assertEquals(0, rule.match(langTool.getAnalyzedSentence("Qu'est ce que c'est ?")).length);
assertEquals(0, rule.match(langTool.getAnalyzedSentence("L'enjeu de ce livre est donc triple : philosophique")).length);
// errors:
matches = rule.match(langTool.getAnalyzedSentence("C'est vrai!"));
assertEquals(1, matches.length);
matches = rule.match(langTool.getAnalyzedSentence("C'est vrai !"));
assertEquals(1, matches.length);
matches = rule.match(langTool.getAnalyzedSentence("Qu'est ce que c'est ?"));
assertEquals(1, matches.length);
matches = rule.match(langTool.getAnalyzedSentence("Qu'est ce que c'est?"));
assertEquals(1, matches.length);
matches = rule.match(langTool.getAnalyzedSentence("L'enjeu de ce livre est donc triple: philosophique;"));
assertEquals(2, matches.length);
matches = rule.match(langTool.getAnalyzedSentence("L'enjeu de ce livre est donc triple: philosophique ;"));
assertEquals(2, matches.length);
// check match positions:
assertEquals(2, matches.length);
assertEquals(29, matches[0].getFromPos());
assertEquals(36, matches[0].getToPos());
assertEquals(50, matches[1].getFromPos());
assertEquals(52, matches[1].getToPos());
//guillemets
matches = rule.match(langTool.getAnalyzedSentence("Le guillemet ouvrant est suivi d'un espace insécable : « mais le lieu [...] et le guillemet fermant est précédé d'un espace insécable : [...] littérature »."));
assertEquals(2, matches.length);
matches = rule.match(langTool.getAnalyzedSentence("Le guillemet ouvrant est suivi d'un espace insécable : «mais le lieu [...] et le guillemet fermant est précédé d'un espace insécable : [...] littérature»."));
assertEquals(2, matches.length);
}
use of org.languagetool.language.French in project languagetool by languagetool-org.
the class HunspellRuleTest method testRuleWithFrench.
@Test
public void testRuleWithFrench() throws Exception {
final French french = new French();
final HunspellRule rule = new HunspellRule(TestTools.getMessages("fr"), french);
final JLanguageTool langTool = new JLanguageTool(french);
assertEquals(0, rule.match(langTool.getAnalyzedSentence("Un test simple.")).length);
assertEquals(1, rule.match(langTool.getAnalyzedSentence("Un test simpple.")).length);
assertEquals(0, rule.match(langTool.getAnalyzedSentence("Le cœur, la sœur.")).length);
assertEquals(0, rule.match(langTool.getAnalyzedSentence("LanguageTool")).length);
// Tests with dash and apostrophes.
assertEquals(0, rule.match(langTool.getAnalyzedSentence("Il arrive après-demain.")).length);
assertEquals(0, rule.match(langTool.getAnalyzedSentence("L'Haÿ-les-Roses")).length);
assertEquals(1, rule.match(langTool.getAnalyzedSentence("L'Haÿ les Roses")).length);
assertEquals(0, rule.match(langTool.getAnalyzedSentence("Aujourd'hui et jusqu'à demain.")).length);
assertEquals(0, rule.match(langTool.getAnalyzedSentence("Aujourd’hui et jusqu’à demain.")).length);
assertEquals(0, rule.match(langTool.getAnalyzedSentence("L'Allemagne et l'Italie.")).length);
assertEquals(0, rule.match(langTool.getAnalyzedSentence("L’Allemagne et l’Italie.")).length);
assertEquals(2, rule.match(langTool.getAnalyzedSentence("L’allemagne et l’italie.")).length);
}
Aggregations