我想將文檔分成兩個列表,但是這兩個列表中的代碼給了我相同的數據。我定義了兩個單獨的字典,這些字典也是我在這裏使用的。Python,nltk是否將相同的列表值返回給兩個不同的列表?
def feature_extractor(document):
support_features = []
attack_features = []
for sentence in document:
if (word in sentence for word in supporting_ethos):
support_features.append(sentence)
if (word in sentence for word in attacking_ethos):
attack_features.append(sentence)
return(attack_features , support_features)
你可以把它所有的列表理解'裏面[文件句子的句子,如果任何(句子字一個字在support_ethos)]' –