diff --git a/languagetool-core/src/main/java/org/languagetool/rules/AbstractCheckCaseRule.java b/languagetool-core/src/main/java/org/languagetool/rules/AbstractCheckCaseRule.java index 1446472b18b4..576c78e8e36c 100644 --- a/languagetool-core/src/main/java/org/languagetool/rules/AbstractCheckCaseRule.java +++ b/languagetool-core/src/main/java/org/languagetool/rules/AbstractCheckCaseRule.java @@ -34,7 +34,7 @@ */ public abstract class AbstractCheckCaseRule extends AbstractSimpleReplaceRule2 { private final Language language; - public boolean ignoreShortUppercaseWords = true; + private boolean ignoreShortUppercaseWords = true; public AbstractCheckCaseRule(ResourceBundle messages, Language language) { super(messages, language); @@ -96,17 +96,16 @@ public RuleMatch[] match(AnalyzedSentence sentence) { // The phrase is correct. Don't look into shorter phrases inside this phrase. break; } - if (ignoreShortUppercaseWords) { - if (originalPhrase.equals(originalPhrase.toUpperCase())) { - // Toggle is ON and it's a capitalized sentence, continue + if (originalPhrase.equals(originalPhrase.toUpperCase())) { + if (ignoreShortUppercaseWords) { continue; + } else { + if( originalPhrase.length() < 5 ){ + // correct uppercase word less than 5 chars if toggle is on + } else{ + continue; + } } - } else if (originalPhrase.length() < 5) { - //System.out.println("toggle off, <5 chars"); - // Toggle OFF and <5 chars - } else { - //toggle OFF but >5 chars - continue; } if (correctPhrase != null && !correctPhrase.equals(originalPhrase)) { RuleMatch ruleMatch; @@ -141,7 +140,7 @@ public RuleMatch[] match(AnalyzedSentence sentence) { return toRuleMatchArray(ruleMatches); } - public boolean ignoreShortUppercaseWords() { + public boolean isIgnoreShortUppercaseWords() { return ignoreShortUppercaseWords; } diff --git a/languagetool-language-modules/nl/src/main/java/org/languagetool/rules/nl/CheckCaseRule.java b/languagetool-language-modules/nl/src/main/java/org/languagetool/rules/nl/CheckCaseRule.java index baeb58772d35..40c9e963394e 100644 --- a/languagetool-language-modules/nl/src/main/java/org/languagetool/rules/nl/CheckCaseRule.java +++ b/languagetool-language-modules/nl/src/main/java/org/languagetool/rules/nl/CheckCaseRule.java @@ -34,6 +34,8 @@ public class CheckCaseRule extends AbstractCheckCaseRule { public CheckCaseRule(ResourceBundle messages, Language language) { super(messages, language); useSubRuleSpecificIds(); + // do not ignore abbreviations like "apk, dvd" etc + setIgnoreShortUppercaseWords(false); } @Override @@ -66,10 +68,4 @@ public Locale getLocale() { return NL_LOCALE; } - @Override - public boolean ignoreShortUppercaseWords() { - //does not override boolean - return false; - } - } diff --git a/languagetool-language-modules/nl/src/test/java/org/languagetool/rules/nl/CheckCaseRuleTest.java b/languagetool-language-modules/nl/src/test/java/org/languagetool/rules/nl/CheckCaseRuleTest.java index 4626f150aa24..b41dd18fd0f4 100644 --- a/languagetool-language-modules/nl/src/test/java/org/languagetool/rules/nl/CheckCaseRuleTest.java +++ b/languagetool-language-modules/nl/src/test/java/org/languagetool/rules/nl/CheckCaseRuleTest.java @@ -46,6 +46,9 @@ public void testRule() throws IOException { assertEquals(0, rule.match(lt.getAnalyzedSentence("een bisschop")).length); assertEquals(0, rule.match(lt.getAnalyzedSentence("Een bisschop")).length); + // ignored sentence: + assertEquals(0, rule.match(lt.getAnalyzedSentence("EEN BISSCHOP")).length); + // incorrect sentences: RuleMatch[] matches = rule.match(lt.getAnalyzedSentence("Een Bisschop")); assertEquals(1, matches.length); @@ -55,9 +58,14 @@ public void testRule() throws IOException { assertEquals(1, matches.length); assertEquals("een bisschop", matches[0].getSuggestedReplacements().get(0)); - matches = rule.match(lt.getAnalyzedSentence("Dit is een video op dVD.")); + // less than 5chars: + matches = rule.match(lt.getAnalyzedSentence("Mag ik die DVD lenen?")); assertEquals(1, matches.length); assertEquals("dvd", matches[0].getSuggestedReplacements().get(0)); + matches = rule.match(lt.getAnalyzedSentence("Heb je de nieuwe IPAD al gezien?")); + assertEquals(1, matches.length); + assertEquals("iPad", matches[0].getSuggestedReplacements().get(0)); + } }