Skip to content

Instantly share code, notes, and snippets.

@CurtisL
Last active December 5, 2015 00:47
Show Gist options
  • Save CurtisL/96a0e70b530a6bac0432 to your computer and use it in GitHub Desktop.
Save CurtisL/96a0e70b530a6bac0432 to your computer and use it in GitHub Desktop.
Indefinite Article Grammar Helper Challenge

Challenge

Write a script that will help determine the indefinite article of a word ('a' or 'an'). The test strings below demonstrate some of the complexities of this grammar rule to be aware of. But test it aginst as many strings as you can think of.

Exceptions:

Some conditions do not need to be considered for this challenge.

  • Don't worry about "Uncountable" words such as "air" or "salt" they don't count (Ha! Pun!).
  • Consider all words to be an "American" accent. "an herb" (American silent H) vs "a herb" (European hard H) when testing. Bonus points (not that there are points or anything) if you have the ability to match based of accent.

Test Strings

	'apple',
	'boy',
	'car',
	'dog',
	'elephant',
	'eulogy',
	'euro',
	'european',
	'espresso',
	'farm',
	'goat',
	'helicopter',
	'honor',
	'house',
	'hour',
	'hound',
	'umbrella',
	'undisclosed',
	'unit',
	'university',

Test Key

	'apple'       : 'an',
	'boy'         : 'a',
	'car'         : 'a',
	'dog'         : 'a',
	'elephant'    : 'an',
	'eulogy'      : 'a',
	'euro'        : 'a',
	'european'    : 'a',
	'espresso'    : 'an',
	'farm'        : 'a',
	'goat'        : 'a',
	'helicopter'  : 'a',
	'honor'       : 'an',
	'house'       : 'a',
	'hour'        : 'an',
	'hound'       : 'a',
	'umbrella'    : 'an',
	'undisclosed' : 'an',
	'unit'        : 'a',
	'university'  : 'a',

Extra

Expand on the test words: Find other words to put to the test. This grammar rule has some interesting exceptions that may make it more of a challenge with more words.

Accent Option: Test against alternate accents that may change the article of some words.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment