javanlpnlgsimplenlg

SimpleNLG - How to get the plural of a noun?


I'm using SimpleNLG 4.4.2 to get plural form for a noun:

final XMLLexicon xmlLexicon = new XMLLexicon();
final WordElement word = xmlLexicon.getWord("apple", LexicalCategory.NOUN);
System.out.println(word);
System.out.println(word.getFeature(LexicalFeature.PLURAL));

However even for this simple example, getFeature returns null instead of apples. What am I doing wrong?


Solution

  • Thanks for making me aware of this library! Based on the comment from biziclop, I came up with this solution:

    final XMLLexicon xmlLexicon = new XMLLexicon();
    final WordElement word = xmlLexicon.getWord("apple", LexicalCategory.NOUN);
    final InflectedWordElement pluralWord = new InflectedWordElement(word);
    pluralWord.setPlural(true);
    final Realiser realiser = new Realiser(xmlLexicon);
    System.out.println(realiser.realise(pluralWord));
    

    which outputs:

    apples