-
Notifications
You must be signed in to change notification settings - Fork 3
Section 8 Adding adjectives via modifier
This page is based on a page of the wiki for the original SimpleNLG.
We know for a fact that Marie is an good thrower, so we’d like to assign Marie a suitable adjective, like sterk ‘strong’. This can be generated by the SimpleNLG library using the concept of modifier.
To deem Marie ‘sterk’, however, you will no longer want to refer to her simply as the ‘subject’ of the sentence. Instead, let’s also define her name as a noun phrase (which it is). In that way, we can ascribe the adjective ‘sterk’ to Marie (which she certainly is) by means of the modifier function.
NPPhraseSpec subject = nlgFactory.createNounPhrase("Marie");
While we're at it, let's also define the object as a noun phrase and the verb as a verb phrase. This will allow us to do some fancier stuff later on, like adding a modifier to each.
NPPhraseSpec object = nlgFactory.createNounPhrase("de bal"); //[1]
VPPhraseSpec verb = nlgFactory.createVerbPhrase("gooien");
Now, we can apply the adjective ‘sterk’ to Marie by writing:
subject.addModifier("sterk");
Next, we set the subject, object, and verb on the SPhraseSpec p
that we defined earlier:
p.setSubject(subject);
p.setObject(object);
p.setVerb(verb);
String output3 = realiser.realiseSentence(p); // Realiser created earlier.
System.out.println(output3);
The output will be:
Sterke Marie gooit de bal.
→ For more examples on noun phrases, look at testsrc/NounPhraseTest.java
.
→ For more examples on modifiers, look at testsrc/AdjectivePhraseTest.java
.
[1] Note that we can also construct the noun phrase "de bal" in the following way:
NPPhraseSpec object = nlgFactory.createNounPhrase("bal");
object.setSpecifier("de");