This piece addresses the practical problem of programmatically choosing the English indefinite article "a" versus "an" for generated text. It explains that the correct choice depends on the initial sound of the spoken word, not its written first letter, and gives familiar counterexamples: unicorn begins with the vowel letter "u" but a consonant /j/ sound so it takes "a", while hour begins with "h" but an initial vowel sound so it takes "an". A simple-first-letter heuristic fails in these cases, so the writeup explores how much extra information is needed to make the right decision and how to automate it.
To answer that, the author parsed the CMU Pronouncing Dictionary and analyzed 32,455 words, building tries and visualizations (using d3.js) to see whether one or two written letters are enough to determine article choice. The finding: only 129 words required explicit exceptions. The writeup describes the trie simplification approach, shows visualizations of which letter pairs are ambiguous, and notes implementation tradeoffs - one-off code focused on correctness rather than polish and a retrospective comment that using LLMs might have saved time. The practical takeaway is that phonetic data plus a small exception list suffices for robust a/an selection in most cases.
Summary generated by AI from the linked article. hn.today is not affiliated with Hacker News or Y Combinator.