Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Javascript library to determine indefinite article

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").

like image 933
frshca Avatar asked Mar 12 '13 16:03

frshca


1 Answers

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

like image 165
Andrew Clark Avatar answered Oct 12 '22 01:10

Andrew Clark