From f068ca9ff79e687c44ca0579018041be6e934366 Mon Sep 17 00:00:00 2001 From: jaumeortola Date: Wed, 29 May 2024 20:32:45 +0200 Subject: [PATCH] [de] add test for ignoring English words --- .../rules/spelling/hunspell/HunspellRule.java | 3 ++- .../src/test/java/org/languagetool/JLanguageToolTest.java | 8 ++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/languagetool-core/src/main/java/org/languagetool/rules/spelling/hunspell/HunspellRule.java b/languagetool-core/src/main/java/org/languagetool/rules/spelling/hunspell/HunspellRule.java index 2f0b37d41f76..7b14febb0476 100644 --- a/languagetool-core/src/main/java/org/languagetool/rules/spelling/hunspell/HunspellRule.java +++ b/languagetool-core/src/main/java/org/languagetool/rules/spelling/hunspell/HunspellRule.java @@ -457,7 +457,8 @@ protected String getSentenceTextWithoutUrlsAndImmunizedTokens(AnalyzedSentence s AnalyzedTokenReadings[] sentenceTokens = getSentenceWithImmunization(sentence).getTokens(); for (int i = 1; i < sentenceTokens.length; i++) { String token = sentenceTokens[i].getToken(); - if (sentenceTokens[i].isImmunized() || sentenceTokens[i].isIgnoredBySpeller() || isUrl(token) || isEMail(token) || isQuotedCompound(sentence, i, token)) { + if (sentenceTokens[i].isImmunized() || sentenceTokens[i].isIgnoredBySpeller() || isUrl(token) || isEMail(token) + || isQuotedCompound(sentence, i, token) || sentenceTokens[i].hasPosTag("_english_ignore_")) { if (isQuotedCompound(sentence, i, token)) { sb.append(' ').append(token.substring(1)); } diff --git a/languagetool-standalone/src/test/java/org/languagetool/JLanguageToolTest.java b/languagetool-standalone/src/test/java/org/languagetool/JLanguageToolTest.java index 2ab1ff38ecad..2f08c5563a90 100644 --- a/languagetool-standalone/src/test/java/org/languagetool/JLanguageToolTest.java +++ b/languagetool-standalone/src/test/java/org/languagetool/JLanguageToolTest.java @@ -603,4 +603,12 @@ public void testIgnoreEnglishWordsInPortuguese() throws IOException { } } + @Test + public void testIgnoringEnglishWordsInGerman() throws IOException { + Language lang = new GermanyGerman(); + JLanguageTool lt = new JLanguageTool(lang); + List matches = lt.check("This is an English sentence."); + assertEquals(0, matches.size()); + } + }