(folder_path = 'benchmark', yago_path = 'yago', file_name='yagoTypes.tsv', threshold=0.95)
| 15 | #通过这个lsh索引分桶里面选一个实体作为这个桶里所有值匹配的实体,阈值设为0.9,然后建个字典,存起来,处理表的时候直接查 |
| 16 | |
| 17 | def entity_cellvalues_lsh(folder_path = 'benchmark', yago_path = 'yago', file_name='yagoTypes.tsv', threshold=0.95): |
| 18 | #file_path = os.path.join(yago_path, file_name) |
| 19 | lsh = MinHashLSH(threshold=0.95, num_perm=128) |
| 20 | entity_set = set() |
| 21 | # with open(file_path, 'r', encoding='utf-8') as file: |
| 22 | # for line in file: |
| 23 | # _, entity, relation, t = line.strip().split('t') |
| 24 | # entity = process_string(entity[1:-1]) |
| 25 | # entity_set.add(entity) |
| 26 | conn, cursor = get_yagoTypes_from_tsv() |
| 27 | query = "SELECT distinct entity, taxonomy_class, entity_count FROM yagoTypejoinclasses" |
| 28 | cursor.execute(query) |
| 29 | |
| 30 | # 获取查询结果 |
| 31 | results = cursor.fetchall() |
| 32 | for row in results: |
| 33 | minhash = MinHash(num_perm=128) |
| 34 | minhash.update(row[0].encode('utf-8')) |
| 35 | index = "+-*/".join(row) |
| 36 | lsh.insert(index, minhash) |
| 37 | |
| 38 | |
| 39 | def match_yago_entity_from_yago_lsh(lsh, file_subset): |
nothing calls this directly
no test coverage detected