Search in sources :

Example 6 with Demo

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

the class MultiThreadedJLanguageToolTest method testCheck.

@Test
public void testCheck() throws IOException {
    MultiThreadedJLanguageTool lt1 = new MultiThreadedJLanguageTool(new Demo());
    lt1.setCleanOverlappingMatches(false);
    List<String> ruleMatchIds1 = getRuleMatchIds(lt1);
    assertEquals(9, ruleMatchIds1.size());
    lt1.shutdown();
    JLanguageTool lt2 = new JLanguageTool(new Demo());
    lt2.setCleanOverlappingMatches(false);
    List<String> ruleMatchIds2 = getRuleMatchIds(lt2);
    assertEquals(ruleMatchIds1, ruleMatchIds2);
}
Also used : Demo(org.languagetool.language.Demo) Test(org.junit.Test)

Example 7 with Demo

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

the class MultiThreadedJLanguageToolTest method testConfigurableThreadPoolSize.

@Test
public void testConfigurableThreadPoolSize() throws IOException {
    MultiThreadedJLanguageTool lt = new MultiThreadedJLanguageTool(new Demo());
    assertEquals(Runtime.getRuntime().availableProcessors(), lt.getThreadPoolSize());
    lt.shutdown();
}
Also used : Demo(org.languagetool.language.Demo) Test(org.junit.Test)

Example 8 with Demo

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

the class MultiThreadedJLanguageToolTest method testTextAnalysis.

@Test
public void testTextAnalysis() throws IOException {
    MultiThreadedJLanguageTool lt = new MultiThreadedJLanguageTool(new Demo());
    List<AnalyzedSentence> analyzedSentences = lt.analyzeText("This is a sentence. And another one.");
    assertThat(analyzedSentences.size(), is(2));
    assertThat(analyzedSentences.get(0).getTokens().length, is(10));
    // sentence start has its own token
    assertThat(analyzedSentences.get(0).getTokensWithoutWhitespace().length, is(6));
    assertThat(analyzedSentences.get(1).getTokens().length, is(7));
    assertThat(analyzedSentences.get(1).getTokensWithoutWhitespace().length, is(5));
    lt.shutdown();
}
Also used : Demo(org.languagetool.language.Demo) Test(org.junit.Test)

Example 9 with Demo

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

the class AbstractPatternRulePerformerTest method testTestAllReadings.

@Test
public void testTestAllReadings() throws Exception {
    PatternToken patternToken1 = new PatternToken("foo", false, false, false);
    PatternRule simpleRule = new PatternRule("FAKE", new Demo(), Collections.singletonList(patternToken1), "descr", "message", "short");
    PatternTokenMatcher elemMatcher = new PatternTokenMatcher(patternToken1);
    AbstractPatternRulePerformer p = new MockAbstractPatternRulePerformer(simpleRule, new Unifier(null, null));
    assertTrue(p.testAllReadings(tokenReadings("foo", null), elemMatcher, null, 0, 0, 0));
    assertFalse(p.testAllReadings(tokenReadings("bar", null), elemMatcher, null, 0, 0, 0));
    assertTrue(p.testAllReadings(tokenReadings("foo", "myChunk"), elemMatcher, null, 0, 0, 0));
    assertTrue(p.testAllReadings(tokenReadings("foo", "otherChunk"), elemMatcher, null, 0, 0, 0));
}
Also used : Demo(org.languagetool.language.Demo) Test(org.junit.Test)

Example 10 with Demo

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

the class AbstractPatternRulePerformerTest method testTestAllReadingsWithChunks.

@Test
public void testTestAllReadingsWithChunks() throws Exception {
    PatternToken chunkPatternToken = new PatternToken(null, false, false, false);
    chunkPatternToken.setChunkTag(new ChunkTag("myChunk"));
    PatternRule simpleRule = new PatternRule("FAKE", new Demo(), Collections.singletonList(chunkPatternToken), "descr", "message", "short");
    PatternTokenMatcher elemMatcher = new PatternTokenMatcher(chunkPatternToken);
    AbstractPatternRulePerformer p = new MockAbstractPatternRulePerformer(simpleRule, new Unifier(null, null));
    assertFalse(p.testAllReadings(tokenReadings("bar", null), elemMatcher, null, 0, 0, 0));
    assertTrue(p.testAllReadings(tokenReadings("bar", "myChunk"), elemMatcher, null, 0, 0, 0));
    assertFalse(p.testAllReadings(tokenReadings("bar", "otherChunk"), elemMatcher, null, 0, 0, 0));
}
Also used : ChunkTag(org.languagetool.chunking.ChunkTag) Demo(org.languagetool.language.Demo) Test(org.junit.Test)

Aggregations

Demo (org.languagetool.language.Demo)15 Test (org.junit.Test)14 ByteArrayInputStream (java.io.ByteArrayInputStream)1 RejectedExecutionException (java.util.concurrent.RejectedExecutionException)1 Before (org.junit.Before)1 JLanguageTool (org.languagetool.JLanguageTool)1 ChunkTag (org.languagetool.chunking.ChunkTag)1 RuleMatch (org.languagetool.rules.RuleMatch)1 ManualSynthesizer (org.languagetool.synthesis.ManualSynthesizer)1 ManualSynthesizerAdapter (org.languagetool.synthesis.ManualSynthesizerAdapter)1 ManualTagger (org.languagetool.tagging.ManualTagger)1 ManualTaggerAdapter (org.languagetool.tokenizers.ManualTaggerAdapter)1