我正在使用SimpleNLG 4.4.2获得名词的复数形式:

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

但是,即使对于这个简单的示例,getFeature也会返回null而不是apples。我究竟做错了什么?

最佳答案

感谢您让我知道这个图书馆!根据biziclop的评论,我提出了以下解决方案:

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));

输出:
apples

10-06 09:08