How do you ask "Should I (verb) (object)"

137 views
Skip to first unread message

Samy Ateia

unread,
Apr 24, 2016, 7:46:49 PM4/24/16
to simplenlg
Hi i would like to use simplenlg to ask simple "Should I (verb) (object)" questions.

Is it possible and how can i achieve this?

the closest  i was getting was with this code:

p.setFeature(Feature.INTERROGATIVE_TYPE, InterrogativeType.YES_NO);
String subject = "I";
p.setSubject(subject);
p.setVerb(verb);
        p.setObject(object);


Best,

Samy

Rodrigo de Oliveira

unread,
Apr 25, 2016, 8:43:04 AM4/25/16
to simp...@googlegroups.com
Samy,

Yes, but not in the ‘proper’ way AFAIK.

My (very!) hacky solution:
p.setFeature(Feature.INTERROGATIVE_TYPE, true);
String verb = "eat";
p.setVerb(verb);
String object = "chocolate";
p.setObject(object);
p.addPreModifier("should I);

Why is this a hack?
A) TRUE is not the expected value of InterrogativeType, as you’d normally provide things like HOW or WHO. But it gives you the question mark in the end.
B) Not the proper linguistic parse.

What should be done to achieve what you want in the proper way?
A) AFAIK, interrogatives are restricted to a WH type of interrogative, such as HOW or WHO. One would need to modify the VerbPhraseHelper algorithm (and relevant Enums) to allow non-WH interrogative types other than with do and be. When you set InterrogativeType to YES_NO (which I think was the right interpretation), SimpleNLG will place a form of do (do, does, did) or be (am, is, are, were, was) at the beginning of the sentence. What you need at the start of the sentence is none, but the modal verb “should”. And you surely don’t want “who”, “how”, “how many” there either.
B) Provide the proper linguistic specification. Since you need the modal “should”, you cannot pass a single verb to the sentence. Instead you’ll need to pass a VerbPhrase, whose head is the verb you want and set the modal of the verb phrase to be “should”. Once all the is done, your linguistically valid code would look like:
p.setFeature(Feature.INTERROGATIVE_TYPE, true);
p.setSubject("I");
String verb = "eat";
VPPhraseSpec vp = nlgFactory.createVerbPhrase(verb);
vp.setFeature(Feature.MODAL, "should");
p.setVerb(vp);
String object = "chocolate";
p.setObject(object);

Hope this helps.

Rodrigo de Oliveira

unread,
Apr 25, 2016, 10:26:37 AM4/25/16
to simp...@googlegroups.com
Sorry, I meant the following code would be a linguistically valid sentence specification:

p2.setFeature(Feature.INTERROGATIVE_TYPE, InterrogativeType.YES_NO);
p2.setSubject("I");
VPPhraseSpec vp = nlgFactory.createVerbPhrase(verb);
vp.setFeature(Feature.MODAL, "should");
p2.setVerb(vp);
p2.setObject(object);

However the above currently returns “Do I should eat chocolate?”.
On 25 Apr 2016, at 00:46, 'Samy Ateia' via simplenlg <simp...@googlegroups.com> wrote:

--
You received this message because you are subscribed to the Google Groups "simplenlg" group.
To unsubscribe from this group and stop receiving emails from it, send an email to simplenlg+...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Samy Ateia

unread,
Apr 25, 2016, 10:43:42 AM4/25/16
to simplenlg
Hi Rodrigo, thank you very much for your help!
Reply all
Reply to author
Forward
0 new messages