SimpleNLG - 如何获得名词的复数形式?
SimpleNLG - How to get the plural of a noun?
我正在使用 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
returns 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
我正在使用 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
returns 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