Package org.languagetool.language

Examples of org.languagetool.language.English


              match.getSuggestedReplacements());
    }
  }

  public void testEnglish() throws IOException {
    final JLanguageTool tool = new JLanguageTool(new English());
    assertEquals(0, tool.check("A test that should not give errors.").size());
    assertEquals(1, tool.check("A test test that should give errors.").size());
    assertEquals(0, tool.check("I can give you more a detailed description.").size());
    assertEquals(10, tool.getAllRules().size());
    tool.activateDefaultPatternRules();
View Full Code Here


    assertEquals(2, match.getLine());
    assertEquals(14, match.getColumn());   // TODO: should actually be 15, as in testPositionsWithEnglish()
  }

  public void testAnalyzedSentence() throws IOException {
    final JLanguageTool tool = new JLanguageTool(new English());
    //test soft-hyphen ignoring:
    assertEquals("<S> This[this/DT]  is[be/VBZ]  a[a/DT]  test­ed[tested/JJ,test/VBD,test/VBN,test­ed]  sentence[sentence/NN,sentence/VB,sentence/VBP].[./.,</S>]", tool.getAnalyzedSentence("This is a test\u00aded sentence.").toString());
    //test paragraph ends adding
    assertEquals("<S> </S><P/> ", tool.getAnalyzedSentence("\n").toString());
 
View Full Code Here

    //test paragraph ends adding
    assertEquals("<S> </S><P/> ", tool.getAnalyzedSentence("\n").toString());
 
 
  public void testParagraphRules() throws IOException {
    final JLanguageTool tool = new JLanguageTool(new English());
   
    //run normally
    List<RuleMatch> matches = tool.check("(This is an quote.\n It ends in the second sentence.");
    assertEquals(2, matches.size());
    assertEquals(2, tool.getSentenceCount());
View Full Code Here

    assertEquals("EN_UNPAIRED_BRACKETS", matches.get(0).getRule().getId());
    assertEquals(2, tool.getSentenceCount());
 
   
  public void testWhitespace() throws IOException {
    final JLanguageTool tool = new JLanguageTool(new English());
    final AnalyzedSentence raw = tool.getRawAnalyzedSentence("Let's do a \"test\", do you understand?");
    final AnalyzedSentence cooked = tool.getAnalyzedSentence("Let's do a \"test\", do you understand?");
    //test if there was a change
    assertFalse(raw.equals(cooked));
    //see if nothing has been deleted
View Full Code Here

  }

  public void testOverlapFilter() throws IOException {
    final Category category = new Category("test category");
    final List<Element> elements1 = Arrays.asList(new Element("one", true, false, false));
    final PatternRule rule1 = new PatternRule("id1", new English(), elements1, "desc1", "msg1", "shortMsg1");
    rule1.setSubId("1");
    rule1.setCategory(category);

    final List<Element> elements2 = Arrays.asList(new Element("one", true, false, false), new Element("two", true, false, false));
    final PatternRule rule2 = new PatternRule("id1", new English(), elements2, "desc2", "msg2", "shortMsg2");
    rule2.setSubId("2");
    rule2.setCategory(category);

    final JLanguageTool tool = new JLanguageTool(new English());
    tool.addRule(rule1);
    tool.addRule(rule2);

    final List<RuleMatch> ruleMatches1 = tool.check("And one two three.");
    assertEquals("one overlapping rule must be filtered out", 1, ruleMatches1.size());
View Full Code Here

public class EnglishRuleDisambiguator extends AbstractRuleDisambiguator {

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

  private JLanguageTool langTool;

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

  }
 
  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());
   
View Full Code Here

  private Rule rule;
  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

    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: "
View Full Code Here

TOP

Related Classes of org.languagetool.language.English

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.