Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[de-CH] match filtering #10693

Merged
merged 2 commits into from
Jul 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -117493,7 +117493,7 @@ No t'ho explicaré, no cal que em burxis més-->
<url>https://aplicacions.llengua.gencat.cat/llc/AppJava/index.html?action=Principal&amp;method=detall&amp;input_cercar=%22preposici%F3+de%22+condicional&amp;numPagina=1&amp;database=FITXES_PUB&amp;idFont=12237&amp;idHit=12237&amp;tipusFont=Fitxes+de+l%27Optimot&amp;numeroResultat=5&amp;databases_avansada=&amp;categories_avansada=&amp;clickLink=detall&amp;titol=%27d%27haver-ho+sabut%27+o+%27si+ho+hagu%E9s+sabut%27%3F+%2F+Preposici%F3+%27de%27+seguida+d%27infinitiu+amb+valor+condicional+%2F+Infinitiu+condicional&amp;tematica=&amp;tipusCerca=cerca.fitxes</url>
<rule>
<pattern>
<token postag="SENT_START|_PUNCT.*" postag_regexp="yes"><exception regexp="yes">["')’”»]</exception></token>
<token postag="SENT_START|_PUNCT.*|PR0C.*" postag_regexp="yes"><exception regexp="yes">["')’”»]</exception></token>
<marker>
<token regexp="yes">de|d'<exception postag="_complement_directe|_obligacio" postag_regexp="yes"/></token>
</marker>
Expand Down Expand Up @@ -117522,7 +117522,7 @@ No t'ho explicaré, no cal que em burxis més-->
</rule>
<rule>
<pattern>
<token postag="SENT_START|_PUNCT.*" postag_regexp="yes"><exception regexp="yes">["')’”»]</exception></token>
<token postag="SENT_START|_PUNCT.*|PR0C.*" postag_regexp="yes"><exception regexp="yes">["')’”»]</exception></token>
<marker>
<token>de<exception postag="_complement_directe|_obligacio" postag_regexp="yes"/></token>
<token>no</token>
Expand All @@ -117536,7 +117536,7 @@ No t'ho explicaré, no cal que em burxis més-->
</rule>
<rule>
<pattern>
<token postag="SENT_START|_PUNCT.*" postag_regexp="yes"><exception regexp="yes">["')’”»]</exception></token>
<token postag="SENT_START|_PUNCT.*|PR0C.*" postag_regexp="yes"><exception regexp="yes">["')’”»]</exception></token>
<marker>
<token>de<exception postag="_complement_directe|_obligacio" postag_regexp="yes"/></token>
<token>no</token>
Expand All @@ -117550,7 +117550,7 @@ No t'ho explicaré, no cal que em burxis més-->
</rule>
<rule>
<pattern>
<token postag="SENT_START|_PUNCT.*" postag_regexp="yes"/>
<token postag="SENT_START|_PUNCT.*|PR0C.*" postag_regexp="yes"/>
<marker>
<token>de</token>
<token>ser</token>
Expand All @@ -117567,7 +117567,7 @@ No t'ho explicaré, no cal que em burxis més-->
</rule>
<rule>
<pattern>
<token postag="SENT_START|_PUNCT.*" postag_regexp="yes"/>
<token postag="SENT_START|_PUNCT.*|PR0C.*" postag_regexp="yes"/>
<marker>
<token>de</token>
<token>no</token>
Expand Down
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));
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

}

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