Hacker News — AI on Front Page · · 2 min read

English: A vs. An

Mirrored from Hacker News — AI on Front Page for archival readability. Support the source by reading on the original site.

329 pts · 444 comments on Hacker News

Blog post: 16 Sep 2026

{Note: this is a short blog post introducing the actual project page}

In English, there is an “indefinite” article a that can go before a word. For example, a raccoon. But for some words, we use an. For example, an apple.

When procedurally generating text, I want a function a_or_an("apple") that tells me which article to use. That seems like it’d be easy. We can check the first letter to see if it’s a vowel. But that would mean we output an unicorn, not a unicorn.

Tree style visualization of the first two letters of a word
Visualization showing whether the first two letters of a word are enough to determine whether it should have “a” or “an”. It is not.

The actual rule is not whether the written word starts with a vowel letter, but whether the spoken word starts with a vowel sound. The word <unicorn> starts with a vowel letter (<u>) but a consonant sound (cmudict Y, ipa /j/), so it gets a. The word <hour> starts with a consonant letter (<h>) but a vowel sound (cmudict AW, ipa /aʊ/), so it gets an.

I was curious how often these exceptions occurred, and whether they can be grouped together, so I spent a day looking at the data and building some visualizations and wrote up the results. I was surprised that only 129 of the 32,455 words in my list needed exceptions.

[LLM note: I did not use LLMs to write any of this code, but in hindsight, I should have. This is one-off code to answer a question. It doesn’t need to be clean or maintainable. It only needs to be correct. If I had used the LLM to parse cmudict and make the d3.js visualizations, I could’ve spent more of my time coding a better trie analysis algorithm.]

Discussion (0)

Sign in to join the discussion. Free account, 30 seconds — email code or GitHub.

Sign in →

No comments yet. Sign in and be the first to say something.

More from Hacker News — AI on Front Page