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

Function entity_cellvalues_lsh

union/TUS/freebaseProcess.py:17–36  ·  view source on GitHub ↗
(folder_path = 'benchmark', yago_path = 'yago', file_name='yagoTypes.tsv', threshold=0.95)

Source from the content-addressed store, hash-verified

15#通过这个lsh索引分桶里面选一个实体作为这个桶里所有值匹配的实体,阈值设为0.9,然后建个字典,存起来,处理表的时候直接查
16
17def 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
39def match_yago_entity_from_yago_lsh(lsh, file_subset):

Callers

nothing calls this directly

Calls 5

updateMethod · 0.95
insertMethod · 0.95
MinHashLSHClass · 0.90
get_yagoTypes_from_tsvFunction · 0.90
MinHashClass · 0.90

Tested by

no test coverage detected