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);
}
}
}
}
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();
}
Aggregations