Search in sources :

Example 6 with Catalan

use of org.languagetool.language.Catalan in project languagetool by languagetool-org.

the class MorfologikCatalanSpellerRuleTest method testMorfologikSpeller.

@Test
public void testMorfologikSpeller() throws IOException {
    MorfologikCatalanSpellerRule rule = new MorfologikCatalanSpellerRule(TestTools.getMessages("ca"), new Catalan());
    RuleMatch[] matches;
    JLanguageTool langTool = new JLanguageTool(new Catalan());
    // prefixes and suffixes.
    assertEquals(0, rule.match(langTool.getAnalyzedSentence("S'autodefineixin com a populars.")).length);
    //assertEquals(0, rule.match(langTool.getAnalyzedSentence("Redibuixen el futur.")).length);
    assertEquals(0, rule.match(langTool.getAnalyzedSentence("L'exdirigent del partit.")).length);
    assertEquals(0, rule.match(langTool.getAnalyzedSentence("S'autoprenia.")).length);
    assertEquals(0, rule.match(langTool.getAnalyzedSentence("S'autocanta.")).length);
    // word not well-formed with prefix 
    assertEquals(1, rule.match(langTool.getAnalyzedSentence("S'autopren.")).length);
    // correct sentences:
    assertEquals(0, rule.match(langTool.getAnalyzedSentence("Abacallanada")).length);
    assertEquals(0, rule.match(langTool.getAnalyzedSentence("Abatre-les-en")).length);
    assertEquals(0, rule.match(langTool.getAnalyzedSentence("Allò que més l'interessa.")).length);
    // checks that "WORDCHARS ·-'" is added to Hunspell .aff file
    assertEquals(0, rule.match(langTool.getAnalyzedSentence("Porta'n quatre al col·legi.")).length);
    assertEquals(0, rule.match(langTool.getAnalyzedSentence("Has de portar-me'n moltes.")).length);
    assertEquals(0, rule.match(langTool.getAnalyzedSentence(",")).length);
    // Spellcheck dictionary contains Valencian and general accentuation
    assertEquals(0, rule.match(langTool.getAnalyzedSentence("Francès i francés.")).length);
    // checks abbreviations 
    assertEquals(0, rule.match(langTool.getAnalyzedSentence("Viu al núm. 23 del carrer Nou.")).length);
    assertEquals(0, rule.match(langTool.getAnalyzedSentence("N'hi ha de color vermell, blau, verd, etc.")).length);
    // Test for Multiwords.
    assertEquals(0, rule.match(langTool.getAnalyzedSentence("Era vox populi.")).length);
    assertEquals(0, rule.match(langTool.getAnalyzedSentence("Aquell era l'statu quo.")).length);
    assertEquals(0, rule.match(langTool.getAnalyzedSentence("Va ser la XIV edició.")).length);
    //test for "LanguageTool":
    assertEquals(0, rule.match(langTool.getAnalyzedSentence("LanguageTool!")).length);
    //test for numbers, punctuation
    assertEquals(0, rule.match(langTool.getAnalyzedSentence(",")).length);
    assertEquals(0, rule.match(langTool.getAnalyzedSentence("123454")).length);
    assertEquals(0, rule.match(langTool.getAnalyzedSentence("1234,54")).length);
    assertEquals(0, rule.match(langTool.getAnalyzedSentence("1.234,54")).length);
    assertEquals(0, rule.match(langTool.getAnalyzedSentence("1 234,54")).length);
    assertEquals(0, rule.match(langTool.getAnalyzedSentence("-1 234,54")).length);
    assertEquals(0, rule.match(langTool.getAnalyzedSentence("Fa una temperatura de 30°C")).length);
    assertEquals(0, rule.match(langTool.getAnalyzedSentence("Fa una temperatura de 30 °C")).length);
    assertEquals(1, rule.match(langTool.getAnalyzedSentence("Any2010")).length);
    //tests for mixed case words
    assertEquals(0, rule.match(langTool.getAnalyzedSentence("pH")).length);
    assertEquals(0, rule.match(langTool.getAnalyzedSentence("McDonald")).length);
    assertEquals(1, rule.match(langTool.getAnalyzedSentence("AixòÉsUnError")).length);
    //incorrect words:
    matches = rule.match(langTool.getAnalyzedSentence("Bordoy"));
    assertEquals(1, matches.length);
    //Bordó; Bordoi; Bordo; bordon
    assertEquals("Bordó", matches[0].getSuggestedReplacements().get(0));
    assertEquals("Bordoi", matches[0].getSuggestedReplacements().get(1));
    assertEquals("Bordo", matches[0].getSuggestedReplacements().get(2));
    assertEquals("Bordon", matches[0].getSuggestedReplacements().get(3));
    matches = rule.match(langTool.getAnalyzedSentence("Mal'aysia"));
    assertEquals(1, matches.length);
    matches = rule.match(langTool.getAnalyzedSentence("Mala’ysia"));
    assertEquals(1, matches.length);
    matches = rule.match(langTool.getAnalyzedSentence("Malaysia"));
    assertEquals(1, matches.length);
    assertEquals("Malàisia", matches[0].getSuggestedReplacements().get(0));
    assertEquals(1, matches[0].getSuggestedReplacements().size());
    matches = rule.match(langTool.getAnalyzedSentence("quna"));
    assertEquals(1, matches.length);
    assertEquals("que", matches[0].getSuggestedReplacements().get(0));
    assertEquals("una", matches[0].getSuggestedReplacements().get(1));
    assertEquals("quan", matches[0].getSuggestedReplacements().get(2));
    //capitalized suggestion
    matches = rule.match(langTool.getAnalyzedSentence("Video"));
    assertEquals(1, matches.length);
    assertEquals("Vídeo", matches[0].getSuggestedReplacements().get(0));
    matches = rule.match(langTool.getAnalyzedSentence("bànner"));
    assertEquals(1, matches.length);
    assertEquals("bàner", matches[0].getSuggestedReplacements().get(0));
    matches = rule.match(langTool.getAnalyzedSentence("especialisats"));
    assertEquals(1, matches.length);
    assertEquals("especialitzats", matches[0].getSuggestedReplacements().get(0));
    matches = rule.match(langTool.getAnalyzedSentence("colaborassió"));
    assertEquals(1, matches.length);
    assertEquals("col·laboració", matches[0].getSuggestedReplacements().get(0));
    matches = rule.match(langTool.getAnalyzedSentence("colaboració"));
    assertEquals(1, matches.length);
    assertEquals("col·laboració", matches[0].getSuggestedReplacements().get(0));
    matches = rule.match(langTool.getAnalyzedSentence("sssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssss"));
    assertEquals(1, matches.length);
    matches = rule.match(langTool.getAnalyzedSentence("plassa"));
    assertEquals(1, matches.length);
    assertEquals("plaça", matches[0].getSuggestedReplacements().get(0));
    matches = rule.match(langTool.getAnalyzedSentence("Deú"));
    assertEquals(1, matches.length);
    assertEquals("Deu", matches[0].getSuggestedReplacements().get(0));
    assertEquals("Déu", matches[0].getSuggestedReplacements().get(1));
    matches = rule.match(langTool.getAnalyzedSentence("joan"));
    assertEquals(1, matches.length);
    assertEquals(0, matches[0].getFromPos());
    assertEquals(4, matches[0].getToPos());
    assertEquals("Joan", matches[0].getSuggestedReplacements().get(0));
    matches = rule.match(langTool.getAnalyzedSentence("abatusats"));
    assertEquals(1, matches.length);
    assertEquals(0, matches[0].getFromPos());
    assertEquals(9, matches[0].getToPos());
    assertEquals("abatussats", matches[0].getSuggestedReplacements().get(0));
    // incomplete multiword
    matches = rule.match(langTool.getAnalyzedSentence("L'statu"));
    assertEquals(1, matches.length);
    assertEquals(2, matches[0].getFromPos());
    assertEquals(7, matches[0].getToPos());
    assertEquals("tato", matches[0].getSuggestedReplacements().get(0));
    matches = rule.match(langTool.getAnalyzedSentence("argüit"));
    assertEquals(1, matches.length);
    assertEquals(0, matches[0].getFromPos());
    assertEquals(6, matches[0].getToPos());
    assertEquals("arguït", matches[0].getSuggestedReplacements().get(0));
    assertEquals("argüir", matches[0].getSuggestedReplacements().get(1));
    assertEquals("argüint", matches[0].getSuggestedReplacements().get(2));
    matches = rule.match(langTool.getAnalyzedSentence("ángel"));
    assertEquals(1, matches.length);
    assertEquals("àngel", matches[0].getSuggestedReplacements().get(0));
    assertEquals("Àngel", matches[0].getSuggestedReplacements().get(1));
    matches = rule.match(langTool.getAnalyzedSentence("caçessim"));
    assertEquals(1, matches.length);
    assertEquals("cacéssim", matches[0].getSuggestedReplacements().get(0));
    assertEquals("cassàssim", matches[0].getSuggestedReplacements().get(1));
    assertEquals("casséssim", matches[0].getSuggestedReplacements().get(2));
    assertEquals("casàssim", matches[0].getSuggestedReplacements().get(3));
    assertEquals("caséssim", matches[0].getSuggestedReplacements().get(4));
    matches = rule.match(langTool.getAnalyzedSentence("coche"));
    assertEquals(1, matches.length);
    assertEquals("cotxe", matches[0].getSuggestedReplacements().get(0));
    assertEquals("cuixa", matches[0].getSuggestedReplacements().get(1));
    assertEquals("coixa", matches[0].getSuggestedReplacements().get(2));
    matches = rule.match(langTool.getAnalyzedSentence("cantaríà"));
    assertEquals(1, matches.length);
    assertEquals("cantaria", matches[0].getSuggestedReplacements().get(0));
    assertEquals("cantera", matches[0].getSuggestedReplacements().get(1));
    //best suggestion first
    matches = rule.match(langTool.getAnalyzedSentence("poguem"));
    assertEquals(1, matches.length);
    assertEquals("puguem", matches[0].getSuggestedReplacements().get(0));
    //incorrect mixed case words
    assertEquals(1, rule.match(langTool.getAnalyzedSentence("PH")).length);
    assertEquals(1, rule.match(langTool.getAnalyzedSentence("Ph")).length);
    assertEquals(1, rule.match(langTool.getAnalyzedSentence("MCDonald")).length);
    matches = rule.match(langTool.getAnalyzedSentence("tAula"));
    assertEquals(1, matches.length);
    assertEquals("taula", matches[0].getSuggestedReplacements().get(0));
    matches = rule.match(langTool.getAnalyzedSentence("TAula"));
    assertEquals(1, matches.length);
    assertEquals("Taula", matches[0].getSuggestedReplacements().get(0));
    matches = rule.match(langTool.getAnalyzedSentence("col·Labora"));
    assertEquals(1, matches.length);
    assertEquals("col·labora", matches[0].getSuggestedReplacements().get(0));
    matches = rule.match(langTool.getAnalyzedSentence("col·laborÀ"));
    assertEquals(1, matches.length);
    assertEquals("col·laborà", matches[0].getSuggestedReplacements().get(0));
    matches = rule.match(langTool.getAnalyzedSentence("después"));
    assertEquals(1, matches.length);
    assertEquals("després", matches[0].getSuggestedReplacements().get(0));
    matches = rule.match(langTool.getAnalyzedSentence("dessinstalasio"));
    assertEquals(1, matches.length);
    assertEquals("desinstal·làssiu", matches[0].getSuggestedReplacements().get(0));
    assertEquals("desinstal·lació", matches[0].getSuggestedReplacements().get(1));
    matches = rule.match(langTool.getAnalyzedSentence("matitzàrem"));
    assertEquals(1, matches.length);
    assertEquals("matisarem", matches[0].getSuggestedReplacements().get(0));
    assertEquals("matisàrem", matches[0].getSuggestedReplacements().get(1));
    matches = rule.match(langTool.getAnalyzedSentence("tamitzéssim"));
    assertEquals(1, matches.length);
    assertEquals("tamisàssim", matches[0].getSuggestedReplacements().get(0));
    matches = rule.match(langTool.getAnalyzedSentence("adquireixquen"));
    assertEquals(1, matches.length);
    assertEquals("adquirisquen", matches[0].getSuggestedReplacements().get(0));
    assertEquals("adquiresquen", matches[0].getSuggestedReplacements().get(1));
    matches = rule.match(langTool.getAnalyzedSentence("calificar"));
    assertEquals(1, matches.length);
    assertEquals("qualificar", matches[0].getSuggestedReplacements().get(0));
    matches = rule.match(langTool.getAnalyzedSentence("desconte"));
    assertEquals(1, matches.length);
    assertEquals("descompte", matches[0].getSuggestedReplacements().get(0));
    matches = rule.match(langTool.getAnalyzedSentence("atentats"));
    assertEquals("atemptats", matches[0].getSuggestedReplacements().get(0));
    matches = rule.match(langTool.getAnalyzedSentence("síntomes"));
    assertEquals("símptomes", matches[0].getSuggestedReplacements().get(0));
    matches = rule.match(langTool.getAnalyzedSentence("atentats"));
    assertEquals("atemptats", matches[0].getSuggestedReplacements().get(0));
    matches = rule.match(langTool.getAnalyzedSentence("contable"));
    assertEquals("comptable", matches[0].getSuggestedReplacements().get(0));
    matches = rule.match(langTool.getAnalyzedSentence("desició"));
    assertEquals("decisió", matches[0].getSuggestedReplacements().get(0));
    matches = rule.match(langTool.getAnalyzedSentence("España"));
    assertEquals("Espanya", matches[0].getSuggestedReplacements().get(0));
    matches = rule.match(langTool.getAnalyzedSentence("concenciosament"));
    assertEquals("conscienciosament", matches[0].getSuggestedReplacements().get(0));
    matches = rule.match(langTool.getAnalyzedSentence("excelent"));
    assertEquals("excel·lent", matches[0].getSuggestedReplacements().get(0));
    matches = rule.match(langTool.getAnalyzedSentence("exceleixquen"));
    assertEquals("excel·lisquen", matches[0].getSuggestedReplacements().get(0));
    matches = rule.match(langTool.getAnalyzedSentence("caligrafia"));
    assertEquals("cal·ligrafia", matches[0].getSuggestedReplacements().get(0));
    matches = rule.match(langTool.getAnalyzedSentence("calificaren"));
    assertEquals("qualificaren", matches[0].getSuggestedReplacements().get(0));
    matches = rule.match(langTool.getAnalyzedSentence("Excelentissim"));
    assertEquals("Excel·lentíssim", matches[0].getSuggestedReplacements().get(0));
    // Needs Morfologik Speller 2.1.0
    matches = rule.match(langTool.getAnalyzedSentence("milisegons"));
    assertEquals("mil·lisegons", matches[0].getSuggestedReplacements().get(0));
    /*  change in Speller necessary: words of length = 4
        matches = rule.match(langTool.getAnalyzedSentence("nula"));
        assertEquals("nul·la", matches[0].getSuggestedReplacements().get(0));*/
    //capitalized wrong words
    matches = rule.match(langTool.getAnalyzedSentence("En la Pecra"));
    assertEquals(1, matches.length);
    assertEquals("Para", matches[0].getSuggestedReplacements().get(0));
    assertEquals("Pare", matches[0].getSuggestedReplacements().get(1));
    matches = rule.match(langTool.getAnalyzedSentence("IVa"));
    assertEquals(1, matches.length);
    assertEquals("Iva", matches[0].getSuggestedReplacements().get(0));
    assertEquals("IVA", matches[0].getSuggestedReplacements().get(1));
    matches = rule.match(langTool.getAnalyzedSentence("Dvd"));
    assertEquals(1, matches.length);
    assertEquals("DVD", matches[0].getSuggestedReplacements().get(0));
    // deprecated characters of "ela geminada"
    assertEquals(0, rule.match(langTool.getAnalyzedSentence("S'hi havien instaŀlat.")).length);
    assertEquals(0, rule.match(langTool.getAnalyzedSentence("S'HI HAVIEN INSTAĿLAT.")).length);
    assertEquals(1, rule.match(langTool.getAnalyzedSentence("aõh")).length);
    assertEquals(0, rule.match(langTool.getAnalyzedSentence("a")).length);
    // pronoms febles
    matches = rule.match(langTool.getAnalyzedSentence("Magradaria"));
    assertEquals("M'agradaria", matches[0].getSuggestedReplacements().get(0));
    matches = rule.match(langTool.getAnalyzedSentence("tenvio"));
    assertEquals("t'envio", matches[0].getSuggestedReplacements().get(0));
    matches = rule.match(langTool.getAnalyzedSentence("portan"));
    assertEquals("porta'n", matches[0].getSuggestedReplacements().get(0));
    matches = rule.match(langTool.getAnalyzedSentence("consultins"));
    assertEquals("consulti'ns", matches[0].getSuggestedReplacements().get(0));
    matches = rule.match(langTool.getAnalyzedSentence("portarvos"));
    assertEquals("portar-vos", matches[0].getSuggestedReplacements().get(0));
    matches = rule.match(langTool.getAnalyzedSentence("portemne"));
    assertEquals("portem-ne", matches[0].getSuggestedReplacements().get(0));
    matches = rule.match(langTool.getAnalyzedSentence("dacontentar"));
    assertEquals("d'acontentar", matches[0].getSuggestedReplacements().get(0));
    matches = rule.match(langTool.getAnalyzedSentence("devidents"));
    assertEquals("de vidents", matches[0].getSuggestedReplacements().get(0));
    assertEquals("d'evidents", matches[0].getSuggestedReplacements().get(1));
    matches = rule.match(langTool.getAnalyzedSentence("lacomplexat"));
    assertEquals("la complexat", matches[0].getSuggestedReplacements().get(0));
    assertEquals("l'acomplexat", matches[0].getSuggestedReplacements().get(1));
    matches = rule.match(langTool.getAnalyzedSentence("dacomplexats"));
    assertEquals("d'acomplexats", matches[0].getSuggestedReplacements().get(0));
    matches = rule.match(langTool.getAnalyzedSentence("lacomplexats"));
    assertEquals("la complexats", matches[0].getSuggestedReplacements().get(0));
    assertEquals("acomplexats", matches[0].getSuggestedReplacements().get(1));
    matches = rule.match(langTool.getAnalyzedSentence("veurehi"));
    assertEquals("veure-hi", matches[0].getSuggestedReplacements().get(0));
    matches = rule.match(langTool.getAnalyzedSentence("veurels"));
    assertEquals("veure'ls", matches[0].getSuggestedReplacements().get(0));
    matches = rule.match(langTool.getAnalyzedSentence("veureles"));
    assertEquals("veure-les", matches[0].getSuggestedReplacements().get(0));
    matches = rule.match(langTool.getAnalyzedSentence("lilla"));
    assertEquals("l'illa", matches[0].getSuggestedReplacements().get(0));
    matches = rule.match(langTool.getAnalyzedSentence("portas"));
    assertEquals("portes", matches[0].getSuggestedReplacements().get(0));
    matches = rule.match(langTool.getAnalyzedSentence("mantenir'me"));
    assertEquals("mantenir-me", matches[0].getSuggestedReplacements().get(0));
    matches = rule.match(langTool.getAnalyzedSentence("elcap"));
    assertEquals("el cap", matches[0].getSuggestedReplacements().get(0));
    matches = rule.match(langTool.getAnalyzedSentence("almeu"));
    assertEquals("al meu", matches[0].getSuggestedReplacements().get(0));
    matches = rule.match(langTool.getAnalyzedSentence("delteu"));
    assertEquals("del teu", matches[0].getSuggestedReplacements().get(0));
    matches = rule.match(langTool.getAnalyzedSentence("unshomes"));
    assertEquals("uns homes", matches[0].getSuggestedReplacements().get(0));
    matches = rule.match(langTool.getAnalyzedSentence("pelsseus"));
    assertEquals("pels seus", matches[0].getSuggestedReplacements().get(0));
    matches = rule.match(langTool.getAnalyzedSentence("daquesta"));
    assertEquals("d'aquesta", matches[0].getSuggestedReplacements().get(0));
    matches = rule.match(langTool.getAnalyzedSentence("daquelles"));
    assertEquals("d'aquelles", matches[0].getSuggestedReplacements().get(0));
    matches = rule.match(langTool.getAnalyzedSentence("lah"));
    assertEquals("la", matches[0].getSuggestedReplacements().get(0));
    matches = rule.match(langTool.getAnalyzedSentence("dela"));
    assertEquals("de la", matches[0].getSuggestedReplacements().get(0));
    matches = rule.match(langTool.getAnalyzedSentence("sha"));
    assertEquals("s'ha", matches[0].getSuggestedReplacements().get(0));
    assertEquals("xe", matches[0].getSuggestedReplacements().get(1));
    assertEquals("xa", matches[0].getSuggestedReplacements().get(2));
    matches = rule.match(langTool.getAnalyzedSentence("Sha"));
    assertEquals("S'ha", matches[0].getSuggestedReplacements().get(0));
    //assertEquals("Xe", matches[0].getSuggestedReplacements().get(1));
    //assertEquals("Xa", matches[0].getSuggestedReplacements().get(2));
    //Ela geminada 
    matches = rule.match(langTool.getAnalyzedSentence("La sol•licitud"));
    assertEquals("sol·licitud", matches[0].getSuggestedReplacements().get(0));
    matches = rule.match(langTool.getAnalyzedSentence("La sol-licitud"));
    assertEquals("sol·licitud", matches[0].getSuggestedReplacements().get(0));
    matches = rule.match(langTool.getAnalyzedSentence("SOL.LICITUD"));
    assertEquals("Sol·licitud", matches[0].getSuggestedReplacements().get(0));
    matches = rule.match(langTool.getAnalyzedSentence("La sol⋅licitud"));
    assertEquals("sol·licitud", matches[0].getSuggestedReplacements().get(0));
    matches = rule.match(langTool.getAnalyzedSentence("La sol∙licitud"));
    assertEquals("sol·licitud", matches[0].getSuggestedReplacements().get(0));
    matches = rule.match(langTool.getAnalyzedSentence("un estat sindical-laborista"));
    assertEquals(0, matches.length);
    matches = rule.match(langTool.getAnalyzedSentence("en un estat sindical.La classe obrera"));
    assertEquals(0, matches.length);
    matches = rule.match(langTool.getAnalyzedSentence("al-Ladjdjun"));
    assertEquals(3, matches[0].getFromPos());
    assertEquals(11, matches[0].getToPos());
    // "ela geminada" error + another spelling error
    matches = rule.match(langTool.getAnalyzedSentence("La sol•licitut"));
    assertEquals("sol·licitud", matches[0].getSuggestedReplacements().get(0));
    matches = rule.match(langTool.getAnalyzedSentence("Il•lustran"));
    assertEquals("Il·lustren", matches[0].getSuggestedReplacements().get(0));
    matches = rule.match(langTool.getAnalyzedSentence("bél.lica"));
    assertEquals("bèl·lica", matches[0].getSuggestedReplacements().get(0));
}
Also used : RuleMatch(org.languagetool.rules.RuleMatch) JLanguageTool(org.languagetool.JLanguageTool) Catalan(org.languagetool.language.Catalan) Test(org.junit.Test)

Example 7 with Catalan

use of org.languagetool.language.Catalan in project languagetool by languagetool-org.

the class ReflexiveVerbsRuleTest method setUp.

@Before
public void setUp() throws IOException {
    rule = new ReflexiveVerbsRule(TestTools.getEnglishMessages());
    langTool = new JLanguageTool(new Catalan());
}
Also used : JLanguageTool(org.languagetool.JLanguageTool) Catalan(org.languagetool.language.Catalan) Before(org.junit.Before)

Example 8 with Catalan

use of org.languagetool.language.Catalan in project languagetool by languagetool-org.

the class SimpleReplaceBalearicRuleTest method setUp.

@Before
public void setUp() throws Exception {
    rule = new SimpleReplaceBalearicRule(TestTools.getMessages("ca"));
    langTool = new JLanguageTool(new Catalan());
}
Also used : JLanguageTool(org.languagetool.JLanguageTool) Catalan(org.languagetool.language.Catalan) Before(org.junit.Before)

Example 9 with Catalan

use of org.languagetool.language.Catalan in project languagetool by languagetool-org.

the class JLanguageToolTest method testCleanOverlappingErrors.

@Test
public void testCleanOverlappingErrors() throws IOException {
    JLanguageTool tool = new JLanguageTool(new Catalan());
    List<RuleMatch> matches = tool.check("prosper");
    assertEquals(1, matches.size());
    assertEquals("CA_SIMPLE_REPLACE_BALEARIC", matches.get(0).getRule().getId());
    matches = tool.check("Potser siga el millor");
    assertEquals(1, matches.size());
    assertEquals("POTSER_SIGUI", matches.get(0).getRule().getId());
}
Also used : RuleMatch(org.languagetool.rules.RuleMatch) Catalan(org.languagetool.language.Catalan) Test(org.junit.Test)

Example 10 with Catalan

use of org.languagetool.language.Catalan in project languagetool by languagetool-org.

the class CatalanWordRepeatRuleTest method testRule.

/*
   * Test method for 'org.languagetool.rules.ca.CatalanWordRepeatRule.match(AnalyzedSentence)'
   */
@Test
public void testRule() throws IOException {
    final CatalanWordRepeatRule rule = new CatalanWordRepeatRule(TestTools.getMessages("ca"), new Catalan());
    RuleMatch[] matches;
    JLanguageTool langTool = new JLanguageTool(new Catalan());
    //correct
    matches = rule.match(langTool.getAnalyzedSentence("Sempre pensa en en Joan."));
    assertEquals(0, matches.length);
    matches = rule.match(langTool.getAnalyzedSentence("Els els portaré aviat."));
    assertEquals(0, matches.length);
    matches = rule.match(langTool.getAnalyzedSentence("Maximilià I i Maria de Borgonya"));
    assertEquals(0, matches.length);
    matches = rule.match(langTool.getAnalyzedSentence("De la A a la z"));
    assertEquals(0, matches.length);
    matches = rule.match(langTool.getAnalyzedSentence("Entre I i II."));
    assertEquals(0, matches.length);
    matches = rule.match(langTool.getAnalyzedSentence("fills de Sigebert I i Brunegilda"));
    assertEquals(0, matches.length);
    matches = rule.match(langTool.getAnalyzedSentence("del segle I i del segle II"));
    assertEquals(0, matches.length);
    matches = rule.match(langTool.getAnalyzedSentence("entre el capítol I i el II"));
    assertEquals(0, matches.length);
    matches = rule.match(langTool.getAnalyzedSentence("cada una una casa"));
    assertEquals(0, matches.length);
    matches = rule.match(langTool.getAnalyzedSentence("cada un un llibre"));
    assertEquals(0, matches.length);
    //incorrect
    matches = rule.match(langTool.getAnalyzedSentence("Tots els els homes són iguals."));
    assertEquals(1, matches.length);
    matches = rule.match(langTool.getAnalyzedSentence("Maximilià i i Maria de Borgonya"));
    assertEquals(1, matches.length);
}
Also used : RuleMatch(org.languagetool.rules.RuleMatch) JLanguageTool(org.languagetool.JLanguageTool) Catalan(org.languagetool.language.Catalan) Test(org.junit.Test)

Aggregations

Catalan (org.languagetool.language.Catalan)16 JLanguageTool (org.languagetool.JLanguageTool)14 Before (org.junit.Before)9 Test (org.junit.Test)7 RuleMatch (org.languagetool.rules.RuleMatch)6 CatalanTagger (org.languagetool.tagging.ca.CatalanTagger)1 SRXSentenceTokenizer (org.languagetool.tokenizers.SRXSentenceTokenizer)1 CatalanWordTokenizer (org.languagetool.tokenizers.ca.CatalanWordTokenizer)1