how to remove the same words in the paragraph

Peter Otten __peter__ at web.de
Tue Nov 3 17:40:26 EST 2009


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 appears in the paragraph 
twice. could
... some give me some clue or some useful function in the python.
... """
>>> print "\n".join(sorted(set(para.translate(dict.fromkeys(map(ord, 
".:,-"))).split())))
I
appears
clue
could
function
give
if
in
it
me
need
or
paragraph
python
remove
some
the
to
twice
useful
word





More information about the Python-list mailing list