HeadlinesBriefing favicon HeadlinesBriefing.com

Red Blob Games: English a vs an Rule Analysis

Hacker News •
×

In English, the indefinite article "a" precedes words like "a raccoon," while "an" precedes words like "an apple." When procedurally generating text, a function a_or_an("apple") must determine the correct article. The rule depends not on the first written letter but on the first spoken sound. For example, "unicorn" starts with a vowel letter (u) but a consonant sound (Y), requiring "a unicorn." Conversely, "hour" starts with a consonant letter (h) but a vowel sound (OW), requiring "an hour."

The author analyzed 32,455 words to visualize how often exceptions occur and whether they can be grouped. Only 129 words needed exceptions. The post includes visualizations showing whether the first two letters suffice to determine the article. The author notes the code was written without LLMs for a one-off analysis, focusing on correctness over maintainability, and mentions parsing cmudict and re-learning d3.js.