【问题标题】:Get Gerund of a verb获取动词的动名词
【发布时间】:2016-11-02 01:34:24
【问题描述】:

我是 Simple NLG 的新手,我想获得我输入的动词的动名词。 这是一个示例代码,但我尝试输入动名词来表示时态,但它不起作用

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);

【问题讨论】:

  • but it didn't work ... 什么不起作用,或者你得到什么输出?
  • 输出是动词的过去式。因为在第 4 行你可以看到,Tense.PAST 我想将输出更改为动名词,除了没有语法 Tense.GERUND 所以这是我的问题。如何在我的代码中更改这一行或多行,以便输出为动名词。
  • 你能检查一下这个文档吗?

标签: java nlp nlg


【解决方案1】:

我不知道 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 的提示。

【讨论】:

  • 谢谢!这帮助我找到了正确的代码 Lexicon lexicon = new NIHDBLexicon("C:\\Users\\BlackRain\\Desktop\\lexAccess2016 (1)\\lexAccess2016\\data\\HSqlDb\\lexAccess2016.data"); NLGFactory 短语工厂 = new NLGFactory(lexicon); VPPhraseSpec live = phraseFactory.createVerbPhrase("skim"); SPhraseSpec 子句 = phraseFactory.createClause();子句.setVerbPhrase(live);子句.setFeature(Feature.FORM,Form.GERUND); Realiser 实现者 = new Realiser(lexicon); String gerund = implementationr.realise(clause).getRealisation();
  • @JeremyHunts 很高兴你可以拼凑出最后的部分。很高兴听到它奏效了。
  • @JeremyHunts 在原始问题中添加了Feature.FORM 参数;因为,在评论中很难阅读。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2015-11-26
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多