编程语言
首页 > 编程语言> > java-获取动词的Gerund

java-获取动词的Gerund

作者:互联网

我是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​​的提示.

标签:nlp,java,nlg
来源: https://codeday.me/bug/20191118/2024865.html