Package org.languagetool.language

Examples of org.languagetool.language.English


    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,B-NP-singular|E-NP-singular] " +
        "is[be/VBZ,B-VP] a[a/DT,B-NP-singular] " +
        "test­ed[tested/JJ,test/VBD,test/VBN,test­ed/null,I-NP-singular] " +
        "sentence[sentence/NN,E-NP-singular].[./.,</S>,O]",
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

import java.io.IOException;

public class ToolsTest extends TestCase {

  public void testCorrect() throws IOException, ParserConfigurationException, SAXException {
    final JLanguageTool tool = new JLanguageTool(new English());
    tool.activateDefaultPatternRules();
    tool.activateDefaultFalseFriendRules();
    assertEquals("This is a test.", Tools.correctText("This is an test.", tool));
  }
View Full Code Here

    assertThat(readingsList.get(14).getChunkTags().toString(), is("[I-VP]"));
  }

  @Test
  public void testContractions() throws Exception {
    JLanguageTool langTool = new JLanguageTool(new English());
    AnalyzedSentence analyzedSentence = langTool.getAnalyzedSentence("I'll be there");
    AnalyzedTokenReadings[] tokens = analyzedSentence.getTokens();
    assertThat(tokens[1].getChunkTags().get(0), is(new ChunkTag("B-NP-singular")));
    assertThat(tokens[2].getChunkTags().size(), is(0))// "'" cannot be mapped as we tokenize differently
    assertThat(tokens[3].getChunkTags().size(), is(0))// "ll" cannot be mapped as we tokenize differently
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

    tagger = new EnglishTagger();
    tokenizer = new WordTokenizer();
  }
 
  public void testDictionary() throws IOException {
    TestTools.testDictionary(tagger, new English());
  }
View Full Code Here

public class UppercaseSentenceStartRuleTest extends TestCase {

  public void testNonSentences() throws IOException {
    // In OO/LO we get text per paragraph, and list items are a paragraph.
    // Make sure the items that don't look like a sentence generate no error.
    final JLanguageTool lt = new JLanguageTool(new English());
   
    /*assertEquals(0, lt.check("a list item").size());
    assertEquals(0, lt.check("a list item,").size());
    assertEquals(0, lt.check("with trailing whitespace, ").size());
    assertEquals(0, lt.check("a list item;").size());
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.