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

[en] improve EN_A_VS_AN #10358

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,11 @@ public RuleMatch[] match(AnalyzedSentence sentence) {
}
if (equalsA || equalsAn) {
Determiner determiner = getCorrectDeterminerFor(token);
if (token.getToken().equals("EUR") && i < tokens.length - 1) {
Copy link
Member

Choose a reason for hiding this comment

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

Maybe add a comment with an example here, as this is quite clever but maybe a bit difficult to understand by just looking at the code?

determiner = getCorrectDeterminerFor(tokens[i + 1]);
} else if (token.getToken().equals("EUR") && i == tokens.length - 1) {
Copy link
Member

Choose a reason for hiding this comment

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

There's no test for this case, or am I missing something?

determiner = Determiner.A;
}
String msg = null;
if (equalsA && determiner == Determiner.AN) {
String replacement = StringTools.startsWithUppercase(prevTokenStr) ? "An" : "an";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ 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("Import an Xcode project.");
assertCorrect("This is a oncer.");
assertCorrect("She was a Oaxacan chef.");
Expand Down Expand Up @@ -73,6 +75,8 @@ 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 was a hour ago.");
assertIncorrect("It was an sentence that's long.");
assertIncorrect("It was a uninteresting talk.");
Expand Down