I need to do some pattern matching to process a list of questions and come up with
some statements that will head the list of solutions. Every question that I need to match
has a first sentence that ends in a “?”. For example if have the following string:
input="Which of the following can be aa ... zz?"
then I need to see if this matches some predefined patterns and if it does then I need to populate two variables. In this example the string above needs to result in the following:
string1= "Can be aa ... zz:"
string2= "Cannot be contained aa ... zz:"
Where the text aa … zzz in the source appears in the destination.
Inputs:
1 - Which of the following can be aa ... zz?
2 - Which of the following are correct?
3 - What will result when aa ... zz?
4 - Which of the following is a aa ... zz?
5 - Which are aa ... zz?
6 - What can be said about aa ... zz:
7 - Which of the following is true?
8 - What will be the result when aa ... zz?
Output 1:
1 - Can be aa ... zz:
2 - Correct:
3 - The following will result::
4 - A aa ... zz
5 - The following are aa ... zz
6 - True statement(s)
7 - True statement(s)
8 - The following will result:
Output 2:
1 - Cannot be aa ... zz:
2 - Incorrect:
3 - The following will not result
4 - Not a aa ... zz:
5 - Are not aa ... zz:
6 - False statement(s)
7 - False statement(s)
8 - The following will not result
I am thinking that I should store the input pattern and output patterns in a reference data class and then maybe some combination of link and pattern matching.
Does anyone have any suggestions. Even if I could see how to do one match that would be good.
If I have an example for one then I can code in more and work from that.
What kind of patterns? – The patterns are the text. So for example I am looking to see if my input string starts with “Which of the following can be” and ends with a “?”.
Where are these questions coming from? – A limited set of questions. If I cannot get a match then I will put in something like “True” or “False” in the outputs.
It can be modeled something like below: