Spaces:
Sleeping
Sleeping
Create CDRM.py
Browse files
CDRM.py
ADDED
@@ -0,0 +1,68 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# CDRM.py
|
2 |
+
# PLACEHOLDER FILE
|
3 |
+
# Contains all data, scoring logic, and setup specific to the
|
4 |
+
# Clinical Dementia Rating plus NACC FTLD (CDR Memory) assessment.
|
5 |
+
|
6 |
+
import time
|
7 |
+
from gtts import gTTS
|
8 |
+
import utils
|
9 |
+
|
10 |
+
# --- CDRM Specific Data (Placeholder) ---
|
11 |
+
now = utils.now
|
12 |
+
GROUPED_QUESTIONS = {
|
13 |
+
"Question 1: Memory": {
|
14 |
+
"Can you please tell me what the date is today?": {"answer": f"{now.strftime('%A')}, {now.strftime('%B')} {now.day}, {now.year}", "instruction": "Score 1 for fully correct, 0 for any error.", "max_points": 1},
|
15 |
+
"I will give you a name and address to remember. Please repeat it. John Brown, 42 Market Street, Boston.": {"answer": "john brown 42 market street boston", "instruction": "Repeat up to 3 times if necessary. This is for registration, not scoring.", "max_points": 0}
|
16 |
+
},
|
17 |
+
"Question 2: Orientation": {
|
18 |
+
"Who is the current president?": {"answer": "joe biden", "instruction": "Score 1 for correct, 0 for incorrect.", "max_points": 1}
|
19 |
+
}
|
20 |
+
}
|
21 |
+
|
22 |
+
# --- Derived Data Structures ---
|
23 |
+
STRUCTURED_QUESTIONS = []
|
24 |
+
main_num = 1
|
25 |
+
for section, questions in GROUPED_QUESTIONS.items():
|
26 |
+
main_cat_name = section.split(":", 1)[1].strip()
|
27 |
+
sub_q_idx = 0
|
28 |
+
for question, data in questions.items():
|
29 |
+
STRUCTURED_QUESTIONS.append({
|
30 |
+
"main_cat": main_cat_name, "main_num": main_num, "sub_letter": chr(ord('a') + sub_q_idx),
|
31 |
+
"question": question, "answer": data["answer"], "instruction": data.get("instruction", ""),
|
32 |
+
"max_points": data.get("max_points", 1)
|
33 |
+
})
|
34 |
+
sub_q_idx += 1
|
35 |
+
main_num += 1
|
36 |
+
|
37 |
+
TOTAL_QUESTIONS = len(STRUCTURED_QUESTIONS)
|
38 |
+
QUESTION_CHOICES = [f"Q{q['main_num']}{q['sub_letter']}: {q['question']}" for q in STRUCTURED_QUESTIONS]
|
39 |
+
|
40 |
+
# --- CDRM Specific Audio Handling ---
|
41 |
+
AUDIO_FILE_MAP = {}
|
42 |
+
def pregenerate_audio():
|
43 |
+
"""Pre-generates all TTS audio for CDRM questions."""
|
44 |
+
print("Pre-generating CDRM TTS audio...")
|
45 |
+
# This is a placeholder. In a real scenario, you'd generate audio like in MMSE.py
|
46 |
+
print("CDRM TTS audio pre-generation complete (Placeholder).")
|
47 |
+
|
48 |
+
def speak_question(current_index):
|
49 |
+
"""Placeholder for speaking a CDRM question."""
|
50 |
+
# In a real implementation, this would return a file path.
|
51 |
+
print(f"Speaking CDRM Question {current_index}: {STRUCTURED_QUESTIONS[current_index]['question']}")
|
52 |
+
return None
|
53 |
+
|
54 |
+
# --- Main Evaluation Logic (Placeholder) ---
|
55 |
+
def evaluate_CDRM(answers_list, user_drawing_path=None):
|
56 |
+
"""
|
57 |
+
Evaluates all CDRM answers and returns the results.
|
58 |
+
This is a dummy function and returns a fixed score.
|
59 |
+
"""
|
60 |
+
total_score = 1
|
61 |
+
total_possible_score = 2
|
62 |
+
results = [
|
63 |
+
"Q1a: Can you please tell me what the date is today?\n - Score: 1 / 1 | Your Answer: '[User Answer]' | Expected: '[Correct Date]'",
|
64 |
+
"Q2a: Who is the current president?\n - Score: 0 / 1 | Your Answer: '[User Answer]' | Expected: 'joe biden'"
|
65 |
+
]
|
66 |
+
return "\n\n".join(results), f"{total_score} / {total_possible_score}"
|
67 |
+
|
68 |
+
|