|
#!/usr/bin/python
|
# -*- coding: UTF-8 -*-
|
|
import sys
|
from numpy import *
|
|
'''
|
把原始的txt文件, 去重保存成新文件。
|
|
去重规格: 选取四个字中完全不重复的词语,比如“万马奔腾”,删除“鼎鼎有名”,“兢兢业业”,“打探打探”,“不干不净”等。
|
|
'''
|
|
base_txt_file = sys.argv[1]
|
exclude_duplicated = sys.argv[2]
|
|
|
with open(exclude_duplicated, 'w', encoding='utf-8') as final_f:
|
with open(base_txt_file, 'r', encoding='utf-8-sig') as f:
|
for word in f.read().splitlines():
|
#print(word)
|
if len(word) == 4:
|
_list_unique = set()
|
_list_unique.add(word[0])
|
_list_unique.add(word[1])
|
_list_unique.add(word[2])
|
_list_unique.add(word[3])
|
if len(_list_unique) == 4:
|
final_f.write(word)
|
final_f.write('\n')
|
else:
|
print(word)
|
else:
|
print(word)
|