【发布时间】:2023-01-30 20:48:14
【问题描述】:
假设我有以下字典:
data = {'ACCOUNT_CLOSURE': ['account closure',
'close account',
'close bank',
'terminate account',
'account deletion',
'cancel account',
'account cancellation'],
'ACCOUNT_CHANGE': ['change my account',
'switch my account',
'change from private into savings',
'convert into family package',
'change title of the account',
'make title account to family',
'help me access the documentation']}
我想遍历每个键,然后遍历值的元素并删除停用词,所以我这样做:
stop_words = set(stopwords.words("english"))
for key, values in data.items():
data[key] = [value for value in values if value not in stop_words]
但这会返回与我原来的字典完全相同的字典。我想知道我做错了什么?
【问题讨论】:
标签: python dictionary nltk