Re: Replace stop words (remove words from a string)

2008-01-17 Thread bearophileHUGS
Raymond Hettinger: > Regular expressions should do the trick. > >>> stoppattern = '|'.join(map(re.escape, stoplist)) > >>> re.sub(stoppattern, '', mystr) If the stop words are many (and similar) then that RE can be optimized with a trie-based strategy, like this one called "List": http://search.cp

Re: Replace stop words (remove words from a string)

2008-01-17 Thread Bruno Desthuilliers
BerlinBrown a écrit : > if I have an array of "stop" words, and I want to replace those values > with something else; in a string, how would I go about doing this. I > have this code that splits the string and then does a difference but I > think there is an easier approach: > > E.g. > > mystr =

Re: Replace stop words (remove words from a string)

2008-01-17 Thread Gary Herron
hould work. > > -Original Message- > From: [EMAIL PROTECTED] > [mailto:[EMAIL PROTECTED] On Behalf Of > BerlinBrown > Sent: Thursday, January 17, 2008 1:55 PM > To: python-list@python.org > Subject: Replace stop words (remove words from a string) > > if I have

Re: Replace stop words (remove words from a string)

2008-01-17 Thread Raymond Hettinger
On Jan 17, 12:25 am, BerlinBrown <[EMAIL PROTECTED]> wrote: > if I have an array of "stop" words, and I want to replace those values > with something else; > mystr = > kljsldkfjksjdfjsdjflkdjslkf[BAD]Kkjjkkjk[BAD]LSKJFKSFJKSJF;L[BAD2]kjsld­fsd; > if I have an array stop_list = [ "[BAD]", "[BAD2

Re: Replace stop words (remove words from a string)

2008-01-17 Thread Casey Rodarmor
e(mystr, s, "") > > Hope this should work. > > -Original Message- > From: [EMAIL PROTECTED] > [mailto:[EMAIL PROTECTED] On Behalf Of > BerlinBrown > Sent: Thursday, January 17, 2008 1:55 PM > To: python-list@python.org > Subject: Replace stop words (re

Re: Replace stop words (remove words from a string)

2008-01-17 Thread Gary Herron
BerlinBrown wrote: > if I have an array of "stop" words, and I want to replace those values > with something else; in a string, how would I go about doing this. I > have this code that splits the string and then does a difference but I > think there is an easier approach: > > E.g. > > mystr = > kl

RE: Replace stop words (remove words from a string)

2008-01-17 Thread Karthik
stop words (remove words from a string) if I have an array of "stop" words, and I want to replace those values with something else; in a string, how would I go about doing this. I have this code that splits the string and then does a difference but I think there is an easier ap

Replace stop words (remove words from a string)

2008-01-17 Thread BerlinBrown
if I have an array of "stop" words, and I want to replace those values with something else; in a string, how would I go about doing this. I have this code that splits the string and then does a difference but I think there is an easier approach: E.g. mystr = kljsldkfjksjdfjsdjflkdjslkf[BAD]Kkjkk