你可以试试这个代码:
from textblob import TextBlob
from nltk.corpus import stopwords
b="Do not purchase these earphones. It will automatically disconnect and reconnect. Worst product to buy."
text=TextBlob(b)
# Tokens
tokens=set(text.words)
print("Tokens: ",tokens)
# stopwords
stop=set(stopwords.words("english"))
# Removing stop words using set difference operation
print("Filtered Tokens: ",tokens-stop)
Output:
*Tokens:{'购买', '断开连接', '将', '要', '购买', '重新连接', '产品', '它', '做', '和', '最差', '耳机', '不'、'自动'、'这些'}
过滤后的令牌:{'购买', '断开连接', '购买', '重新连接', '产品', '它', '做', '最差', '耳机', '自动'}*