我想在句子中找到一个词来给句子分类。为此,我创建了以下函数:
def theme(x):
category = ()
for i in x:
if 'AC' in i:
category = 'AC problem'
elif 'insects' in i:
category = 'Cleanliness'
elif 'clean' in i:
category = 'Cleanliness'
elif 'food' in i:
category = 'Food Problem'
elif 'delay' in i:
category = 'Train Delayed'
else:
category = 'None'
print(category)
输出为:
None
None
AC problem
None
AC problem
如何将此输出保存到变量
相关问题 更多 >
编程相关推荐