diff --git a/kg_lab_6.13/xml_to_json.py b/kg_lab_6.13/xml_to_json.py index 3da238e..55f77e6 100644 --- a/kg_lab_6.13/xml_to_json.py +++ b/kg_lab_6.13/xml_to_json.py @@ -365,6 +365,18 @@ def parse_indicator_string_to_json(indicator_str: str, output_path: str = "outpu # 解析为 JSON 对象 result = json.loads(indicator_str) + # 过滤 + for item in result: + mapping = item.get("指标描述", {}).get("指标映射") + if isinstance(mapping, str): + if "【工程费用】" in mapping: + cleaned = re.sub(r"@.*?\.", "", mapping) + item["指标描述"]["指标映射"] = cleaned + elif isinstance(mapping, list): + first_elem = mapping[0] + if first_elem.startswith("(") and first_elem.endswith(")"): + del mapping[0] + # 保存为 JSON 文件 with open(output_path, 'w', encoding='utf-8') as f: json.dump(result, f, ensure_ascii=False, indent=2)