nlp - SimpleNLG - Creating a 2 part sentence using "placeholders" -


does know how (using simplenlg) create proper "two part" sentence (i'm not linguist i'm not sure syntactic categories each word/phrase:

"i bought a new widget engine, created product a, product b, , product c."

the text in bold inserted dynamically @ runtime syntactic parser or else. went through simplenlg tutorial (there doesn't seem else that's more in-depth) , subsequently tried attach ppphrasespec object (representing second part of sentence above) sphrasespec (which has nounphrase , verbphrase), result incomprehensible , grammatically incorrect.

here solution problem: first part in bold grammatical object (a noun phrase) , second part in bold object verb "create" (coordinate clause).

import simplenlg.realiser.english.realiser; import simplenlg.lexicon.lexicon; import simplenlg.phrasespec.*; import simplenlg.framework.*; import simplenlg.features.*;   public class test {      // target:     // bought new widget engine,      //   created product a, product b, , product c.      public static void main(string[] args) {         system.out.println("starting...");         lexicon lexicon = lexicon.getdefaultlexicon();         nlgfactory nlgfactory = new nlgfactory(lexicon);         realiser realiser = new realiser(lexicon);          sphrasespec s1 = nlgfactory.createclause("i",             "bought", "a new widget engine");         s1.setfeature(feature.tense, tense.past);          sphrasespec s2 = nlgfactory.createclause("", "created");         npphrasespec object1 = nlgfactory.createnounphrase("product a");         npphrasespec object2 = nlgfactory.createnounphrase("product b");         npphrasespec object3 = nlgfactory.createnounphrase("product c");          coordinatedphraseelement cc = nlgfactory.createcoordinatedphrase();         cc.addcoordinate(object1);         cc.addcoordinate(object2);         cc.addcoordinate(object3);          s2.setobject(cc);         s2.setfeature(feature.tense, tense.past);          s2.setfeature(feature.complementiser, ", which"); // non-restrictive?         s1.addcomplement(s2);          string output = realiser.realisesentence(s1);         system.out.println(output);     }  } 

i not native english speaker , part wrong, think want restrictive relative clause instead of non-restrictive one: "i bought new widget engine created..." instead of "i bought new widget engine, created ..." if case, comment line setting complementiser.


Comments

Popular posts from this blog

java - How to specify maven bin in eclipse maven plugin? -

single sign on - Logging into Plone site with credentials passed through HTTP -

php - Why does AJAX not process login form? -