diff --git a/languagetool-language-modules/en/src/main/java/org/languagetool/rules/en/AvsAnRule.java b/languagetool-language-modules/en/src/main/java/org/languagetool/rules/en/AvsAnRule.java index 37d5416d46c1..644e7d2ddada 100644 --- a/languagetool-language-modules/en/src/main/java/org/languagetool/rules/en/AvsAnRule.java +++ b/languagetool-language-modules/en/src/main/java/org/languagetool/rules/en/AvsAnRule.java @@ -95,6 +95,18 @@ public RuleMatch[] match(AnalyzedSentence sentence) { } if (equalsA || equalsAn) { Determiner determiner = getCorrectDeterminerFor(token); + // if token is "EUR", look at the following word to establish the correct determiner, e.g. "an EUR 80 million debt" + if (token.getToken().equals("EUR") && i < tokens.length - 1) { + if (tokens[i + 1].hasPosTag("PCT")) { + determiner = Determiner.A; + } + else { + determiner = getCorrectDeterminerFor(tokens[i + 1]); + } + // if token is "EUR" and no other word follows it (sentence-final), use "a" + } else if (token.getToken().equals("EUR") && i == tokens.length - 1) { + determiner = Determiner.A; + } String msg = null; if (equalsA && determiner == Determiner.AN) { String replacement = StringTools.startsWithUppercase(prevTokenStr) ? "An" : "an"; diff --git a/languagetool-language-modules/en/src/main/resources/org/languagetool/rules/en/det_a.txt b/languagetool-language-modules/en/src/main/resources/org/languagetool/rules/en/det_a.txt index 09ae28c4db5b..8851af6672ff 100644 --- a/languagetool-language-modules/en/src/main/resources/org/languagetool/rules/en/det_a.txt +++ b/languagetool-language-modules/en/src/main/resources/org/languagetool/rules/en/det_a.txt @@ -3,6 +3,7 @@ # line starts with '*'). # Add words that allow both 'a' and 'an' to det_a.txt and det_an.txt. # Also see: http://www.learnenglish.org.uk/grammar/archive/articles_pronunciation.html +100 Eucharistic eukaryote eukaryotic diff --git a/languagetool-language-modules/en/src/test/java/org/languagetool/rules/en/AvsAnRuleTest.java b/languagetool-language-modules/en/src/test/java/org/languagetool/rules/en/AvsAnRuleTest.java index 411e1349bebc..5164f26e7e7c 100644 --- a/languagetool-language-modules/en/src/test/java/org/languagetool/rules/en/AvsAnRuleTest.java +++ b/languagetool-language-modules/en/src/test/java/org/languagetool/rules/en/AvsAnRuleTest.java @@ -44,6 +44,10 @@ public void setUp() throws IOException { public void testRule() throws IOException { // correct sentences: + assertCorrect("The company has also entered into a EUR 100 million ($88 million) debt"); + assertCorrect("The company has also entered into an EUR 80 million debt"); + assertCorrect("It costs a EUR"); + assertCorrect("It costs a EUR."); assertCorrect("Import an Xcode project."); assertCorrect("This is a oncer."); assertCorrect("She was a Oaxacan chef."); @@ -73,6 +77,10 @@ public void testRule() throws IOException { assertCorrect("He also wrote the comic strips Abbie an' Slats."); // errors: + assertIncorrect("The company has also entered into an EUR 100 million ($88 million) debt"); + assertIncorrect("The company has also entered into a EUR 80 million debt"); + assertIncorrect("It costs an EUR"); + assertIncorrect("It costs an EUR."); assertIncorrect("It was a hour ago."); assertIncorrect("It was an sentence that's long."); assertIncorrect("It was a uninteresting talk.");