function indefinite_article ($word, $explicit_a, $explicit_an
{
// adapted from http://search.cpan.org/~dconway/Lingua-EN-Inflect/
# HANDLE SPECIAL CASES
if (preg_match'/^'implode'|'$explicit_a).'/i', $word)) return "a $word"
if (preg_match'/^'implode'|'$explicit_an).'/i', $word)) return "an $word"
# HANDLE ABBREVIATIONS
if (preg_match'/^((?!FJO|[HLMNS]Y.|RY[EO]|SQU|(F[LR]?|[HL]|MN?|N|RH?|S[CHKLMNPTVW]?|X(YL)?)[AEIOU])[FHLMNRSX][A-Z])/', $word)) return "an $word"
if (preg_match'/^[aefhilmnorsx]$/i', $word)) return "an $word"
if (preg_match'/^[aefhilmnorsx][.-]/i', $word)) return "an $word"
if (preg_match'/^[bcdgjkpqtuvwyz]$/i', $word)) return "a $word"
if (preg_match'/^[bcdgjkpqtuvwyz][.-]/i', $word)) return "a $word"
# HANDLE ORDINAL FORMS
if (preg_match'/^[bcdgjkpqtuvwyz]-?th$/i', $word)) return "a $word"
if (preg_match'/^[aefhilmnorsx]-?th$/i', $word)) return "an $word"
# HANDLE CONSONANTS
if (preg_match'/^[^aeiouy]/i', $word)) return "a $word"
# HANDLE SPECIAL VOWEL-FORMS
if (preg_match'/^e[uw]/i', $word)) return "a $word"
if (preg_match'/^onc?eb/i', $word)) return "a $word"
if (preg_match'/^uni([^nmd]|mo)/i', $word)) return "a $word"
if (preg_match'/^ut[th]/i', $word)) return "an $word"
if (preg_match'/^u[bcfhjkqrst][aeiou]/i', $word)) return "a $word"
# HANDLE SPECIAL CAPITALS
if (preg_match'/^U[NK][AIEO]?/', $word)) return "a $word"
# HANDLE VOWELS
if (preg_match'/^[aeiou]/i', $word)) return "an $word"
# HANDLE y... (BEFORE CERTAIN CONSONANTS IMPLIES (UNNATURALIZED) "i.." SOUND)
if (preg_match'/^(y(b[lor]|cl[ea]|fere|gg|p[ios]|rou|tt))/i', $word)) return "an $word"
# OTHERWISE, GUESS "a"
return "a $word"
}