Search in sources :

Example 66 with RuleMatch

use of org.languagetool.rules.RuleMatch in project languagetool by languagetool-org.

the class AccentuationCheckRuleTest method testPositions.

@Test
public void testPositions() throws IOException {
    final AccentuationCheckRule rule = new AccentuationCheckRule(TestTools.getEnglishMessages());
    final RuleMatch[] matches;
    final JLanguageTool langTool = new JLanguageTool(new Catalan());
    matches = rule.match(langTool.getAnalyzedSentence("Són circumstancies extraordinàries."));
    assertEquals(4, matches[0].getFromPos());
    assertEquals(18, matches[0].getToPos());
}
Also used : RuleMatch(org.languagetool.rules.RuleMatch) JLanguageTool(org.languagetool.JLanguageTool) Catalan(org.languagetool.language.Catalan) Test(org.junit.Test)

Example 67 with RuleMatch

use of org.languagetool.rules.RuleMatch in project languagetool by languagetool-org.

the class CatalanUnpairedBracketsRuleTest method testMultipleSentences.

@Test
public void testMultipleSentences() throws IOException {
    final JLanguageTool tool = new JLanguageTool(new Catalan());
    tool.enableRule("CA_UNPAIRED_BRACKETS");
    List<RuleMatch> matches;
    matches = tool.check("Aquesta és una sentència múltiple amb claudàtors: " + "[Ací hi ha un claudàtor. Amb algun text.] i ací continua.\n");
    assertEquals(0, matches.size());
    matches = tool.check("\"Sóc la teva filla. El corcó no et rosegarà més.\"\n\n");
    assertEquals(0, matches.size());
    matches = tool.check("\"Sóc la teva filla. El corcó no et rosegarà més\".\n\n");
    assertEquals(0, matches.size());
    matches = tool.check("Aquesta és una sentència múltiple amb claudàtors: " + "[Ací hi ha un claudàtor. Amb algun text. I ací continua.\n\n");
    assertEquals(1, matches.size());
    matches = tool.check("«Els manaments diuen: \"No desitjaràs la dona del teu veí\"»");
    //assertEquals(0, matches.size());
    matches = tool.check("Aquesta és una sentència múltiple amb parèntesis " + "(Ací hi ha un parèntesi. \n\n Amb algun text.) i ací continua.");
    assertEquals(0, matches.size());
}
Also used : RuleMatch(org.languagetool.rules.RuleMatch) JLanguageTool(org.languagetool.JLanguageTool) Catalan(org.languagetool.language.Catalan) Test(org.junit.Test)

Example 68 with RuleMatch

use of org.languagetool.rules.RuleMatch 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 69 with RuleMatch

use of org.languagetool.rules.RuleMatch in project languagetool by languagetool-org.

the class AgreementRuleTest method testRegression.

@Test
public void testRegression() throws IOException {
    JLanguageTool lt = new JLanguageTool(new GermanyGerman());
    // used to be not detected > 1.0.1:
    String str = "Und so.\r\nDie Bier.";
    List<RuleMatch> matches = lt.check(str);
    assertEquals(1, matches.size());
}
Also used : RuleMatch(org.languagetool.rules.RuleMatch) JLanguageTool(org.languagetool.JLanguageTool) GermanyGerman(org.languagetool.language.GermanyGerman) Test(org.junit.Test)

Example 70 with RuleMatch

use of org.languagetool.rules.RuleMatch in project languagetool by languagetool-org.

the class AgreementRuleTest method assertBad.

private void assertBad(String s, String... expectedSuggestions) throws IOException {
    RuleMatch[] matches = rule.match(lt.getAnalyzedSentence(s));
    assertEquals("Did not find one match in sentence '" + s + "'", 1, matches.length);
    if (expectedSuggestions.length > 0) {
        RuleMatch match = matches[0];
        List<String> suggestions = match.getSuggestedReplacements();
        assertThat(suggestions, is(Arrays.asList(expectedSuggestions)));
    }
}
Also used : RuleMatch(org.languagetool.rules.RuleMatch)

Aggregations

RuleMatch (org.languagetool.rules.RuleMatch)144 Test (org.junit.Test)64 JLanguageTool (org.languagetool.JLanguageTool)54 ArrayList (java.util.ArrayList)30 AnalyzedTokenReadings (org.languagetool.AnalyzedTokenReadings)14 Rule (org.languagetool.rules.Rule)14 Language (org.languagetool.Language)10 PatternRule (org.languagetool.rules.patterns.PatternRule)10 AnalyzedSentence (org.languagetool.AnalyzedSentence)8 Ukrainian (org.languagetool.language.Ukrainian)8 AbstractPatternRule (org.languagetool.rules.patterns.AbstractPatternRule)8 Matcher (java.util.regex.Matcher)7 English (org.languagetool.language.English)7 IOException (java.io.IOException)6 Catalan (org.languagetool.language.Catalan)6 Polish (org.languagetool.language.Polish)6 GermanyGerman (org.languagetool.language.GermanyGerman)5 AnnotatedText (org.languagetool.markup.AnnotatedText)5 PatternToken (org.languagetool.rules.patterns.PatternToken)5 AnalyzedToken (org.languagetool.AnalyzedToken)4