File size: 454 Bytes
e79b770
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
import json
import os

# 获取当前脚本的所在目录
script_dir = os.path.dirname(os.path.abspath(__file__))

# JSON 文件的文件名
json_filename = "ontology.json"

# 构建 JSON 文件的完整路径
json_path = os.path.join(script_dir, json_filename)

id_name_dict = {}

with open(json_path, 'r') as f:
    json_items = json.load(f)
# '/m/0dgw9r' -> 'Human sounds' and etc.
for item in json_items:
    id_name_dict[item['id']] = item['name']