withopen("FutabaRio_.txt", encoding='utf-8') as record: for text in record.readlines(): if re.match(r"老婆~✨", text): she_sent_count = she_sent_count + 1 elif re.match("槐十", text): me_sent_count = me_sent_count + 1
result_list = [] withopen('stop_words.txt', encoding='utf-8') as f: con = f.readlines() stop_words = set() for i in con: i = i.replace("\n", "") # 去掉读取每一行数据的\n stop_words.add(i)
for word in seg_list_exact: # 设置停用词并去除单个词 if word notin stop_words andlen(word) > 1: result_list.append(word) print(result_list)