Trying to build a function a_or_an(word) proves hilariously challenging for English, surprising no one.
The author catches one dialectal land mine: herb begins with a vowel sound in American English and an /h/ sound in British English. But I see at least two more ways English can ruin your afternoon:
- The name of the letter H itself varies by dialect. Most Americans say aitch, beginning with a vowel sound; plenty of British speakers say haitch, beginning with /h/. Thus even the letter whose entire job is to represent H cannot agree on whether it starts with H.
- Then there is the ludicrous an historic problem. Modern English normally pronounces the initial /h/ in historic, so by the ordinary rule it should be a historic. But an older convention, particularly with words whose first syllable was unstressed and whose /h/ was weak or dropped, gave us an historic, an hotel, and their relatives. The convention survives just enough to ensure that no implementation of
a_or_an()can ever know peace.
He also notes the rebracketing problem (a napron → an apron, mine uncle → my nuncle), which is a pronunciation horse of an entirely different and apocalyptic color.