I have a script that gives me suggestions containing one of the specified keywords. A sentence is defined as something between two periods.
Now I want to use it to select the whole sentence like “Put 1.5 grams of powder”, where, if the powder was the keyword, he would get the whole sentence, and not “5 grams of powder”
I am trying to figure out how to express that sentence is between sequences of period, then space. My new filter:
def iterphrases(text):
return ifilter(None, imap(lambda m: m.group(1), finditer(r'([^\.\s]+)', text)))
However, now I no longer print any sentences of only pieces / phrases of words (including my keyword). I am very confused by what I am doing wrong.
source
share