Skip to content

Commit

Permalink
[de-CH] adjust filterRuleMatches
Browse files Browse the repository at this point in the history
  • Loading branch information
jaumeortola committed Jun 28, 2024
1 parent 4ee8b43 commit 50ff55c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,8 @@ public List<Rule> getRelevantRemoteRules(ResourceBundle messageBundle, List<Remo

@Override
public List<RuleMatch> filterRuleMatches(List<RuleMatch> ruleMatches, AnnotatedText text, Set<String> enabledRules) {
//First, use the filter in German.java
ruleMatches = super.filterRuleMatches(ruleMatches, text, enabledRules);
List<RuleMatch> newRuleMatches = new ArrayList<>();
for (RuleMatch rm : ruleMatches) {
//TODO: replace this by supporting remote-rule-filter for language variants
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -195,10 +195,16 @@ public void testRuleWithAustrianGerman() throws Exception {
@Test
public void testRuleWithSwissGerman() throws Exception {
HunspellRule rule = new HunspellRule(TestTools.getMessages("de"), Languages.getLanguageForShortCode("de-CH"), null);
JLanguageTool lt = new JLanguageTool(Languages.getLanguageForShortCode("de-DE"));
JLanguageTool lt = new JLanguageTool(Languages.getLanguageForShortCode("de-CH"));
commonGermanAsserts(rule, lt);
assertEquals(1, rule.match(lt.getAnalyzedSentence("Der äußere Übeltäter.")).length); // ß not allowed in Swiss
assertEquals(0, rule.match(lt.getAnalyzedSentence("Der äussere Übeltäter.")).length); // ss is used instead of ß

// suggestions with ss, not ß, in Swiss German
List<RuleMatch> matches = lt.check("Mit freundlichen Gruessen");
assertEquals("Grüssen", matches.get(0).getSuggestedReplacements().get(0));
matches = lt.check("schließen");
assertEquals("schliessen", matches.get(0).getSuggestedReplacements().get(0));
}

private void commonGermanAsserts(HunspellRule rule, JLanguageTool lt) throws IOException {
Expand Down

0 comments on commit 50ff55c

Please sign in to comment.