3

I'm new to Simple NLG, I want to get the gerund of the verb I enter. here is a sample code, but i tried entering gerund for tense but it didn't work

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);
Jeremy Hunts
  • 353
  • 1
  • 5
  • 14

1 Answers1

3

I don't know the API, but from what I could piece together, it looks like an approach similar to

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

Might be better for you.

Look at the unit tests for hints on how to use an API if you cannot find a better resource.

Edwin Buck
  • 69,361
  • 7
  • 100
  • 138
  • Thank you ! That helped me reach the right code Lexicon lexicon = new NIHDBLexicon("C:\\Users\\BlackRain\\Desktop\\lexAccess2016 (1)\\lexAccess2016\\data\\HSqlDb\\lexAccess2016.data"); NLGFactory phraseFactory = new NLGFactory(lexicon); VPPhraseSpec live = phraseFactory.createVerbPhrase("skim"); SPhraseSpec clause = phraseFactory.createClause(); clause.setVerbPhrase(live); clause.setFeature(Feature.FORM,Form.GERUND); Realiser realizer = new Realiser(lexicon); String gerund = realizer.realise(clause).getRealisation(); – Jeremy Hunts Nov 06 '16 at 09:36
  • @JeremyHunts Glad you could piece together the last bits. Happy to hear it worked. – Edwin Buck Nov 07 '16 at 03:29
  • @JeremyHunts Added the `Feature.FORM` parameter to the original question; because, it's pretty hard to read in the comment. – Edwin Buck Dec 21 '16 at 21:50