Re: how to remove the same words in the paragraph

2009-11-09 Thread Tim Chase
I think simple regex may come handy, p=re.compile(r'(.+) .*\1')#note the space s=p.search("python and i love python") s.groups() (' python',) But that matches for only one double word.Someone else could light up here to extract all the double words.Then they can be removed from the o

Re: how to remove the same words in the paragraph

2009-11-08 Thread S.Selvam
On Wed, Nov 4, 2009 at 4:27 AM, Tim Chase wrote: > kylin wrote: > >> I need to remove the word if it appears in the paragraph twice. could >> some give me some clue or some useful function in the python. >> > > Sounds like homework. To fail your class, use this one: > > >>> p = "one two three fou

Re: how to remove the same words in the paragraph

2009-11-04 Thread Tim Chase
Can we use inp_paragraph.count(iter_word) to make it simple ? It would work, but the performance will drop off sharply as the length of the paragraph grows, and you'd still have to keep track of which words you already printed so you can correctly print the first one. So you might as well

Re: how to remove the same words in the paragraph

2009-11-04 Thread S.Selvam
On Wed, Nov 4, 2009 at 4:27 AM, Tim Chase wrote: > kylin wrote: > >> I need to remove the word if it appears in the paragraph twice. could >> some give me some clue or some useful function in the python. >> > > Sounds like homework. To fail your class, use this one: > > >>> p = "one two three fou

how to remove the same words in the paragraph

2009-11-03 Thread kylin
I need to remove the word if it appears in the paragraph twice. could some give me some clue or some useful function in the python. -- http://mail.python.org/mailman/listinfo/python-list

Re: how to remove the same words in the paragraph

2009-11-03 Thread Tim Chase
kylin wrote: I need to remove the word if it appears in the paragraph twice. could some give me some clue or some useful function in the python. Sounds like homework. To fail your class, use this one: >>> p = "one two three four five six seven three four eight" >>> s = set() >>> print ' '.joi

Re: how to remove the same words in the paragraph

2009-11-03 Thread Andre Engels
On Tue, Nov 3, 2009 at 11:13 PM, kylin wrote: > I need to remove the word if it appears in the paragraph twice. could > some give me some clue or some useful function in the python. Well, it depends a bit on what you call 'the same word' (In the paragraph "Fly fly, fly!" does the word fly occur 0

Re: how to remove the same words in the paragraph

2009-11-03 Thread Peter Otten
kylin wrote: > I want to remove all the punctuation and no need words form a string > datasets for experiment. > I need to remove the word if it appears in the paragraph twice. could > some give me some clue or some useful function in the python. >>> para = u"""I need to remove the word if it ap