MCPcopy Create free account
hub / github.com/BIT-DataLab/LakeBench / minhash_multi_process

Function minhash_multi_process

union/TUS/Uset.py:121–155  ·  view source on GitHub ↗
(folder_path, file_list, q, spl, id, n, type, t)

Source from the content-addressed store, hash-verified

119 return result
120
121def minhash_multi_process(folder_path, file_list, q, spl, id, n, type, t):
122 # print("{} start".format(id))
123 lsh = MinHashLSH(threshold=t, num_perm=128)
124
125 for i, filename in enumerate(file_list):
126 if filename.endswith('.csv'):
127 #file_path = os.path.join(folder_path, filename)
128 df = pd.read_csv(filename, lineterminator='\n', low_memory=False)
129 #取出每一列,将每一列的值minhah,然后加入lsh中,创建索引,列的索引用文件名+列名
130 for column in df.columns:
131 values = df[column].to_list()
132 if type=='Usem':
133 #执行选多数的操作
134 #values_set = majority_classes(values)
135 if values[-1] == 0:
136 continue
137 values_set = [values[-1]]
138 elif type=='Uset':
139 #去重操作
140 values_set = set(values)
141
142 #如果这一列找不到Yago里的entity,那就跳过
143 if len(values_set) == 0:
144 continue
145
146 minHash = MinHash(num_perm=n)
147 values_set = list(values_set)
148 values_set = [str(value) for value in values_set]
149 minHash.update_batch([value.encode('utf-8') for value in values_set])
150 lsh.insert(filename+" "+column, minHash)
151 if id==0:
152 sys.stdout.write("\rId 0 Process Read and minhash {}/{} files".format(i+1, len(file_list)))
153 if id==0:
154 sys.stdout.write("\n")
155 q.put(lsh)
156
157def minhash_Lsh(type='Uset', folder_path = 'benchmark', t=0.9, n =128):
158 lsh = MinHashLSH(threshold=t, num_perm=n)

Callers

nothing calls this directly

Calls 5

update_batchMethod · 0.95
insertMethod · 0.95
MinHashLSHClass · 0.90
MinHashClass · 0.90
writeMethod · 0.80

Tested by

no test coverage detected