Skip to content

Commit

Permalink
Fix some a/an bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
pwdyson committed Jun 10, 2012
1 parent b2f97a5 commit b46a8f8
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 8 deletions.
5 changes: 5 additions & 0 deletions CHANGES.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@

ver 0.2.3

* fix a/an for dishonor, Honolulu, mpeg, onetime, Ugandan, Ukranian,
Unabomber, unanimous, US

ver 0.2.2

* change numwords to number_to_words in strings
Expand Down
12 changes: 10 additions & 2 deletions inflect.py
Original file line number Diff line number Diff line change
Expand Up @@ -1102,9 +1102,14 @@ def get_si_pron(thecase, word, gender):

# EXCEPTIONS TO EXCEPTIONS

A_explicit_a = enclose('|'.join((
"unabomber", "unanimous", "US",
)))

A_explicit_an = enclose('|'.join((
"euler",
"hour(?!i)", "heir", "honest", "hono",
"hour(?!i)", "heir", "honest", "hono[ur]",
"mpeg",
)))

A_ordinal_an = enclose('|'.join((
Expand Down Expand Up @@ -2739,8 +2744,11 @@ def _indef_article(self, word, count):
for a in (
(r"^e[uw]", "a"),
(r"^onc?e\b", "a"),
(r"^onetime\b", "a"),
(r"^uni([^nmd]|mo)", "a"),
(r"^u[bcfhjkqrst][aeiou]", "a"),
(r"^u[bcfghjkqrst][aeiou]", "a"),
(r"^ukr", "a"),
(r"^(%s)" % A_explicit_a, "a"),
):
mo = search(a[0], word, IGNORECASE)
if mo:
Expand Down
20 changes: 14 additions & 6 deletions tests/test_an.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,18 @@ def test_an():

p = inflect.engine()

eq_(p.an('cat'), 'a cat' ,msg='cat')
eq_(p.an('ant'), 'an ant' ,msg='ant')
eq_(p.an('a'), 'an a' ,msg='a')
eq_(p.an('b'), 'a b' ,msg='b')
eq_(p.an('honest cat'), 'an honest cat' ,msg='honest')
eq_(p.an('dishonest cat'), 'a dishonest cat' ,msg='dishonest')
eq_(p.an('cat'), 'a cat' ,msg='a cat')
eq_(p.an('ant'), 'an ant' ,msg='an ant')
eq_(p.an('a'), 'an a' ,msg='an a')
eq_(p.an('b'), 'a b' ,msg='a b')
eq_(p.an('honest cat'), 'an honest cat' ,msg='an honest')
eq_(p.an('dishonest cat'), 'a dishonest cat' ,msg='a dishonest')
eq_(p.an('Honolulu sunset'), 'a Honolulu sunset' ,msg='a Honolulu')
eq_(p.an('mpeg'), 'an mpeg' ,msg='an mpeg')
eq_(p.an('onetime holiday'), 'a onetime holiday' ,msg='a onetime')
eq_(p.an('Ugandan person'), 'a Ugandan person' ,msg='a Ugandan')
eq_(p.an('Ukranian person'), 'a Ukranian person' ,msg='a Ukranian')
eq_(p.an('Unabomber'), 'a Unabomber' ,msg='a Unabomber')
eq_(p.an('unanimous decision'), 'a unanimous decision' ,msg='a unanimous')
eq_(p.an('US farmer'), 'a US farmer' ,msg='a US')

0 comments on commit b46a8f8

Please sign in to comment.