(table_name, lsh, folder_path, topk, Aunion, model, type='Uset', threshold=0.7)
| 18 | from operator import itemgetter |
| 19 | |
| 20 | def get_candidate(table_name, lsh, folder_path, topk, Aunion, model, type='Uset', threshold=0.7):#改调用query_lsh的方式 |
| 21 | file_path = os.path.join(folder_path, table_name) |
| 22 | df = pd.read_csv(file_path) |
| 23 | for column in df.columns: |
| 24 | values = df[column].to_list() |
| 25 | if type == 'Uset' or type == 'Usem': |
| 26 | results = query_lsh(values, lsh, type, n=128, folder_path=folder_path) |
| 27 | else: |
| 28 | results = query_lsh_nl(values, lsh, threshold=threshold) |
| 29 | #对所有的LSH候选结果计算精确的结果 |
| 30 | set_col_dict = cal_precise_unionablity(type, values, results, folder_path, model) |
| 31 | |
| 32 | #把col_dict按照values的大小排序,倒序,把前几个放到集合A_union中 |
| 33 | sorted_col_dict = dict(sorted(set_col_dict.items(), key=itemgetter(1), reverse=True)) |
| 34 | |
| 35 | #这里要不要筛选一遍?还是把所有的候选表都放进去,算表的可并性的时候再筛选 |
| 36 | if len(sorted_col_dict)>=topk: |
| 37 | Aunion.update(list(sorted_col_dict.keys())[:topk])#这里是选top5个 |
| 38 | else: |
| 39 | Aunion.update(list(sorted_col_dict.keys())) |
| 40 | #Usem的minhashLSH索引得改,改成最后一行插入的 |
| 41 | |
| 42 | def get_column_goodness(score, type = 'uset'): |
no test coverage detected