-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconfig.py
More file actions
85 lines (85 loc) · 4.47 KB
/
config.py
File metadata and controls
85 lines (85 loc) · 4.47 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
GRAPH_TEMPLATE = {
'desc': {
'slots': ['disease'],
'question': '什么叫%disease%? / %disease%是一种什么病?',
'cypher': "MATCH (n:Disease) WHERE n.name='%disease%' RETURN n.desc AS RES",
'answer': '【%disease%】的定义:%RES%',
},
'cause': {
'slots': ['disease'],
'question': '%disease%一般是由什么引起的?/ 什么会导致%disease%?',
'cypher': "MATCH (n:Disease) WHERE n.name='%disease%' RETURN n.cause AS RES",
'answer': '【%disease%】的病因:%RES%',
},
'disease_symptom': {
'slots': ['disease'],
'question': '%disease%会有哪些症状?/ %disease%有哪些临床表现?',
'cypher': "MATCH (n:Disease)-[:DISEASE_SYMPTOM]->(m) WHERE n.name='%disease%' RETURN SUBSTRING(REDUCE(s = '', x IN COLLECT(m.name) | s + '、' + x), 1) AS RES",
'answer': '【%disease%】的症状:%RES%',
},
'symptom': {
'slots': ['symptom'],
'question': '%symptom%可能是得了什么病?',
'cypher': "MATCH (n)-[:DISEASE_SYMPTOM]->(m:Symptom) WHERE m.name='%symptom%' RETURN SUBSTRING(REDUCE(s = '', x IN COLLECT(n.name) | s + '、' + x), 1) AS RES",
'answer': '可能出现【%symptom%】症状的疾病:%RES%',
},
'cure_way': {
'slots': ['disease'],
'question': '%disease%吃什么药好得快?/ %disease%怎么治?',
'cypher': '''
MATCH (n:Disease)-[:DISEASE_CUREWAY]->(m1),
(n:Disease)-[:DISEASE_DRUG]->(m2),
(n:Disease)-[:DISEASE_DO_EAT]->(m3)
WHERE n.name = '%disease%'
WITH COLLECT(DISTINCT m1.name) AS m1Names,
COLLECT(DISTINCT m2.name) AS m2Names,
COLLECT(DISTINCT m3.name) AS m3Names
RETURN SUBSTRING(REDUCE(s = '', x IN m1Names | s + '、' + x), 1) AS RES1,
SUBSTRING(REDUCE(s = '', x IN m2Names | s + '、' + x), 1) AS RES2,
SUBSTRING(REDUCE(s = '', x IN m3Names | s + '、' + x), 1) AS RES3
''',
'answer': '【%disease%】的治疗方法:%RES1%。\n可用药物:%RES2%。\n推荐食物:%RES3%',
},
'cure_department': {
'slots': ['disease'],
'question': '得了%disease%去医院挂什么科室的号?',
'cypher': "MATCH (n:Disease)-[:DISEASE_DEPARTMENT]->(m) WHERE n.name='%disease%' RETURN SUBSTRING(REDUCE(s = '', x IN COLLECT(m.name) | s + '、' + x), 1) AS RES",
'answer': '【%disease%】的就诊科室:%RES%',
},
'prevent': {
'slots': ['disease'],
'question': '%disease%要怎么预防?',
'cypher': "MATCH (n:Disease) WHERE n.name='%disease%' RETURN n.prevent AS RES",
'answer': '【%disease%】的预防方法:%RES%',
},
'not_eat': {
'slots': ['disease'],
'question': '%disease%换着有什么禁忌?/ %disease%不能吃什么?',
'cypher': "MATCH (n:Disease)-[:DISEASE_NOT_EAT]->(m) WHERE n.name='%disease%' RETURN SUBSTRING(REDUCE(s = '', x IN COLLECT(m.name) | s + '、' + x), 1) AS RES",
'answer': '【%disease%】的患者不能吃的食物:%RES%',
},
'check': {
'slots': ['disease'],
'question': '%disease%要做哪些检查?',
'cypher': "MATCH (n:Disease)-[:DISEASE_CHECK]->(m) WHERE n.name='%disease%' RETURN SUBSTRING(REDUCE(s = '', x IN COLLECT(m.name) | s + '、' + x), 1) AS RES",
'answer': '【%disease%】的检查项目:%RES%',
},
'cured_prob': {
'slots': ['disease'],
'question': '%disease%能治好吗?/ %disease%治好的几率有多大?',
'cypher': "MATCH (n:Disease) WHERE n.name='%disease%' RETURN n.cured_prob AS RES",
'answer': '【%disease%】的治愈率:%RES%',
},
'acompany': {
'slots': ['disease'],
'question': '%disease%的并发症有哪些?',
'cypher': "MATCH (n:Disease)-[:DISEASE_ACOMPANY]->(m) WHERE n.name='%disease%' RETURN SUBSTRING(REDUCE(s = '', x IN COLLECT(m.name) | s + '、' + x), 1) AS RES",
'answer': '【%disease%】的并发症:%RES%',
},
'indications': {
'slots': ['drug'],
'question': '%drug%能治那些病?',
'cypher': "MATCH (n:Disease)-[:DISEASE_DRUG]->(m:Drug) WHERE m.name='%drug%' RETURN SUBSTRING(REDUCE(s = '', x IN COLLECT(n.name) | s + '、' + x), 1) AS RES",
'answer': '【%drug%】能治疗的疾病有:%RES%',
},
}