SimpleNLG - How to get the plural of a noun?

I use SimpleNLG 4.4.2to get the 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, getFeaturereturns nullinstead apples. What am I doing wrong?

+4
source share
1 answer

Thanks for letting me know about this library! Based on a 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
+5
source

Source: https://habr.com/ru/post/1613466/


All Articles