library to determine indefinite article of a noun

Posted by Andrew Bullock on Stack Overflow See other posts from Stack Overflow or by Andrew Bullock
Published on 2010-04-06T13:20:30Z Indexed on 2010/04/06 13:23 UTC
Read the original article Hit count: 328

Filed under:
|

Are there any libraries for .NET that deal with determining the Indefinite Article of a noun?

My crude attempt is below, which will probably work for 99% of my usage (which is acceptable) just wondering if there are any established alternatives?

public static string GetIndefinateArticle(string noun)
{
    if(string.IsNullOrEmpty(self))
        return self;

    var first = noun[0];

    if(first == 'a' ||
        first == 'e' ||
        first == 'i' ||
        first == 'o')
        return "a " + self;

    return "an " + self;
}

© Stack Overflow or respective owner

Related posts about c#

Related posts about english