(set_path, file_list, q, param_dic, id)
| 139 | # print("{} end,size={}".format(id,len(sizes))) |
| 140 | |
| 141 | def minhash_multi_process(set_path, file_list, q, param_dic, id): |
| 142 | # print("{} start".format(id)) |
| 143 | lsh = MinHashLSHEnsemble(threshold=param_dic['threshold'], num_perm=param_dic['num_perm'], |
| 144 | num_part=param_dic['num_part'], m=param_dic['m'], storage_config=param_dic['storage_config']) |
| 145 | for i, (lower, upper) in enumerate(param_dic["partitions"]): |
| 146 | lsh.lowers[i], lsh.uppers[i] = lower, upper |
| 147 | for i, sets_file in enumerate(file_list): |
| 148 | df = pd.read_csv(os.path.join(set_path, sets_file), dtype='str', lineterminator='\n').dropna() |
| 149 | columns = df.columns.tolist() |
| 150 | data = df.values.T.tolist() |
| 151 | for column, vals in zip(columns, data): |
| 152 | # 需要对value去重 |
| 153 | vals = list(set(vals)) |
| 154 | # 域的键值 |
| 155 | key = sets_file + "." + column |
| 156 | # 生成minhash |
| 157 | mh = MinHash(param_dic['num_perm'], hashfunc=_hash_32) |
| 158 | for word in vals: |
| 159 | mh.update(str(word)) |
| 160 | lsh.index((key, mh, len(vals))) |
| 161 | if id==0: |
| 162 | sys.stdout.write("\rId 0 Process Read and minhash {}/{} files".format(i+1, len(file_list))) |
| 163 | if id==0: |
| 164 | sys.stdout.write("\n") |
| 165 | q.put(lsh) |
| 166 | |
| 167 | # 将csv文件列表中每个表格中的column转换为三元组(minhashes, sets, keys)形式 |
| 168 | # @profile |
nothing calls this directly
no test coverage detected