use of org.languagetool.language.Polish in project languagetool by languagetool-org.
the class PolishWordRepeatRuleTest method testRule.
@Test
public void testRule() throws IOException {
final PolishWordRepeatRule rule = new PolishWordRepeatRule(TestTools.getEnglishMessages());
RuleMatch[] matches;
JLanguageTool langTool = new JLanguageTool(new Polish());
//correct
matches = rule.match(langTool.getAnalyzedSentence("To jest zdanie próbne."));
assertEquals(0, matches.length);
matches = rule.match(langTool.getAnalyzedSentence("On tak się bardzo nie martwił, bo przecież musiał się umyć."));
assertEquals(0, matches.length);
//repeated prepositions, don't count'em
matches = rule.match(langTool.getAnalyzedSentence("Na dyskotece tańczył jeszcze, choć był na bani."));
assertEquals(0, matches.length);
// sf bug report:
matches = rule.match(langTool.getAnalyzedSentence("Żadnych „ale”."));
assertEquals(0, matches.length);
//incorrect
matches = rule.match(langTool.getAnalyzedSentence("Był on bowiem pięknym strzelcem bowiem."));
assertEquals(1, matches.length);
matches = rule.match(langTool.getAnalyzedSentence("Mówiła długo, żeby tylko mówić długo."));
assertEquals(2, matches.length);
}
use of org.languagetool.language.Polish in project languagetool by languagetool-org.
the class SimpleReplaceRuleTest method setUp.
@Before
public void setUp() throws Exception {
rule = new SimpleReplaceRule(TestTools.getMessages("pl"));
langTool = new JLanguageTool(new Polish());
}
use of org.languagetool.language.Polish in project languagetool by languagetool-org.
the class ToolsTest method testCorrect.
@Test
public void testCorrect() throws IOException, ParserConfigurationException, SAXException {
JLanguageTool tool = new JLanguageTool(new Polish());
tool.setCleanOverlappingMatches(false);
String correct = Tools.correctText("To jest całkowicie prawidłowe zdanie.", tool);
assertEquals("To jest całkowicie prawidłowe zdanie.", correct);
correct = Tools.correctText("To jest jest problem.", tool);
assertEquals("To jest problem.", correct);
// more sentences, need to apply more suggestions > 1 in subsequent sentences
correct = Tools.correctText("To jest jest problem. Ale to już już nie jest problem.", tool);
assertEquals("To jest problem. Ale to już nie jest problem.", correct);
correct = Tools.correctText("To jest jest problem. Ale to już już nie jest problem. Tak sie nie robi. W tym zdaniu brakuje przecinka bo go zapomniałem.", tool);
assertEquals("To jest problem. Ale to już nie jest problem. Tak się nie robi. W tym zdaniu brakuje przecinka, bo go zapomniałem.", correct);
}
use of org.languagetool.language.Polish in project languagetool by languagetool-org.
the class FalseFriendsAsBitextLoaderTest method testHintsForPolishTranslators.
@Test
public void testHintsForPolishTranslators() throws IOException, ParserConfigurationException, SAXException {
Polish polish = new Polish();
English english = new English();
JLanguageTool langTool = new JLanguageTool(english, polish);
JLanguageTool trgTool = new JLanguageTool(polish);
FalseFriendsAsBitextLoader ruleLoader = new FalseFriendsAsBitextLoader();
String name = "/false-friends.xml";
List<BitextPatternRule> rules = ruleLoader.getFalseFriendsAsBitext(name, english, polish);
assertErrors(1, rules, "This is an absurd.", "To absurd.", langTool, trgTool);
assertErrors(1, rules, "I have to speak to my advocate.", "Muszę porozmawiać z adwokatem.", langTool, trgTool);
assertErrors(1, rules, "This is not actual.", "To nie jest aktualne.", langTool, trgTool);
assertErrors(0, rules, "This is not actual.", "To nie jest rzeczywiste.", langTool, trgTool);
}
use of org.languagetool.language.Polish in project languagetool by languagetool-org.
the class MatchTest method testSpeller.
@Test
public void testSpeller() throws Exception {
//tests with synthesizer
Match match = getMatch("POS1", "POS2", true);
final Polish polish = new Polish();
MatchState matchState = new MatchState(match, polish.getSynthesizer());
matchState.setToken(getAnalyzedTokenReadings("inflectedform11", "POS1", "Lemma1"));
//getting empty strings, which is what we want
assertEquals("[]", Arrays.toString(matchState.toFinalString(polish)));
// contrast with a speller = false!
match = getMatch("POS1", "POS2", false);
matchState = new MatchState(match, polish.getSynthesizer());
matchState.setToken(getAnalyzedTokenReadings("inflectedform11", "POS1", "Lemma1"));
assertEquals("[(inflectedform11)]", Arrays.toString(matchState.toFinalString(polish)));
//and now a real word - we should get something
match = getMatch("subst:sg:acc.nom:m3", "subst:sg:gen:m3", true);
matchState = new MatchState(match, polish.getSynthesizer());
matchState.setToken(getAnalyzedTokenReadings("AON", "subst:sg:acc.nom:m3", "AON"));
assertEquals("[AON-u]", Arrays.toString(matchState.toFinalString(polish)));
//and now pure text changes
match = getTextMatch("^(.*)$", "$0-u", true);
match.setLemmaString("AON");
matchState = new MatchState(match, polish.getSynthesizer());
assertEquals("[AON-u]", Arrays.toString(matchState.toFinalString(polish)));
match.setLemmaString("batalion");
//should be empty
matchState = new MatchState(match, polish.getSynthesizer());
assertEquals("[]", Arrays.toString(matchState.toFinalString(polish)));
match.setLemmaString("ASEAN");
//and this one not
matchState = new MatchState(match, polish.getSynthesizer());
assertEquals("[ASEAN-u]", Arrays.toString(matchState.toFinalString(polish)));
}
Aggregations