Search in sources :

Example 26 with English

use of org.languagetool.language.English in project languagetool by languagetool-org.

the class AvsAnRuleTest method testPositions.

@Test
public void testPositions() throws IOException {
    RuleMatch[] matches;
    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());
}
Also used : English(org.languagetool.language.English) RuleMatch(org.languagetool.rules.RuleMatch) JLanguageTool(org.languagetool.JLanguageTool) Test(org.junit.Test)

Example 27 with English

use of org.languagetool.language.English in project languagetool by languagetool-org.

the class ContractionSpellingRuleTest method setUp.

@Before
public void setUp() throws Exception {
    rule = new ContractionSpellingRule(TestTools.getMessages("en"));
    langTool = new JLanguageTool(new English());
}
Also used : English(org.languagetool.language.English) JLanguageTool(org.languagetool.JLanguageTool) Before(org.junit.Before)

Example 28 with English

use of org.languagetool.language.English in project languagetool by languagetool-org.

the class EnglishPatternRuleTest method testBug.

// used to cause an ArrayIndexOutOfBoundsException in MatchState.setToken()
@Test
public void testBug() throws Exception {
    JLanguageTool langTool = new JLanguageTool(new English());
    langTool.check("Alexander between 369 and 358 BC\n\nAlexander");
}
Also used : English(org.languagetool.language.English) JLanguageTool(org.languagetool.JLanguageTool) Test(org.junit.Test) PatternRuleTest(org.languagetool.rules.patterns.PatternRuleTest)

Example 29 with English

use of org.languagetool.language.English in project languagetool by languagetool-org.

the class EnglishUnpairedBracketsRuleTest method setUp.

@Before
public void setUp() throws IOException {
    rule = new EnglishUnpairedBracketsRule(TestTools.getEnglishMessages(), new English());
    langTool = new JLanguageTool(new English());
}
Also used : English(org.languagetool.language.English) JLanguageTool(org.languagetool.JLanguageTool) Before(org.junit.Before)

Example 30 with English

use of org.languagetool.language.English in project languagetool by languagetool-org.

the class EnglishUnpairedBracketsRuleTest method testMultipleSentences.

@Test
public void testMultipleSentences() throws IOException {
    JLanguageTool lt = new JLanguageTool(new English());
    assertEquals(0, getMatches("This is multiple sentence text that contains a bracket: " + "[This is bracket. With some text.] and this continues.\n", lt));
    assertEquals(0, getMatches("This is multiple sentence text that contains a bracket. " + "(This is bracket. \n\n With some text.) and this continues.", lt));
    assertEquals(1, getMatches("This is multiple sentence text that contains a bracket: " + "[This is bracket. With some text. And this continues.\n\n", lt));
}
Also used : English(org.languagetool.language.English) JLanguageTool(org.languagetool.JLanguageTool) Test(org.junit.Test)

Aggregations

English (org.languagetool.language.English)35 Test (org.junit.Test)19 JLanguageTool (org.languagetool.JLanguageTool)14 PatternRule (org.languagetool.rules.patterns.PatternRule)8 Rule (org.languagetool.rules.Rule)7 RuleMatch (org.languagetool.rules.RuleMatch)7 PatternToken (org.languagetool.rules.patterns.PatternToken)7 AmericanEnglish (org.languagetool.language.AmericanEnglish)6 BritishEnglish (org.languagetool.language.BritishEnglish)5 Before (org.junit.Before)4 Language (org.languagetool.Language)4 InputStream (java.io.InputStream)3 AnalyzedSentence (org.languagetool.AnalyzedSentence)3 AnalyzedTokenReadings (org.languagetool.AnalyzedTokenReadings)3 ByteArrayInputStream (java.io.ByteArrayInputStream)2 FileInputStream (java.io.FileInputStream)2 IOException (java.io.IOException)2 ArrayList (java.util.ArrayList)2 RAMDirectory (org.apache.lucene.store.RAMDirectory)2 Ignore (org.junit.Ignore)2