Skip to content

Commit

Permalink
[fr] AI_FR_GGEC_TRES_tonetags_test
Browse files Browse the repository at this point in the history
  • Loading branch information
GillouLT committed Apr 9, 2024
1 parent 95dbb69 commit 094835e
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -468,6 +468,17 @@ public List<RuleMatch> adaptSuggestions(List<RuleMatch> ruleMatches, Set<String>
currentMatch.getRule().setLocQualityIssueType(ITSIssueType.Typographical);
}

// UNNECESSARY_ADVERB_TRES
if (ruleId.startsWith("AI_FR_GGEC") && ruleId.contains("UNNECESSARY_ADVERB_TRÈS")) {
if (sentenceText.contains("très très")) {
currentMatch.setSpecificRuleId("AI_FR_GGEC_TRES");
currentMatch.getRule().setToneTags(Collections.singletonList(ToneTag.formal));
currentMatch.getRule().setGoalSpecific(true);
currentMatch.getRule().setLocQualityIssueType(ITSIssueType.Style);
}
}


// AI_FR_GGEC_MAIL_EMAIL_JOINED
if (sentenceText.contains("mail")) {
String message = "Dans un contexte formel, « e-mail » semble plus approprié.";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,4 +119,20 @@ 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

This comment has been minimized.

Copy link
@danielnaber

danielnaber Apr 9, 2024

Member

Looks like wrong indentation here?

This comment has been minimized.

Copy link
@GillouLT

GillouLT Apr 9, 2024

Author Collaborator

It did look wrong, just fixed, thank you!

public void teststyle() throws IOException {
Language lang = new French();
JLanguageTool lt = new JLanguageTool(lang);
AnalyzedSentence analyzedSentence = lt.getAnalyzedSentence("C'est très très bien.");
RuleMatch ruleMatch = new RuleMatch(new FakeRule("AI_FR_GGEC_UNNECESSARY_ADVERB_TRÈS"), analyzedSentence, 6, 10, "Possible error");
List<RuleMatch> ruleMatches = new ArrayList<>();
ruleMatches.add(ruleMatch);
Set<String> enabledRules = Collections.emptySet();
List<RuleMatch> processedMatches = lang.adaptSuggestions(ruleMatches, enabledRules);
assertEquals(true, processedMatches.get(0).getRule().getToneTags().contains(ToneTag.formal));
assertEquals(true, processedMatches.get(0).getRule().isGoalSpecific());
assertEquals("AI_FR_GGEC_TRES", processedMatches.get(0).getSpecificRuleId());
assertEquals(ITSIssueType.Style, processedMatches.get(0).getRule().getLocQualityIssueType());
}
}

0 comments on commit 094835e

Please sign in to comment.