1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253 |
- import sys,os
- current_path = os.getcwd()
- sys.path.append(current_path)
- from libs.graph_helper import GraphHelper
- graph_helper = GraphHelper()
- user_input = "腹痛 发热 腹泻"
- try:
- keywords = user_input.split(" ")
- start_nodes = []
- for keyword in keywords:
- results = graph_helper.node_search(
- keyword, limit=10, node_type="word"
- )
- for item in results:
- if item['score']>1.9:
- start_nodes.append(item['id'])
- print("cdss start from :", start_nodes)
- result = graph_helper.cdss_travel(start_nodes,max_hops=2)
-
- for item in result["details"]:
- name, data = item
- print(f"{name} {data['score'] *100:.2f} %")
- for disease in data["diseases"]:
- print(f"\t疾病:{disease[0]} ")
- for check in data["checks"]:
- print(f"\t检查:{check[0]} ")
- for drug in data["drugs"]:
- print(f"\t药品:{drug[0]} ")
- print("最终推荐的检查和药品如下:")
- for item in result["checks"][:5]:
- print(f"\t检查:{item[0]} {item[1]['count'] / result["total_checks"] * 100:.2f} %")
-
- for item in result["drugs"][:5]:
- print(f"\t药品:{item[0]} {item[1]['count'] / result["total_drugs"] * 100:.2f} %")
- #print(results)
- # results = graph_helper.node_search(
- # keyword,
- # limit=limit,
- # node_type=node_type,
- # min_degree=min_degree
- # )
- except Exception as e:
- raise e
|