diff --git a/languagetool-language-modules/nl/src/main/java/org/languagetool/language/Dutch.java b/languagetool-language-modules/nl/src/main/java/org/languagetool/language/Dutch.java index 9bd9938ba9b7..39e9164cf8d8 100644 --- a/languagetool-language-modules/nl/src/main/java/org/languagetool/language/Dutch.java +++ b/languagetool-language-modules/nl/src/main/java/org/languagetool/language/Dutch.java @@ -65,7 +65,7 @@ public String[] getCountries() { @NotNull @Override public Tagger createDefaultTagger() { - return new DutchTagger(); + return DutchTagger.INSTANCE; } @Nullable diff --git a/languagetool-language-modules/nl/src/main/java/org/languagetool/rules/nl/CompoundAcceptor.java b/languagetool-language-modules/nl/src/main/java/org/languagetool/rules/nl/CompoundAcceptor.java index dac22efa8f9a..17d7d6809906 100644 --- a/languagetool-language-modules/nl/src/main/java/org/languagetool/rules/nl/CompoundAcceptor.java +++ b/languagetool-language-modules/nl/src/main/java/org/languagetool/rules/nl/CompoundAcceptor.java @@ -558,14 +558,13 @@ public class CompoundAcceptor { } } - private final DutchTagger DutchTagger; + private DutchTagger dutchTagger = DutchTagger.INSTANCE; CompoundAcceptor() { - this.DutchTagger = new DutchTagger(); } public CompoundAcceptor(DutchTagger DutchTagger) { - this.DutchTagger = DutchTagger; + this.dutchTagger = DutchTagger; } boolean acceptCompound(String word) { @@ -622,14 +621,14 @@ boolean acceptCompound(String part1, String part2) { } private boolean isNoun(String word) throws IOException { - return DutchTagger.getPostags(word).stream().anyMatch(k -> { + return dutchTagger.getPostags(word).stream().anyMatch(k -> { assert k.getPOSTag() != null; return k.getPOSTag().startsWith("ZNW") && !part2Exceptions.contains(word); }); } private boolean isExistingWord(String word) throws IOException { - return DutchTagger.getPostags(word).stream().anyMatch(k -> k.getPOSTag() != null); + return dutchTagger.getPostags(word).stream().anyMatch(k -> k.getPOSTag() != null); } private boolean hasCollidingVowels(String part1, String part2) { diff --git a/languagetool-language-modules/nl/src/main/java/org/languagetool/tagging/nl/DutchTagger.java b/languagetool-language-modules/nl/src/main/java/org/languagetool/tagging/nl/DutchTagger.java index 93256ad5641c..41f7d6f8afb1 100644 --- a/languagetool-language-modules/nl/src/main/java/org/languagetool/tagging/nl/DutchTagger.java +++ b/languagetool-language-modules/nl/src/main/java/org/languagetool/tagging/nl/DutchTagger.java @@ -37,6 +37,7 @@ */ public class DutchTagger extends BaseTagger { + public static final DutchTagger INSTANCE = new DutchTagger(); private static final Pattern PATTERN1_A = compile("([^aeiouáéíóú])(á)([^aeiouáéíóú])"); private static final Pattern PATTERN1_E = compile("([^aeiouáéíóú])(é)([^aeiouáéíóú])"); private static final Pattern PATTERN1_I = compile("([^aeiouáéíóú])(í)([^aeiouáéíóú])");