Search in sources :

Example 16 with Polish

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

the class CompoundRuleTest method testCompoundFile.

@Test
public void testCompoundFile() throws IOException {
    final MorfologikPolishSpellerRule spellRule = new MorfologikPolishSpellerRule(TestTools.getMessages("pl"), new Polish());
    final InputStream file = JLanguageTool.getDataBroker().getFromResourceDirAsStream("/pl/compounds.txt");
    try (Scanner scanner = new Scanner(file, "UTF-8")) {
        while (scanner.hasNextLine()) {
            String line = scanner.nextLine().trim();
            if (line.isEmpty() || line.charAt(0) == '#') {
                // ignore comments
                continue;
            }
            if (line.endsWith("+")) {
                line = removeLastCharacter(line);
                line = line.replace('-', ' ');
                final RuleMatch[] ruleMatches = spellRule.match(lt.getAnalyzedSentence(line));
                assertEquals("The entry: " + line + " is not found in the spelling dictionary!", 0, ruleMatches.length);
            } else if (line.endsWith("*")) {
                line = removeLastCharacter(line);
                final RuleMatch[] ruleMatches = spellRule.match(lt.getAnalyzedSentence(line));
                assertEquals("The entry: " + line + " is not found in the spelling dictionary!", 0, ruleMatches.length);
            } else {
                assertEquals("The entry: " + line + " is not found in the spelling dictionary!", 0, spellRule.match(lt.getAnalyzedSentence(line)).length);
                assertEquals("The entry: " + line.replace("-", "") + " is not found in the spelling dictionary!", 0, spellRule.match(lt.getAnalyzedSentence(line.replace("-", ""))).length);
            }
        }
    }
}
Also used : Scanner(java.util.Scanner) Polish(org.languagetool.language.Polish) RuleMatch(org.languagetool.rules.RuleMatch) InputStream(java.io.InputStream) AbstractCompoundRuleTest(org.languagetool.rules.AbstractCompoundRuleTest) Test(org.junit.Test)

Example 17 with Polish

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

the class DashRuleTest method setUp.

@Before
public void setUp() throws Exception {
    langTool = new JLanguageTool(new Polish());
    rule = new DashRule();
}
Also used : Polish(org.languagetool.language.Polish) JLanguageTool(org.languagetool.JLanguageTool) Before(org.junit.Before)

Aggregations

Polish (org.languagetool.language.Polish)17 Test (org.junit.Test)13 JLanguageTool (org.languagetool.JLanguageTool)12 RuleMatch (org.languagetool.rules.RuleMatch)6 Before (org.junit.Before)4 InputStream (java.io.InputStream)1 Scanner (java.util.Scanner)1 Language (org.languagetool.Language)1 English (org.languagetool.language.English)1 AbstractCompoundRuleTest (org.languagetool.rules.AbstractCompoundRuleTest)1 MultipleWhitespaceRule (org.languagetool.rules.MultipleWhitespaceRule)1 WordRepeatRule (org.languagetool.rules.WordRepeatRule)1 AbstractPatternRule (org.languagetool.rules.patterns.AbstractPatternRule)1 Match (org.languagetool.rules.patterns.Match)1 MatchState (org.languagetool.rules.patterns.MatchState)1 BitextPatternRule (org.languagetool.rules.patterns.bitext.BitextPatternRule)1 FalseFriendsAsBitextLoader (org.languagetool.rules.patterns.bitext.FalseFriendsAsBitextLoader)1 PolishTagger (org.languagetool.tagging.pl.PolishTagger)1 SRXSentenceTokenizer (org.languagetool.tokenizers.SRXSentenceTokenizer)1 WordTokenizer (org.languagetool.tokenizers.WordTokenizer)1