Changing a statement into a question

Consider the following sentences:

  • Every day I want to:

    1. read a book
    2. do my homework
    3. go jogging for 20 minutes
    4. be nice to my mom

To convert these into the following questions:

  • Did you:

    1. read a book today?
    2. do your homework today?
    3. go jogging for 20 minutes today?
  • Were you:

    1. nice to your mom today?

You would change:
me --> you and
be --> were

I need to write a program which does this, are there any cases where this would fail? What are the general rules?

I know for long sentences this would make no sense, but only 50 characters are allowed.


Your program needs to do a couple of things:

  1. Identify the main verb. This is harder than it seems in the general case, but if you've constrained your answers to complete a sentence of the form Every day I want to [blank], then you can be reasonably assured that the first word of the continuation is a verb in the infinitive form.
  2. If the main verb is be, then the verb should be moved directly to the front of the sentence.
  3. If the main verb is have followed by a past participle, then the verb (but not the participle) should be moved directly to the front of the sentence.
  4. For all other verbs, you should leave the verb in place (uninflected) and add Did to the front of the sentence.
  5. Replace all forms of the pronoun I with the corresponding form of the pronoun you
  6. Inflect the verbs at the beginning of the sentence to agree with you.

So it's quite a bit more complicated than you originally described. However, provided that the input sentences are suitably constrained, it should be possible with relatively small effort. (Note, however, that turning arbitrary statements into questions is quite a bit harder, and generally cannot be accomplished without a complete parse of the original statement.)


You might get hung up on more complex forms, but I agree with Mr. Disappointment that you should just write it and start fixing problems as you run into them. (Mr. Disappointment should put that in an answer so he can get reputation for that. :-) )

An example of a problem case: "have finished the previous day's to-do list". That is, you want to arrive at each day having already completed the previous day's tasks. I'm not sure that translates to your target form at all, but the rules you have won't suffice. On the other hand, it's a little convoluted so maybe you don't care.