Skip to content

Commit

Permalink
Merge pull request #10620 from languagetool-org/match-merging-adding-…
Browse files Browse the repository at this point in the history
…test

[fr] adding a java test for match-merging
  • Loading branch information
GillouLT authored May 29, 2024
2 parents 15f1841 + f602e3f commit 5187f29
Showing 1 changed file with 24 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -101,4 +101,28 @@ public void testQuotes() throws IOException {
assertEquals(true, processedMatches.get(0).getRule().getTags().contains(Tag.picky));
assertEquals("AI_FR_GGEC_QUOTES", processedMatches.get(0).getSpecificRuleId());
}
@Test
public void testMergingOfGrammarCorrections() throws IOException {
Language lang = new French();
JLanguageTool lt = new JLanguageTool(lang);
AnalyzedSentence analyzedSentence = lt.getAnalyzedSentence("Ce sont de spectateur");

// Mocking two adjacent grammar issues
RuleMatch ruleMatch1 = new RuleMatch(new FakeRule("AI_FR_GGEC_DES"), analyzedSentence, 9, 11, "Erreur de nombre");
ruleMatch1.setSuggestedReplacement("des");
RuleMatch ruleMatch2 = new RuleMatch(new FakeRule("AI_FR_GGEC_SPECTATEURS"), analyzedSentence, 12, 21, "Erreur de forme plurielle");
ruleMatch2.setSuggestedReplacement("spectateurs");

List<RuleMatch> ruleMatches = new ArrayList<>();
ruleMatches.add(ruleMatch1);
ruleMatches.add(ruleMatch2);

// Process the rule matches
List<RuleMatch> processedMatches = lang.mergeSuggestions(ruleMatches, null, null);

// Asserts
assertEquals("des spectateurs", processedMatches.get(0).getSuggestedReplacements().get(0));
assertEquals("AI_FR_MERGED_MATCH", processedMatches.get(0).getSpecificRuleId());
}

}

0 comments on commit 5187f29

Please sign in to comment.