Skip to content

06 – Prepositional phrases

Kira edited this page Apr 14, 2019 · 3 revisions

Prepositional phrases, for instance "im Park", work exactly the same as in SimpleNLG English. Two ways of constructing a prepositional phrase exist. Either, the prepositional phrase can be added as a whole as a complement to the sentence:

sentence.addComplement("in dem Park");

Or, the elements of the phrase can be specified separately, and then the prepositional phrase added as a complement to the sentence:

NPPhraseSpec place = nlgFactory.createNounPhrase("der park");
PPPhraseSpec pp = nlgFactory.createPrepositionPhrase();
pp.addComplement(place);
pp.setPreposition("in");
pp.setFeature(InternalFeature.CASE, DiscourseFunction.INDIRECT_OBJECT);

sentence.addComplement(pp);

This would output "in dem Park". Please note in order to receive "dem Park", and not "der Park", the corresponding grammatical case must be set to the prepositional phrase, as explained in 07 – Setting the grammatical case.