English: A vs. An
English Grammar: Choosing Between "A" and "An"
Originally published on the Red Blob Games Blog on September 16, 2026.
In the English language, we use an indefinite article (either "a" or "an") before certain words. When I am working on procedural text generation, I need a programmatic way to decide which one to use. Specifically, I want a helper function:
a_or_an("apple") returns "an"
The Core Logic
Many people assume the choice depends on the first letter, but that is incorrect. The actual rule is based on the phonetic sound at the start of the spoken word, not the written character.
Comparison of Exceptions
| Word | Starting Letter | Phonetic Sound (IPA) | CMUdict | Correct Article |
|---|---|---|---|---|
| Unicorn | u (vowel) | /j/ (consonant) | Y | a |
| Hour | h (consonant) | /aʊ/ (vowel) | AW | an |
To visualize this decision process:
Data Analysis
I spent a day investigating how frequently these phonetic exceptions occur and whether they follow any group patterns. My workflow included:
- Analyze a dataset of words.
- Create data visualizations.
- Document the findings.
I discovered that the number of exceptions is surprisingly low. Out of a total of words, only required an exception to the basic vowel-letter rule. The ratio of exceptions is:
Implementation Reflection
# Conceptual implementation
def a_or_an(word):
if starts_with_vowel_sound(word):
return "an"
return "a"
Note from the author: I didn't utilize LLMs to write the code for this project. Looking back, I realize I should have. Using an LLM to handle the
cmudictparsing and thed3.jsvisualizations would have freed up my time to develop a more sophisticated trie analysis algorithm.
Get in touch:
- Email:
redblobgames@gmail.com - Discussion: [Load comments from Disqus] or [View the discussion thread]