5

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. 我究竟做错了什么?

4

1 回答 1

7

谢谢你让我知道这个图书馆!根据 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
于 2015-10-30T17:42:05.217 回答