parent
8878361126
commit
153b2dadc1
@ -1,18 +1,22 @@
|
|||||||
import json
|
import ijson
|
||||||
|
import os
|
||||||
|
|
||||||
from Tools.KG_Config import TOPIC
|
from Tools.KG_Config import TOPIC
|
||||||
|
|
||||||
# 文件路径
|
# 文件路径
|
||||||
file_path = rf"d:\dsWork\dsProject\dsLightRag\Topic\{TOPIC}\vdb_entities.json"
|
file_path = rf"d:\dsWork\dsProject\dsLightRag\Topic\{TOPIC}\vdb_entities.json"
|
||||||
|
|
||||||
# 读取并解析JSON文件
|
# 检查文件是否存在
|
||||||
with open(file_path, 'r', encoding='utf-8') as f:
|
if not os.path.exists(file_path):
|
||||||
data = json.load(f)
|
raise FileNotFoundError(f"文件不存在: {file_path}")
|
||||||
|
|
||||||
# 提取所有实体名称
|
|
||||||
entities = [item['entity_name'] for item in data['data']]
|
|
||||||
|
|
||||||
# 打印实体列表
|
# 使用ijson流式读取JSON文件
|
||||||
|
with open(file_path, 'r', encoding='utf-8') as f:
|
||||||
|
# 流式迭代所有实体名称
|
||||||
|
print("正在读取实体...")
|
||||||
|
entity_names = ijson.items(f, 'data.item.entity_name')
|
||||||
|
entity_list = list(entity_names)
|
||||||
|
print(f"共找到 {len(entity_list)} 个实体:")
|
||||||
print("文件中的实体列表:")
|
print("文件中的实体列表:")
|
||||||
for entity in entities:
|
for entity in entity_list:
|
||||||
print(f"- {entity}")
|
print(f"- {entity}")
|
Loading…
Reference in new issue