-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcreate_m2_data.py
More file actions
75 lines (67 loc) · 3.41 KB
/
Copy pathcreate_m2_data.py
File metadata and controls
75 lines (67 loc) · 3.41 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
import json
import os
print("🔧 建立 M2 病程階段模組...")
# 確保目錄存在
os.makedirs('../data/chunks', exist_ok=True)
# M2 病程階段知識片段
m2_chunks = [
{
"chunk_id": "M2-01",
"module_id": "M2",
"chunk_type": "stage_description",
"title": "輕度失智症階段特徵",
"content": "患者在熟悉環境中仍可獨立生活,但在複雜任務上需要協助。認知能力有輕微記憶缺損,主要影響近期記憶。日常生活基本活動多數可自理,但複雜活動如理財、購物需要監督。照護重點:建立規律作息、安全環境、認知刺激活動。",
"keywords": ["輕度", "獨立生活", "複雜任務", "監督", "規律作息"],
"confidence_score": 0.92,
"source": "CDR量表與照護指引"
},
{
"chunk_id": "M2-02",
"module_id": "M2",
"chunk_type": "stage_description",
"title": "中度失智症階段特徵",
"content": "明顯認知功能衰退,日常生活需要相當程度協助。記憶力顯著下降,時空混亂常見。基本活動需要提醒或協助,複雜活動無法獨立完成。可能出現遊走、重複行為、睡眠障礙、情緒不穩。需要協助穿衣、容易迷路。",
"keywords": ["中度", "認知衰退", "協助", "穿衣", "迷路", "睡眠障礙", "遊走"],
"confidence_score": 0.90,
"source": "CDR量表與照護指引"
},
{
"chunk_id": "M2-03",
"module_id": "M2",
"chunk_type": "stage_description",
"title": "重度失智症階段特徵",
"content": "嚴重認知功能缺損,日常生活完全依賴他人。嚴重記憶喪失,無法辨識親人,語言能力大幅退化。所有基本活動需要協助,可能出現吞嚥困難、行動障礙。照護重點:全面性照護、舒適照護、感染預防。",
"keywords": ["重度", "完全依賴", "無法辨識", "吞嚥困難", "全面照護"],
"confidence_score": 0.88,
"source": "CDR量表與照護指引"
},
{
"chunk_id": "M2-04",
"module_id": "M2",
"chunk_type": "care_guidance",
"title": "病程階段照護指引",
"content": "不同階段需要不同照護策略。輕度階段重點維持獨立性,中度階段注重安全與行為管理,重度階段著重舒適照護。照護者應了解各階段特徵,提前規劃照護資源,並注意自身身心健康。",
"keywords": ["照護指引", "階段策略", "獨立性", "安全管理", "舒適照護"],
"confidence_score": 0.85,
"source": "照護指導手冊"
}
]
# 儲存為 JSONL 格式
output_file = '../data/chunks/m2_stage_chunks.jsonl'
with open(output_file, 'w', encoding='utf-8') as f:
for chunk in m2_chunks:
f.write(json.dumps(chunk, ensure_ascii=False) + '\n')
print(f"✅ 成功建立 {len(m2_chunks)} 個 M2 知識片段")
print(f"📁 檔案位置: {output_file}")
# 驗證檔案
if os.path.exists(output_file):
with open(output_file, 'r', encoding='utf-8') as f:
lines = f.readlines()
print(f"📊 檔案驗證: {len(lines)} 行資料")
# 顯示第一個 chunk
if lines:
first_chunk = json.loads(lines[0])
print(f"📋 第一個片段: {first_chunk['chunk_id']} - {first_chunk['title']}")
else:
print("❌ 檔案建立失敗")
print(f"\n🎯 M2 模組建立完成!")