I have a database of nouns (e.g. "house", "exclamation point", "apple") that need to be output and described in an application. It's difficult to put together a natural-sounding sentence to describe an item without using "a" or "an" - "the house is big," "the exclamation mark is small," etc.
Is there any function, library or hack I can use in PHP to determine whether A or AN is more appropriate to describe any given noun?
I need this for a C# project, so here is thePython codementioned above. Make sure to include
using System.Text.RegularExpressions;
in your source file.What you want is to identify the appropriate indefinite article.
Lingua::EN::Inflect
is a Perl module that performs well. I've extracted the relevant code and pasted it below. It's just a bunch of cases and some regular expressions, so porting to PHP shouldn't be difficult. A friend ported it to PythonIf anyone is interested, click here.