Hi,
This is just part of a bigger program I'm writing, but at the moment I don't know how to do what I'm about to say.
So first, the user enters a sentence. Now, I have a text file with sentences to match it to. So let's say the first line in the text file is:
i am <state> | Do you often feel <state>?
So what I need to do is check whether the input matches the part before the | and if so, print the part after the |. The <state> is represented by any word. So if the user inputs 'i am hungry', then <state> would be hungry, and the output would be 'Do you often feel hungry'. The problem is I don't know how to check the input like that when I don't know one of the words. I can't remove the <state> and use indexing to get the next word because:
Another rule may not have the missing word at the start or end eg.
can you <w1> <w2> <w3> something | Why should I <w1> <w2> <w3> something?
The input might be 'can you help me with something' and the output would then by 'Why should I help you with something?
And one requirement of the program is I need to store the word(s) in question for later use, I'm assuming as a dictionary. So taking the above into account, the dicionary would be {<state>: 'hungry', <w1>: 'help', <w2>: 'me', <w3>: 'with'} This would assist in printing the output as I could just define any word with <> and as the user said it, the definition would be the word I need.
So how could I do such a task as to match sentences when 1 or more words is not known?