Are there any javascript libraries that exist for determining the indefinite article ("a" vs "an") of a noun?
I can start with a simple regex like so:
var pattern = /^([aeiou])/i;
pattern.test("umbrella");
but this doesn't handle a case like: "user" which should return false (you wouldn't say "an user clicked the button").
The following Javascript library by Eamon Nerbonne should be what you are looking for:
http://home.nerbonne.org/A-vs-An/AvsAn.js
This was actually created as an answer to a similar question here on SO:
https://stackoverflow.com/a/1288473/505154
The approach used here was to download Wikipedia, filter it, and create a prefix database to determine a/an, which should be more accurate than most rules-based systems. You can find more information at the following location (also linked in the above answer):
http://home.nerbonne.org/A-vs-An/
There is also a link there to an alternative implementation by Chad Kirby:
https://github.com/uplake/Articles
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With