Search in sources :

Example 1 with English

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

the class UppercaseSentenceStartRuleTest method testRule.

@Test
public void testRule() throws IOException {
    JLanguageTool lt = new JLanguageTool(new English());
    assertEquals(0, lt.check("In Nov. next year.").size());
    assertEquals(0, lt.check("www.languagetool.org is a website.").size());
    assertEquals(0, lt.check("Languagetool.org is a website.").size());
    assertEquals(1, lt.check("languagetool.org is a website.").size());
    assertEquals(1, lt.check("a sentence.").size());
    assertEquals(1, lt.check("a sentence!").size());
}
Also used : English(org.languagetool.language.English) JLanguageTool(org.languagetool.JLanguageTool) Test(org.junit.Test)

Example 2 with English

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

the class EnglishDisambiguationRuleTest method setUp.

@Before
public void setUp() {
    tagger = new EnglishTagger();
    tokenizer = new WordTokenizer();
    sentenceTokenizer = new SRXSentenceTokenizer(new English());
    disambiguator = new XmlRuleDisambiguator(new English());
    disamb2 = new DemoDisambiguator();
}
Also used : English(org.languagetool.language.English) DemoDisambiguator(org.languagetool.tagging.disambiguation.xx.DemoDisambiguator) XmlRuleDisambiguator(org.languagetool.tagging.disambiguation.rules.XmlRuleDisambiguator) WordTokenizer(org.languagetool.tokenizers.WordTokenizer) EnglishTagger(org.languagetool.tagging.en.EnglishTagger) SRXSentenceTokenizer(org.languagetool.tokenizers.SRXSentenceTokenizer) Before(org.junit.Before)

Example 3 with English

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

the class EnglishChunkerTest method testContractions.

@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")));
    // "'" cannot be mapped as we tokenize differently
    assertThat(tokens[2].getChunkTags().size(), is(0));
    // "ll" cannot be mapped as we tokenize differently
    assertThat(tokens[3].getChunkTags().size(), is(0));
    assertThat(tokens[5].getChunkTags().get(0), is(new ChunkTag("I-VP")));
}
Also used : English(org.languagetool.language.English) AnalyzedSentence(org.languagetool.AnalyzedSentence) JLanguageTool(org.languagetool.JLanguageTool) AnalyzedTokenReadings(org.languagetool.AnalyzedTokenReadings) Test(org.junit.Test)

Example 4 with English

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

the class EnglishChunkerTest method testAddChunkTagsSingular.

@Test
public void testAddChunkTagsSingular() throws Exception {
    EnglishChunker chunker = new EnglishChunker();
    JLanguageTool lt = new JLanguageTool(new English());
    List<AnalyzedSentence> sentences = lt.analyzeText("The abacus shows how numbers can be stored");
    List<AnalyzedTokenReadings> readingsList = Arrays.asList(sentences.get(0).getTokens());
    chunker.addChunkTags(readingsList);
    // "The abacus":
    assertThat(readingsList.get(1).getChunkTags().toString(), is("[B-NP-singular]"));
    assertThat(readingsList.get(3).getChunkTags().toString(), is("[E-NP-singular]"));
    // "numbers":
    assertThat(readingsList.get(9).getChunkTags().toString(), is("[B-NP-plural, E-NP-plural]"));
}
Also used : English(org.languagetool.language.English) AnalyzedSentence(org.languagetool.AnalyzedSentence) JLanguageTool(org.languagetool.JLanguageTool) AnalyzedTokenReadings(org.languagetool.AnalyzedTokenReadings) Test(org.junit.Test)

Example 5 with English

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

the class AvsAnRuleTest method setUp.

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

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