有没有办法用python检查列表中的字符串是否是普通英语中使用的真实单词?
我试图从一个关键字列表中提取出英语中常见的单词 这是我的密码:有没有办法用python检查列表中的字符串是否是普通英语中使用的真实单词?,python,python-3.x,Python,Python 3.x,我试图从一个关键字列表中提取出英语中常见的单词 这是我的密码: words = ['apple','a%32','j & quod','rectangle','house','fsdfdsoij','fdfd'] for word in words: if word ???: # How can I check if the words is a real word? Any module that I can use for that or a free API?
words = ['apple','a%32','j & quod','rectangle','house','fsdfdsoij','fdfd']
for word in words:
if word ???: # How can I check if the words is a real word? Any module that I can use for that or a free API?
print:
else:
pass
我只想得到以下结果:
apple
rectangle
house
第一步,安装nltk 然后: 试试:-他们的英语很好。
import nltk
nltk.download('words')
from nltk.corpus import words
samplewords=['apple','a%32','j & quod','rectangle','house','fsdfdsoij','fdfd']
[i for i in samplewords if i in words.words()]
['apple', 'rectangle', 'house']