Programmatically determine whether to describe an object with “a” or “an”?

后端 未结 8 1527
耶瑟儿~
耶瑟儿~ 2020-12-01 21:13

I have a database of nouns (ex \"house\", \"exclamation point\", \"apple\") that I need to output and describe in my application. It\'s hard to put together a natural-soundi

8条回答
  •  一整个雨季
    2020-12-01 21:46

    I've written a PHP port of the popular JS a-vs-an code as described in this stackoverflow post https://stackoverflow.com/a/1288473/1526020.

    Github page: https://github.com/UseAllFive/a-vs-an.

    E.g.

    $result = $aVsAn->query('0800 number');
    print_r($result);
    

    Returns

    Array
    (
        [aCount] => 8
        [anCount] => 25
        [prefix] => 08
        [article] => an
    )
    

提交回复
热议问题