use of org.languagetool.rules.patterns.PatternToken in project languagetool by languagetool-org.
the class RuleWithMaxFilterTest method testNoFilteringIfDifferentRulegroups.
@Test
public void testNoFilteringIfDifferentRulegroups() {
List<PatternToken> fakePatternTokens = new ArrayList<>();
Rule rule1 = new PatternRule("id1", language, fakePatternTokens, "desc1", "msg1", "shortMsg1");
Rule rule2 = new PatternRule("id2", language, fakePatternTokens, "desc2", "msg2", "shortMsg2");
RuleMatch match1 = new RuleMatch(rule1, 10, 20, "Match1");
RuleMatch match2 = new RuleMatch(rule2, 15, 25, "Match2");
RuleWithMaxFilter filter = new RuleWithMaxFilter();
List<RuleMatch> filteredMatches1 = filter.filter(Arrays.asList(match1, match2));
assertEquals(2, filteredMatches1.size());
RuleMatch match3 = new RuleMatch(rule2, 11, 19, "Match3");
List<RuleMatch> filteredMatches2 = filter.filter(Arrays.asList(match1, match3));
assertEquals(2, filteredMatches2.size());
}
use of org.languagetool.rules.patterns.PatternToken in project languagetool by languagetool-org.
the class RuleWithMaxFilterTest method testFilter.
@Test
public void testFilter() {
List<PatternToken> fakePatternTokens = new ArrayList<>();
PatternRule rule1 = new PatternRule("id1", language, fakePatternTokens, "desc1", "msg1", "shortMsg1");
PatternRule rule2 = new PatternRule("id1", language, fakePatternTokens, "desc2", "msg2", "shortMsg2");
RuleMatch match1 = new RuleMatch(rule1, 10, 20, "Match1");
RuleMatch match2 = new RuleMatch(rule2, 15, 25, "Match2");
RuleWithMaxFilter filter = new RuleWithMaxFilter();
List<RuleMatch> filteredMatches1 = filter.filter(Arrays.asList(match1, match2));
assertEquals(2, filteredMatches1.size());
RuleMatch match3 = new RuleMatch(rule2, 11, 19, "Match3");
List<RuleMatch> filteredMatches2 = filter.filter(Arrays.asList(match1, match3));
assertEquals(1, filteredMatches2.size());
}
use of org.languagetool.rules.patterns.PatternToken in project languagetool by languagetool-org.
the class SameRuleGroupFilterTest method testNoFilteringIfNotOverlapping.
@Test
public void testNoFilteringIfNotOverlapping() {
List<PatternToken> fakePatternTokens = new ArrayList<>();
PatternRule rule1 = new PatternRule("id1", language, fakePatternTokens, "desc1", "msg1", "shortMsg1");
PatternRule rule2 = new PatternRule("id1", language, fakePatternTokens, "desc2", "msg2", "shortMsg2");
RuleMatch match1 = new RuleMatch(rule1, 10, 20, "Match1");
RuleMatch match2 = new RuleMatch(rule2, 21, 25, "Match2");
SameRuleGroupFilter filter = new SameRuleGroupFilter();
List<RuleMatch> filteredMatches = filter.filter(Arrays.asList(match1, match2));
assertEquals(2, filteredMatches.size());
}
use of org.languagetool.rules.patterns.PatternToken in project languagetool by languagetool-org.
the class SameRuleGroupFilterTest method testNoFilteringIfDifferentRulegroups.
@Test
public void testNoFilteringIfDifferentRulegroups() {
List<PatternToken> fakePatternTokens = new ArrayList<>();
Rule rule1 = new PatternRule("id1", language, fakePatternTokens, "desc1", "msg1", "shortMsg1");
Rule rule2 = new PatternRule("id2", language, fakePatternTokens, "desc2", "msg2", "shortMsg2");
RuleMatch match1 = new RuleMatch(rule1, 10, 20, "Match1");
RuleMatch match2 = new RuleMatch(rule2, 15, 25, "Match2");
SameRuleGroupFilter filter = new SameRuleGroupFilter();
List<RuleMatch> filteredMatches = filter.filter(Arrays.asList(match1, match2));
assertEquals(2, filteredMatches.size());
}
use of org.languagetool.rules.patterns.PatternToken in project languagetool by languagetool-org.
the class SameRuleGroupFilterTest method testFilter.
@Test
public void testFilter() {
List<PatternToken> fakePatternTokens = new ArrayList<>();
PatternRule rule1 = new PatternRule("id1", language, fakePatternTokens, "desc1", "msg1", "shortMsg1");
PatternRule rule2 = new PatternRule("id1", language, fakePatternTokens, "desc2", "msg2", "shortMsg2");
RuleMatch match1 = new RuleMatch(rule1, 10, 20, "Match1");
RuleMatch match2 = new RuleMatch(rule2, 15, 25, "Match2");
SameRuleGroupFilter filter = new SameRuleGroupFilter();
List<RuleMatch> filteredMatches = filter.filter(Arrays.asList(match1, match2));
assertEquals(1, filteredMatches.size());
assertEquals("Match1", filteredMatches.get(0).getMessage());
}
Aggregations