-
Notifications
You must be signed in to change notification settings - Fork 1
12 – Multiple subjects, objects and complements
Kira edited this page Apr 14, 2019
·
3 revisions
A sentence can have multiple subjects, objects and complements but not multiple verbs (although a future version of SimpleNLG might include this functionality). Multiple elements can be added with a CoordinatedPhraseElement
:
SPhraseSpec sentence = nlgFactory.createClause();
NPPhraseSpec subject1 = nlgFactory.createNounPhrase("Mary");
NPPhraseSpec subject2 = nlgFactory.createNounPhrase("der Hund");
CoordinatedPhraseElement c = nlgFactory.createCoordinatedPhrase();
c.addCoordinate(subject1);
c.addCoordinate(subject2);
VPPhraseSpec verb = nlgFactory.createVerbPhrase("laufen");
sentence.setSubject(c);
sentence.setVerb(verb);
String output = realiser.realiseSentence(sentence);
System.out.println(output);
SimpleNLG German outputs:
Mary und der Hund laufen.
Automatically, "und" was added and the verb set to plural.
Analogously, several objects can be added by using a CoordinatedPhraseElement
.
The conjunction "und" can be changed, if necessary, for example to "oder" by setting the conjunction to the coordinated phrase:
c.setFeature(Feature.CONJUNCTION, "or");