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);
}
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();
}
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();
}
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));
}
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));
}
Aggregations