use of org.languagetool.language.English in project languagetool by languagetool-org.
the class TatoebaSentenceSourceTest method testTatoebaSourceInvalidInput.
@Test(expected = RuntimeException.class)
public void testTatoebaSourceInvalidInput() throws UnsupportedEncodingException {
ByteArrayInputStream stream = new ByteArrayInputStream("just a text".getBytes("utf-8"));
TatoebaSentenceSource source = new TatoebaSentenceSource(stream, new English());
source.hasNext();
}
use of org.languagetool.language.English in project languagetool by languagetool-org.
the class TatoebaSentenceSourceTest method testTatoebaSource.
@Test
public void testTatoebaSource() {
InputStream stream = WikipediaSentenceSourceTest.class.getResourceAsStream("/org/languagetool/dev/wikipedia/tatoeba-en.txt");
TatoebaSentenceSource source = new TatoebaSentenceSource(stream, new English());
assertTrue(source.hasNext());
assertThat(source.next().getText(), is("\"What is your wish?\" asked the little white rabbit."));
assertThat(source.next().getText(), is("The mother wakes up her daughter."));
assertThat(source.next().getText(), is("Ken beat me at chess."));
assertFalse(source.hasNext());
}
use of org.languagetool.language.English in project languagetool by languagetool-org.
the class IndexerSearcherTest method testNegatedMatchAtSentenceStart.
public void testNegatedMatchAtSentenceStart() throws Exception {
createIndex("How to move?");
PatternToken negatedPatternToken = new PatternToken("Negated", false, false, false);
negatedPatternToken.setNegation(true);
List<PatternToken> patternTokens = Arrays.asList(negatedPatternToken, new PatternToken("How", false, false, false));
Searcher errorSearcher = new Searcher(directory);
PatternRule rule1 = new PatternRule("RULE1", new English(), patternTokens, "desc", "msg", "shortMsg");
SearcherResult searcherResult = errorSearcher.findRuleMatchesOnIndex(rule1, new English());
assertEquals(1, searcherResult.getCheckedSentences());
assertEquals(1, searcherResult.getMatchingSentences().size());
List<RuleMatch> ruleMatches = searcherResult.getMatchingSentences().get(0).getRuleMatches();
assertEquals(1, ruleMatches.size());
Rule rule = ruleMatches.get(0).getRule();
assertEquals("RULE1", rule.getId());
}
use of org.languagetool.language.English in project languagetool by languagetool-org.
the class IndexerSearcherTest method testWithRegexRule.
public void testWithRegexRule() throws Exception {
createIndex("How to move back and fourth from linux to xmb?");
List<PatternToken> patternTokens = Arrays.asList(new PatternToken("move", false, false, false), new PatternToken("forth|back", false, true, false));
PatternRule rule1 = new PatternRule("RULE1", new English(), patternTokens, "desc", "msg", "shortMsg");
Searcher errorSearcher = new Searcher(directory);
SearcherResult searcherResult = errorSearcher.findRuleMatchesOnIndex(rule1, new English());
assertEquals(1, searcherResult.getCheckedSentences());
assertEquals(1, searcherResult.getMatchingSentences().size());
List<RuleMatch> ruleMatches = searcherResult.getMatchingSentences().get(0).getRuleMatches();
assertEquals(1, ruleMatches.size());
Rule rule = ruleMatches.get(0).getRule();
assertEquals("RULE1", rule.getId());
}
use of org.languagetool.language.English in project languagetool by languagetool-org.
the class IndexerSearcherTest method testApostropheElement.
public void testApostropheElement() throws Exception {
createIndex("Daily Bleed's Anarchist Encyclopedia");
List<PatternToken> elements1 = Arrays.asList(new PatternToken("Bleed", false, false, false), new PatternToken("'", false, false, false), new PatternToken("s", false, false, false));
PatternRule rule1 = new PatternRule("RULE1", new English(), elements1, "desc", "msg", "shortMsg");
List<PatternToken> elements2 = Arrays.asList(new PatternToken("Bleed", false, false, false), new PatternToken("'", false, false, false), new PatternToken("x", false, false, false));
PatternRule rule2 = new PatternRule("RULE", new English(), elements2, "desc", "msg", "shortMsg");
SearcherResult searcherResult1 = errorSearcher.findRuleMatchesOnIndex(rule1, new English());
assertEquals(1, searcherResult1.getMatchingSentences().size());
List<RuleMatch> ruleMatches = searcherResult1.getMatchingSentences().get(0).getRuleMatches();
assertEquals(1, ruleMatches.size());
Rule rule = ruleMatches.get(0).getRule();
assertEquals("RULE1", rule.getId());
SearcherResult searcherResult2 = errorSearcher.findRuleMatchesOnIndex(rule2, new English());
assertEquals(0, searcherResult2.getMatchingSentences().size());
}
Aggregations