I am trying to parse a sentence (or a line of text) where you have a sentence, and maybe some key / shaft pairs were followed on the same line. A pair is not only a key / value pair, but also a dynamic one. I am looking for a result to be something like:
Entrance:
"There was a cow at home. home=mary cowname=betsy date=10-jan-2013"
Output:
Values = {'theSentence' : "There was a cow at home.", 'home' : "mary", 'cowname' : "betsy", 'date'= "10-jan-2013" }
Entrance:
"Mike ordered a large hamburger. lastname=Smith store=burgerville"
Output:
Values = {'theSentence' : "Mike ordered a large hamburger.", 'lastname' : "Smith", 'store' : "burgerville" }
Entrance:
"Sam is nice."
Output:
Values = {'theSentence' : "Sam is nice."}
Thanks for any input / direction. I know the suggestions show that this is a homework problem, but I'm just new to python. I know this is probably a regex solution, but I'm not the best with regards to regex.
source share