Monday, 30 September 2019

Remove stopwords in Python

Hi All,
See the code using set difference operation

--------------------------------
stopwords="is and it when which where to in have has "
testdata="it is bad and worst"
stoplist=stopwords.split()
testlist=testdata.split()
newtestlist=list(set(testlist)-set(stoplist))
print(newtestlist)
----------------------------------------

No comments:

Post a Comment