初始归档:健康管理资料库(大医网/药膳/体质监测/中医理论等12个资料集,7712个文件)
This commit is contained in:
commit
80ae3811cf
7712 files changed
+4628547
No files matched your search
@@ -0,0 +1,40 @@
|
||||
|
||||
import json
|
||||
|
||||
def recommend(disease_query, cleaned_idx_path, exercise_idx_path):
|
||||
with open(cleaned_idx_path, 'r', encoding='utf-8') as f:
|
||||
idx = json.load(f)
|
||||
with open(exercise_index_path, 'r', encoding='utf-8') as f:
|
||||
ex_data = json.load(f)
|
||||
|
||||
results = {"food_remedy": [], "exercise_remedy": []}
|
||||
|
||||
# 1. Find Food Remedy
|
||||
# Search in '药膳_flatten_mapping'
|
||||
for mapping_key, ingredients in idx.get('药膳_mapping_cleaned', {}).items():
|
||||
# Check if disease name is in the key
|
||||
if disease_query in mapping_key:
|
||||
results["food_remedy"].append(f"Use {', '.join(ingredients)} patterns found in {mapping_key}")
|
||||
|
||||
# 2. Find Exercise Remedy
|
||||
for tech in ex_data['techniques']:
|
||||
# Check benefits or parts
|
||||
keywords = tech['benefits'] + tech['parts_involved']
|
||||
for k in keywords:
|
||||
if k in disease_query or disease_query in k:
|
||||
results["exercise_remedy"].append(f"Practice {tech['name']} (Targeting: {k})")
|
||||
|
||||
return results
|
||||
|
||||
if __name__ == "__main__':
|
||||
import sys
|
||||
query = sys.argv[1] if len(sys.argv) > 1 else "肩"
|
||||
c_path = "/home/songyi/Documents/ai_agent_scraper_study/data/大医网/索引_药膳疾病关联_cleaned.json"
|
||||
e_path = "/home/songyi/Documents/ai_agent_scraper_study/data/大医网/索引_导引运动处_technique.json"
|
||||
|
||||
import sys
|
||||
sys.path.append(os.path.dirname(os.path.abspath(__file__)))
|
||||
|
||||
print(f"--- Recommendation for: {query} ---")
|
||||
print(json.dumps(recommend(query, c_path, e_path), ensure_ascii=int(0), indent=2))
|
||||
|
||||
Reference in new issue
Block a user