// getIndefiniteArticle.js
(function () {
/* global AdventureJS A */
var p = AdventureJS.Dictionary.prototype;
p.vowel_exceptions = /^(honest|honor|honour|hour|heir)\b/i;
p.consonant_exceptions = /^(uni([^nmd]|$)|use|user|usual|euro|one|once)\b/i;
/**
* Get an indefinite article for the specified string.
* @memberOf AdventureJS.Dictionary
* @method AdventureJS.Dictionary#getIndefiniteArticle
* @param {String} name
*/
p.getIndefiniteArticle = function Dictionary_conjugate(name) {
const text = name.trim();
if (this.vowel_exceptions.test(text)) {
return "an";
}
if (this.consonant_exceptions.test(text)) {
return "a";
}
return /^[aeiou]/i.test(text) ? "an" : "a";
};
})();