jaraco / inflect

Correctly generate plurals, ordinals, indefinite articles; convert numbers to words
https://pypi.org/project/inflect
MIT License
957 stars 107 forks source link

wrong `inflect.a`: "an BLT" #180

Closed bancron closed 1 year ago

bancron commented 1 year ago

There is a bug with certain strings of capital letters appearing in words that results in bad results from a(). For example it should be "a Spicy BLT Sauce", not "an Spicy BLT Sauce".

This appears to have to do with

A_abbrev = re.compile(
    r"""
(?! FJO | [HLMNS]Y.  | RY[EO] | SQU
  | ( F[LR]? | [HL] | MN? | N | RH? | S[CHKLMNPTVW]? | X(YL)?) [AEIOU])
[FHLMNRSX][A-Z]
""",
    re.VERBOSE,
)

matching the "LT" part. It seems to me that the regex should be anchored (^...) or in some fashion not match random "LT" in the middle of words.

I would really appreciate it if you could fix this bug. Thank you!

bancron commented 1 year ago

Duplicate of https://github.com/jaraco/inflect/issues/136.