SimpleNLG - 如何获得名词的复数?

时间:2015-10-28 10:56:29

标签: java nlp nlg simplenlg

我正在使用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。我做错了什么?

1 个答案:

答案 0 :(得分:5)

感谢您让我了解这个图书馆!根据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