Examples of JLanguageTool


Examples of org.languagetool.JLanguageTool

  private JLanguageTool langTool;

  @Override
  public void setUp() throws IOException {
    rule = new AvsAnRule(null);
    langTool = new JLanguageTool(new English());
  }
View Full Code Here

Examples of org.languagetool.JLanguageTool

  }
 
  public void testPositions() throws IOException {
    final AvsAnRule rule = new AvsAnRule(null);
    RuleMatch[] matches;
    final JLanguageTool langTool = new JLanguageTool(new English());
    // no quotes etc.:
    matches = rule.match(langTool.getAnalyzedSentence("a industry standard."));
    assertEquals(0, matches[0].getFromPos());
    assertEquals(1, matches[0].getToPos());
   
    // quotes..
    matches = rule.match(langTool.getAnalyzedSentence("a \"industry standard\"."));
    assertEquals(0, matches[0].getFromPos());
    assertEquals(1, matches[0].getToPos());
   
    matches = rule.match(langTool.getAnalyzedSentence("a - industry standard\"."));
    assertEquals(0, matches[0].getFromPos());
    assertEquals(1, matches[0].getToPos());
   
    matches = rule.match(langTool.getAnalyzedSentence("This is a \"industry standard\"."));
    assertEquals(8, matches[0].getFromPos());
    assertEquals(9, matches[0].getToPos());
   
    matches = rule.match(langTool.getAnalyzedSentence("\"a industry standard\"."));
    assertEquals(1, matches[0].getFromPos());
    assertEquals(2, matches[0].getToPos());
   
    matches = rule.match(langTool.getAnalyzedSentence("\"Many say this is a industry standard\"."));
    assertEquals(18, matches[0].getFromPos());
    assertEquals(19, matches[0].getToPos());
   
    matches = rule.match(langTool.getAnalyzedSentence("Like many \"an desperado\" before him, Bart headed south into Mexico."));
    assertEquals(11, matches[0].getFromPos());
    assertEquals(13, matches[0].getToPos());
  }
View Full Code Here

Examples of org.languagetool.JLanguageTool

  public void testMorfologikSpeller() throws IOException {
    final BritishEnglish language = new BritishEnglish();
    final MorfologikBritishSpellerRule rule =
            new MorfologikBritishSpellerRule (TestTools.getMessages("English"), language);

    final JLanguageTool langTool = new JLanguageTool(language);

    // correct sentences:
    assertEquals(0, rule.match(langTool.getAnalyzedSentence("This is an example: we get behaviour as a dictionary word.")).length);
    assertEquals(0, rule.match(langTool.getAnalyzedSentence("Why don't we speak today.")).length);
    //with doesn't
    assertEquals(0, rule.match(langTool.getAnalyzedSentence("He doesn't know what to do.")).length);
    //with an abbreviation:
    assertEquals(0, rule.match(langTool.getAnalyzedSentence("This is my Ph.D. thesis.")).length);
    assertEquals(0, rule.match(langTool.getAnalyzedSentence(",")).length);
    assertEquals(0, rule.match(langTool.getAnalyzedSentence("123454")).length);

    //incorrect sentences:

    final RuleMatch[] matches = rule.match(langTool.getAnalyzedSentence("Behavior"));
    // check match positions:
    assertEquals(1, matches.length);
    assertEquals(0, matches[0].getFromPos());
    assertEquals(8, matches[0].getToPos());
    assertEquals("behaviour", matches[0].getSuggestedReplacements().get(0));

    assertEquals(1, rule.match(langTool.getAnalyzedSentence("aõh")).length);
    assertEquals(0, rule.match(langTool.getAnalyzedSentence("a")).length);
  }
View Full Code Here

Examples of org.languagetool.JLanguageTool

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

Examples of org.languagetool.JLanguageTool

  public void testMorfologikSpeller() throws IOException {
    final AmericanEnglish language = new AmericanEnglish();
    final MorfologikAmericanSpellerRule rule =
            new MorfologikAmericanSpellerRule (TestTools.getMessages("English"), language);

    final JLanguageTool langTool = new JLanguageTool(language);

    // correct sentences:
    assertEquals(0, rule.match(langTool.getAnalyzedSentence("This is an example: we get behavior as a dictionary word.")).length);
    assertEquals(0, rule.match(langTool.getAnalyzedSentence("Why don't we speak today.")).length);
    assertEquals(0, rule.match(langTool.getAnalyzedSentence("An URL like http://sdaasdwe.com is no error.")).length);
    //with doesn't
    assertEquals(0, rule.match(langTool.getAnalyzedSentence("He doesn't know what to do.")).length);
    assertEquals(0, rule.match(langTool.getAnalyzedSentence(",")).length);
    assertEquals(0, rule.match(langTool.getAnalyzedSentence("123454")).length);

    //incorrect sentences:

    final RuleMatch[] matches = rule.match(langTool.getAnalyzedSentence("behaviour"));
    // check match positions:
    assertEquals(1, matches.length);
    assertEquals(0, matches[0].getFromPos());
    assertEquals(9, matches[0].getToPos());
    assertEquals("behavior", matches[0].getSuggestedReplacements().get(0));

    assertEquals(1, rule.match(langTool.getAnalyzedSentence("aõh")).length);
    assertEquals(0, rule.match(langTool.getAnalyzedSentence("a")).length);
  }
View Full Code Here

Examples of org.languagetool.JLanguageTool

  public void testMorfologikSpeller() throws IOException {
    final CanadianEnglish language = new CanadianEnglish();
    final MorfologikBritishSpellerRule rule =
            new MorfologikBritishSpellerRule (TestTools.getMessages("English"), language);

    final JLanguageTool langTool = new JLanguageTool(language);

    // correct sentences:
    assertEquals(0, rule.match(langTool.getAnalyzedSentence("This is an example: we get behaviour as a dictionary word.")).length);
    assertEquals(0, rule.match(langTool.getAnalyzedSentence("Why don't we speak today.")).length);
    //with doesn't
    assertEquals(0, rule.match(langTool.getAnalyzedSentence("He doesn't know what to do.")).length);
    assertEquals(0, rule.match(langTool.getAnalyzedSentence(",")).length);
    assertEquals(0, rule.match(langTool.getAnalyzedSentence("123454")).length);

    //incorrect sentences:

    final RuleMatch[] matches = rule.match(langTool.getAnalyzedSentence("arbor"));
    // check match positions:
    assertEquals(1, matches.length);
    assertEquals(0, matches[0].getFromPos());
    assertEquals(5, matches[0].getToPos());
    assertEquals("arbour", matches[0].getSuggestedReplacements().get(0));

    assertEquals(1, rule.match(langTool.getAnalyzedSentence("aõh")).length);
    assertEquals(0, rule.match(langTool.getAnalyzedSentence("a")).length);
  }
View Full Code Here

Examples of org.languagetool.JLanguageTool

  private JLanguageTool langTool;
 
  @Override
  public void setUp() throws IOException {
    rule = new EnglishUnpairedBracketsRule(TestTools.getEnglishMessages(), new English());
    langTool = new JLanguageTool(new English());
  }
View Full Code Here

Examples of org.languagetool.JLanguageTool

    final RuleMatch[] matches = rule.match(langTool.getAnalyzedSentence(sentence));
    assertEquals(1, matches.length);
  }
 
  public void testMultipleSentences() throws IOException {
    final JLanguageTool tool = new JLanguageTool(new English());
    tool.enableRule("EN_UNPAIRED_BRACKETS");

    List<RuleMatch> matches;
    matches = tool
        .check("This is multiple sentence text that contains a bracket: "
            + "[This is bracket. With some text.] and this continues.\n");
    assertEquals(0, matches.size());
    matches = tool
        .check("This is multiple sentence text that contains a bracket: "
            + "[This is bracket. With some text. And this continues.\n\n");
    assertEquals(1, matches.size());
    // now with a paragraph end inside - we get two alarms because of paragraph
    // resetting
    matches = tool
        .check("This is multiple sentence text that contains a bracket. "
            + "(This is bracket. \n\n With some text.) and this continues.");
    assertEquals(2, matches.size());
  }
View Full Code Here

Examples of org.languagetool.JLanguageTool

  public void testMorfologikSpeller() throws IOException {
    final NewZealandEnglish language = new NewZealandEnglish();
    final MorfologikNewZealandSpellerRule rule =
            new MorfologikNewZealandSpellerRule (TestTools.getMessages("English"), language);

    final JLanguageTool langTool = new JLanguageTool(language);

    // correct sentences:
    assertEquals(0, rule.match(langTool.getAnalyzedSentence("This is an example: we get behaviour as a dictionary word.")).length);
    assertEquals(0, rule.match(langTool.getAnalyzedSentence("Why don't we speak today.")).length);
    //with doesn't
    assertEquals(0, rule.match(langTool.getAnalyzedSentence("He doesn't know what to do.")).length);
    assertEquals(0, rule.match(langTool.getAnalyzedSentence(",")).length);
    assertEquals(0, rule.match(langTool.getAnalyzedSentence("123454")).length);

    //special New Zealand content:
    assertEquals(0, rule.match(langTool.getAnalyzedSentence("Abercrombie")).length);

    //incorrect sentences:

    final RuleMatch[] matches = rule.match(langTool.getAnalyzedSentence("behavior"));
    // check match positions:
    assertEquals(1, matches.length);
    assertEquals(0, matches[0].getFromPos());
    assertEquals(8, matches[0].getToPos());
    assertEquals("behaviour", matches[0].getSuggestedReplacements().get(0));

    assertEquals(1, rule.match(langTool.getAnalyzedSentence("aõh")).length);
    assertEquals(0, rule.match(langTool.getAnalyzedSentence("a")).length);
  }
View Full Code Here

Examples of org.languagetool.JLanguageTool

  public void testMorfologikSpeller() throws IOException {
    final SouthAfricanEnglish language = new SouthAfricanEnglish();
    final MorfologikSouthAfricanSpellerRule rule =
            new MorfologikSouthAfricanSpellerRule (TestTools.getMessages("English"), language);

    final JLanguageTool langTool = new JLanguageTool(language);

    // correct sentences:
    assertEquals(0, rule.match(langTool.getAnalyzedSentence("This is an example: we get behaviour as a dictionary word.")).length);
    assertEquals(0, rule.match(langTool.getAnalyzedSentence("Why don't we speak today.")).length);
    //with doesn't
    assertEquals(0, rule.match(langTool.getAnalyzedSentence("He doesn't know what to do.")).length);
    assertEquals(0, rule.match(langTool.getAnalyzedSentence(",")).length);
    assertEquals(0, rule.match(langTool.getAnalyzedSentence("123454")).length);

    //South African dict:
    assertEquals(0, rule.match(langTool.getAnalyzedSentence("Amanzimnyama")).length);

    //incorrect sentences:

    final RuleMatch[] matches = rule.match(langTool.getAnalyzedSentence("behavior"));
    // check match positions:
    assertEquals(1, matches.length);
    assertEquals(0, matches[0].getFromPos());
    assertEquals(8, matches[0].getToPos());
    assertEquals("behaviour", matches[0].getSuggestedReplacements().get(0));

    assertEquals(1, rule.match(langTool.getAnalyzedSentence("aõh")).length);
    assertEquals(0, rule.match(langTool.getAnalyzedSentence("a")).length);
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.