I am trying to split this sentence
"Mr. Smith bought cheapsite.com for 1.5 million dollars, i.e. he paid a lot " \
"for it. Did he mind? Adam Jones Jr. thinks he didn't. In any case, this " \
"isn't true... Well, with a probability of .9 it isn't."
Into list of below.
Mr. Smith bought cheapsite.com for 1.5 million dollars, i.e. he paid a lot for it.
Did he mind?
Adam Jones Jr. thinks he didn't.
In any case, this isn't true...
Well, with a probability of .9 it isn't.
Code:
print re.findall('([A-Z]+[^.].*?[a-z.][.?!] )[^a-z]',text)
Output:
['Mr. Smith bought cheapsite.com for 1.5 million dollars, i.e. he paid
a lot for it. ', "Adam Jones Jr. thinks he didn't. "]
K gud, but it missed some, is there a way to tell Python since last [^a-z] isn't part of my group, pls continue searching from there.
EDIT:
This was achieved through forward look ahead regex as mentioned by @sputnick.
print re.findall('([A-Z]+[^.].*?[a-z.][.?!] )(?=[^a-z])',text)
Output:
['Mr. Smith bought cheapsite.com for 1.5 million dollars, i.e. he paid
a lot for it. ', 'Did he mind? ', "Adam Jones Jr. thinks he didn't. "
, "In any case, this isn't true... "]
But we still need the last sentence. Any ideas?