我有一个单词列表,如果声明,我想做,下面是我的列表:
list = ['camera','display','price','memory'(will have 200+ words in the list)]
Run Code Online (Sandbox Code Playgroud)
这是我的代码:
def check_it(sentences):
if 'camera' in sentences and 'display' in sentences and 'price' in sentences:
return "Camera/Display/Price"
if 'camera' in sentences and 'display' in sentences:
return "Camera/Display"
...
return "Others"
h.loc[:, 'Category'] = h.Mention.apply(check_it)
Run Code Online (Sandbox Code Playgroud)
对于这些组合将有太多组合,并且我希望单独返回行.有谁知道如何制作这个样本并单独返回单词而不是做'相机/显示/价格'?