我是Simple NLG的新手,我想知道我输入的动词的动名词.
这是一个示例代码,但是我尝试输入gerund来进行时态,但是没有用
XMLLexicon lexicon = new XMLLexicon("path\\to\\default-lexicon.xml");
WordElement word = lexicon.getWord("live", LexicalCategory.VERB);
InflectedWordElement infl = new InflectedWordElement(word);
infl.setFeature(Feature.TENSE, Tense.PAST); //I want the verb to be in gerund not past
Realiser realiser = new Realiser(lexicon);
String gerund = realiser.realise(infl).getRealisation();
System.out.println(gerund);
解决方法:
我不知道API,但是从我可以拼凑的角度来看,它看起来类似于
XMLLexicon lexicon = ...
NLGFactory phraseFactory = new NLGFactory(lexicon);
VPPhraseSpec live = phraseFactory.createVerbPhrase("live");
SPhraseSpec clause = phraseFactory.createClause();
clause.setVerbPhrase(live);
clause.setFeature(Feature.FORM, Form.GERUND);
Realizer realizer = new Realizer(lexicon);
String gerund = realizer.realize(clause).getRealisation();
可能对你更好.
如果找不到更好的资源,请查看the unit tests,以获取有关如何使用API的提示.