参考文献生成项目,使用faiss实现
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

23 lines
561 B

import json
with open("label_threshold.txt", encoding="utf-8") as f:
data = json.loads(f.read())
id2lable = {}
lable2id = {}
for i in data:
if i not in lable2id:
lable2id[i] = data[i][0]
for i in lable2id:
if lable2id[i] not in id2lable:
id2lable[lable2id[i]] = i
with open("data/lable/id2lable.json", "w", encoding="utf-8") as f:
f.write(json.dumps(id2lable, indent=2, ensure_ascii=False))
with open("data/lable/lable2id.json", "w", encoding="utf-8") as f:
f.write(json.dumps(lable2id, indent=2, ensure_ascii=False))