Package org.languagetool.language

Examples of org.languagetool.language.Polish


import java.util.List;

public class JLanguageToolTest extends TestCase {

  public void testPolish() throws IOException {
    final Polish polish = new Polish();
    JLanguageTool tool = new JLanguageTool(polish);
    assertEquals("[PL]", Arrays.toString(polish.getCountryVariants()));
    List<RuleMatch> matches = tool.check("To jest całkowicie prawidłowe zdanie.");
    assertEquals(0, matches.size());
    matches = tool.check("To jest jest problem.");
    assertEquals(1, matches.size());
    //this rule is by default off
    matches = tool.check("Był on bowiem pięknym strzelcem bowiem.");
    assertEquals(0, matches.size());
    tool.enableDefaultOffRule("PL_WORD_REPEAT");
    matches = tool.check("Był on bowiem pięknym strzelcem bowiem.");
    assertEquals(1, matches.size());
    tool.activateDefaultPatternRules();
    matches = tool.check("Premier drapie się w ucho co i rusz.");
    assertEquals(1, matches.size());
    // Polish rule has no effect with English error but will get spelling activated:
    matches = tool.check("I can give you more a detailed description");
    assertEquals(6, matches.size());
    tool.setListUnknownWords(true);
    matches = tool.check("This is not a Polish text.");
    assertEquals(3, matches.size());
    assertEquals("[Polish, This, is, text]", tool.getUnknownWords().toString());
    //check positions relative to sentence ends   
    matches = tool.check("To jest tekst.\nTest 1. To jest linia w której nie ma przecinka.");
    assertEquals(17, matches.get(0).getColumn());
    //with a space...
    matches = tool.check("To jest tekst. \nTest 1. To jest linia w której nie ma przecinka.");
    assertEquals(16, matches.get(0).getColumn());
    matches = tool.check("To jest tekst. Test 1. To jest linia w której nie ma przecinka.");
    assertEquals(32, matches.get(0).getColumn());
    //recheck with the -b mode...
    polish.getSentenceTokenizer().setSingleLineBreaksMarksParagraph(true);
    tool = new JLanguageTool(polish);
    tool.activateDefaultPatternRules();
    matches = tool.check("To jest tekst.\nTest 1. To jest linia w której nie ma przecinka.");
    assertEquals(17, matches.get(0).getColumn());
    //with a space...
View Full Code Here


    tagger = new PolishTagger();
    tokenizer = new WordTokenizer();
  }

  public void testDictionary() throws IOException {
    TestTools.testDictionary(tagger, new Polish());
  }
View Full Code Here

public class PolishRuleDisambiguator extends AbstractRuleDisambiguator {

  @Override
  protected Language getLanguage() {
    return new Polish();
  }
View Full Code Here

  }
 
  public void testBitextCheck() throws IOException, ParserConfigurationException, SAXException {
    final English english = new English();
    final JLanguageTool srcTool = new JLanguageTool(english);
    final Polish polish = new Polish();
    final JLanguageTool trgTool = new JLanguageTool(polish);
    trgTool.activateDefaultPatternRules();
   
    final List<BitextRule> rules = Tools.getBitextRules(english, polish);
   
View Full Code Here

  }

  public void testSpeller() throws Exception {
    //tests with synthesizer
    Match match = getMatch("POS1", "POS2", true);
    final Polish polish = new Polish();
    match.setSynthesizer(polish.getSynthesizer());
    match.setToken(getAnalyzedTokenReadings("inflectedform11", "POS1", "Lemma1"));
    //getting empty strings, which is what we want
    assertEquals("[]", Arrays.toString(match.toFinalString(polish)));

    // contrast with a speller = false!
    match = getMatch("POS1", "POS2", false);
    match.setSynthesizer(polish.getSynthesizer());
    match.setToken(getAnalyzedTokenReadings("inflectedform11", "POS1", "Lemma1"));
    assertEquals("[(inflectedform11)]", Arrays.toString(match.toFinalString(polish)));

    //and now a real word - we should get something
    match = getMatch("subst:sg:acc.nom:m3", "subst:sg:gen:m3", true);
    match.setSynthesizer(polish.getSynthesizer());
    match.setToken(getAnalyzedTokenReadings("AON", "subst:sg:acc.nom:m3", "AON"));
    assertEquals("[AON-u]", Arrays.toString(match.toFinalString(polish)));

    //and now pure text changes       
    match = getTextMatch("^(.*)$", "$0-u", true);
    match.setSynthesizer(polish.getSynthesizer());
    match.setLemmaString("AON");
    assertEquals("[AON-u]", Arrays.toString(match.toFinalString(polish)));
    match.setLemmaString("batalion");
    //should be empty
    assertEquals("[]", Arrays.toString(match.toFinalString(polish)));
View Full Code Here

public class MorfologikPolishSpellerRuleTest {

  @Test
  public void testMorfologikSpeller() throws IOException {
    final MorfologikPolishSpellerRule rule =
            new MorfologikPolishSpellerRule (TestTools.getMessages("Polish"), new Polish());

    final JLanguageTool langTool = new JLanguageTool(new Polish());

    // correct sentences:
    assertEquals(0, rule.match(langTool.getAnalyzedSentence("To jest test bez jakiegokolwiek błędu.")).length);
    assertEquals(0, rule.match(langTool.getAnalyzedSentence("Żółw na starość wydziela dziwną woń.")).length);
    //test for "LanguageTool":
View Full Code Here

import java.io.IOException;

public class WhitespaceRuleTest extends TestCase {

    public void testRule() throws IOException {
      final WhitespaceRule rule = new WhitespaceRule(TestTools.getEnglishMessages(), new Polish());
      final JLanguageTool langTool = new JLanguageTool(new Polish());
      assertEquals(0, rule.match(langTool.getAnalyzedSentence("To jest test.")).length);
      assertEquals(1, rule.match(langTool.getAnalyzedSentence("To jest   test.")).length);
    }
View Full Code Here

  @Override
  protected void setUp() throws Exception {
    super.setUp();
    rule = new SimpleReplaceRule(TestTools.getMessages("pl"));
    langTool = new JLanguageTool(new Polish());
  }
View Full Code Here

   * Test method for 'org.languagetool.rules.pl.PolishWordRepeatRule.match(AnalyzedSentence)'
   */
  public void testRule() throws IOException {
      final PolishWordRepeatRule rule = new PolishWordRepeatRule(null);
      RuleMatch[] matches;
      JLanguageTool langTool = new JLanguageTool(new Polish());
      //correct
      matches = rule.match(langTool.getAnalyzedSentence("To jest zdanie próbne."));
      assertEquals(0, matches.length);
      //repeated prepositions, don't count'em
      matches = rule.match(langTool.getAnalyzedSentence("Na dyskotece tańczył jeszcze, choć był na bani."));     
View Full Code Here

    System.setOut(this.stdout);
    System.setErr(this.stderr);
  }

  public void testCheck() throws IOException, ParserConfigurationException, SAXException {
    final JLanguageTool tool = new JLanguageTool(new Polish());
    tool.activateDefaultPatternRules();
    tool.activateDefaultFalseFriendRules();
    int matches = Tools.checkText("To jest całkowicie prawidłowe zdanie.", tool);
    String output = new String(this.out.toByteArray());
View Full Code Here

TOP

Related Classes of org.languagetool.language.Polish

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.