Search in sources :

Example 1 with French

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);
}
Also used : French(org.languagetool.language.French) JLanguageTool(org.languagetool.JLanguageTool) Test(org.junit.Test)

Example 2 with French

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();
}
Also used : DemoDisambiguator(org.languagetool.tagging.disambiguation.xx.DemoDisambiguator) FrenchTagger(org.languagetool.tagging.fr.FrenchTagger) French(org.languagetool.language.French) XmlRuleDisambiguator(org.languagetool.tagging.disambiguation.rules.XmlRuleDisambiguator) WordTokenizer(org.languagetool.tokenizers.WordTokenizer) SRXSentenceTokenizer(org.languagetool.tokenizers.SRXSentenceTokenizer) Before(org.junit.Before)

Example 3 with French

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);
}
Also used : French(org.languagetool.language.French) JLanguageTool(org.languagetool.JLanguageTool) Test(org.junit.Test)

Example 4 with French

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);
}
Also used : RuleMatch(org.languagetool.rules.RuleMatch) French(org.languagetool.language.French) JLanguageTool(org.languagetool.JLanguageTool) Test(org.junit.Test)

Example 5 with French

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);
}
Also used : French(org.languagetool.language.French) JLanguageTool(org.languagetool.JLanguageTool) Test(org.junit.Test)

Aggregations

French (org.languagetool.language.French)5 Test (org.junit.Test)4 JLanguageTool (org.languagetool.JLanguageTool)4 Before (org.junit.Before)1 RuleMatch (org.languagetool.rules.RuleMatch)1 XmlRuleDisambiguator (org.languagetool.tagging.disambiguation.rules.XmlRuleDisambiguator)1 DemoDisambiguator (org.languagetool.tagging.disambiguation.xx.DemoDisambiguator)1 FrenchTagger (org.languagetool.tagging.fr.FrenchTagger)1 SRXSentenceTokenizer (org.languagetool.tokenizers.SRXSentenceTokenizer)1 WordTokenizer (org.languagetool.tokenizers.WordTokenizer)1