# 暂时没有用到这个函数
import json

def extract_related_work(content_path):
    # 输入参数是PDF文件的content.json文件的路径
    # 读取content.json文件
    # 格式为 "1+KANs are interpretable+19" ,其中1是level, KANs are interpretable是title, 19是page
    with open(content_path, 'r', encoding='utf-8') as file:
        print(content_path)
        content = json.load(file)


    # 找到key中包含related work的内容, 查看level, 并获得其内容和子内容, 形成一个层级结构的字典
    related_work = {}
    have_found = False
    all_found = False
    for key in content.keys():
        if 'related work' in key.lower() and not have_found:
            level = int(key.split('+')[0])
            have_found = True
        elif have_found and not all_found:
            if int(key.split('+')[0]) > level:
                related_work[key] = content[key]
            else:
                all_found = True
                break

