Search code examples
javanlpnlg

Get Gerund of a verb


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

Solution

  • 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.