flat_list = ['speed','glass','front','fond','bezel','design','pleasure','view','day','inky']
我有这样的编码:
from nltk.corpus import wordnet
for w in flat_list:
syns = wordnet.synsets(w)
print(w, syns[0].lexname().split('.')[0]) if syns else (w, None)
和输出:
speed noun
glass noun
front noun
fond adj
bezel noun
design noun
pleasure noun
view noun
day noun
inky adj
如何删除/删除名词以外的其他类型的单词?
谢谢
好吧,因为您的代码不完整,所以我假设您可以获得类似的列表发送
sent = [["speed", "noun"],["glass", "noun"],["front", "noun"],["fond", "adj"],["bezel",
"noun"],["design", "noun"],["inky", "adj"]]
for i in sent:
if i[1] == "noun":
print(i[0])