java – 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.我究竟做错了什么?
解决方法:
感谢您让我知道这个图书馆!根据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
标签:java,nlp,nlg 来源: https://codeday.me/bug/20190609/1202686.html