Spaces:
Sleeping
Sleeping
Update annotated_casl_app.py
Browse files- annotated_casl_app.py +181 -92
annotated_casl_app.py
CHANGED
|
@@ -182,13 +182,24 @@ def call_claude_api(prompt):
|
|
| 182 |
return call_claude_api_quick_analysis(prompt)
|
| 183 |
|
| 184 |
def answer_quick_question(transcript_content, question, age, gender, slp_notes):
|
| 185 |
-
"""Answer a specific question about the transcript quickly"""
|
| 186 |
if not transcript_content or len(transcript_content.strip()) < 20:
|
| 187 |
return "Error: Please provide a transcript for analysis."
|
| 188 |
|
| 189 |
if not question or len(question.strip()) < 5:
|
| 190 |
return "Error: Please provide a specific question."
|
| 191 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 192 |
# Add SLP notes to the prompt if provided
|
| 193 |
notes_section = ""
|
| 194 |
if slp_notes and slp_notes.strip():
|
|
@@ -201,14 +212,24 @@ def answer_quick_question(transcript_content, question, age, gender, slp_notes):
|
|
| 201 |
prompt = f"""
|
| 202 |
You are a speech-language pathologist answering a specific question about a speech sample.
|
| 203 |
|
| 204 |
-
TRANSCRIPT:
|
| 205 |
-
{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 206 |
|
| 207 |
QUESTION: {question}
|
| 208 |
|
| 209 |
INSTRUCTIONS:
|
| 210 |
Provide a focused, detailed answer to the specific question asked
|
| 211 |
Include specific examples from the transcript with exact quotes
|
|
|
|
| 212 |
Provide quantitative data when relevant (counts, percentages, rates)
|
| 213 |
Provide objective data interpretation only
|
| 214 |
Keep the response focused on the question but thorough in analysis
|
|
@@ -221,10 +242,21 @@ def answer_quick_question(transcript_content, question, age, gender, slp_notes):
|
|
| 221 |
return call_claude_api_quick_analysis(prompt)
|
| 222 |
|
| 223 |
def analyze_targeted_area(transcript_content, analysis_area, age, gender, slp_notes):
|
| 224 |
-
"""Perform targeted analysis of a specific area"""
|
| 225 |
if not transcript_content or len(transcript_content.strip()) < 20:
|
| 226 |
return "Error: Please provide a transcript for analysis."
|
| 227 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 228 |
# Add SLP notes to the prompt if provided
|
| 229 |
notes_section = ""
|
| 230 |
if slp_notes and slp_notes.strip():
|
|
@@ -237,198 +269,255 @@ def analyze_targeted_area(transcript_content, analysis_area, age, gender, slp_no
|
|
| 237 |
# Define analysis prompts for different areas
|
| 238 |
analysis_prompts = {
|
| 239 |
"Fluency and Disfluencies": """
|
| 240 |
-
Conduct a comprehensive FLUENCY ANALYSIS
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 241 |
|
| 242 |
1. DISFLUENCY TYPES AND COUNTS:
|
| 243 |
-
Count
|
| 244 |
-
|
| 245 |
-
|
| 246 |
-
Count and quote ALL revisions and restarts
|
| 247 |
-
Count and quote ALL prolongations or blocks (if noted)
|
| 248 |
|
| 249 |
2. DISFLUENCY PATTERNS:
|
| 250 |
-
|
| 251 |
-
|
| 252 |
-
Analyze clustering patterns
|
| 253 |
Assess impact on communication effectiveness
|
| 254 |
|
| 255 |
3. FLUENCY FACILITATORS:
|
| 256 |
-
Identify fluent segments
|
| 257 |
-
Note
|
| 258 |
Assess overall speech rhythm and flow
|
| 259 |
|
| 260 |
4. OBJECTIVE SUMMARY:
|
| 261 |
-
Provide data summary
|
| 262 |
-
List observed patterns
|
| 263 |
|
| 264 |
-
|
| 265 |
""",
|
| 266 |
|
| 267 |
"Grammar and Syntax": """
|
| 268 |
-
Conduct a comprehensive GRAMMATICAL ANALYSIS
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 269 |
|
| 270 |
1. MORPHOLOGICAL ANALYSIS:
|
| 271 |
-
Count and categorize
|
| 272 |
-
Identify
|
| 273 |
-
Analyze
|
| 274 |
|
| 275 |
2. SYNTACTIC STRUCTURES:
|
| 276 |
-
Analyze
|
| 277 |
-
Count and
|
| 278 |
-
Assess word order
|
| 279 |
-
Evaluate
|
| 280 |
|
| 281 |
3. VERB USAGE:
|
| 282 |
-
|
|
|
|
| 283 |
Count subject-verb agreement errors
|
| 284 |
-
Assess auxiliary verb usage
|
| 285 |
|
| 286 |
4. OBJECTIVE SUMMARY:
|
| 287 |
List primary grammatical patterns observed
|
| 288 |
-
Provide data
|
| 289 |
|
| 290 |
-
|
| 291 |
""",
|
| 292 |
|
| 293 |
"Vocabulary and Semantics": """
|
| 294 |
-
Conduct a comprehensive VOCABULARY ANALYSIS
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 295 |
|
| 296 |
1. LEXICAL DIVERSITY:
|
| 297 |
-
|
| 298 |
-
|
| 299 |
-
|
| 300 |
|
| 301 |
2. SEMANTIC ACCURACY:
|
| 302 |
-
|
| 303 |
-
|
| 304 |
-
|
|
|
|
| 305 |
|
| 306 |
3. VOCABULARY CATEGORIES:
|
| 307 |
-
|
| 308 |
-
Identify high-frequency vs. low-frequency
|
| 309 |
-
Assess
|
| 310 |
|
| 311 |
4. WORD RETRIEVAL:
|
| 312 |
-
Count
|
| 313 |
Identify compensatory strategies
|
| 314 |
-
Assess
|
| 315 |
|
| 316 |
5. OBJECTIVE SUMMARY:
|
| 317 |
-
List vocabulary patterns observed
|
| 318 |
Provide data summary only
|
| 319 |
|
| 320 |
-
|
| 321 |
""",
|
| 322 |
|
| 323 |
"Pragmatics and Discourse": """
|
| 324 |
-
Conduct a comprehensive PRAGMATIC ANALYSIS
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 325 |
|
| 326 |
1. DISCOURSE ORGANIZATION:
|
| 327 |
-
|
| 328 |
Assess narrative structure and coherence
|
| 329 |
-
Evaluate logical sequencing
|
| 330 |
|
| 331 |
2. CONVERSATIONAL SKILLS:
|
| 332 |
-
|
| 333 |
-
|
| 334 |
-
Evaluate
|
| 335 |
|
| 336 |
3. REFERENTIAL COMMUNICATION:
|
| 337 |
-
Count
|
| 338 |
-
Assess
|
| 339 |
-
Evaluate
|
| 340 |
|
| 341 |
4. PRAGMATIC APPROPRIATENESS:
|
| 342 |
-
|
| 343 |
-
Assess contextual appropriateness
|
| 344 |
-
Evaluate social awareness
|
| 345 |
|
| 346 |
5. OBJECTIVE SUMMARY:
|
| 347 |
-
List pragmatic patterns observed
|
| 348 |
Provide data summary only
|
| 349 |
|
| 350 |
-
|
| 351 |
""",
|
| 352 |
|
| 353 |
"Sentence Complexity": """
|
| 354 |
-
Conduct a comprehensive SENTENCE COMPLEXITY ANALYSIS
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 355 |
|
| 356 |
1. SENTENCE TYPES:
|
| 357 |
-
Count
|
| 358 |
-
|
| 359 |
-
|
| 360 |
|
| 361 |
2. CLAUSE ANALYSIS:
|
| 362 |
-
|
| 363 |
-
|
| 364 |
-
Assess coordination
|
| 365 |
|
| 366 |
3. PHRASE STRUCTURES:
|
| 367 |
-
Analyze
|
| 368 |
-
Assess
|
| 369 |
Evaluate prepositional phrase usage
|
| 370 |
|
| 371 |
4. SYNTACTIC MATURITY:
|
| 372 |
-
Calculate Mean Length of Utterance (MLU)
|
| 373 |
List syntactic patterns observed
|
| 374 |
|
| 375 |
5. OBJECTIVE SUMMARY:
|
| 376 |
-
Provide complexity data
|
| 377 |
List observed patterns only
|
| 378 |
|
| 379 |
-
|
| 380 |
""",
|
| 381 |
|
| 382 |
"Word Finding and Retrieval": """
|
| 383 |
-
Conduct a comprehensive WORD RETRIEVAL ANALYSIS
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 384 |
|
| 385 |
1. WORD-FINDING DIFFICULTIES:
|
| 386 |
-
Count
|
| 387 |
-
|
| 388 |
-
|
| 389 |
|
| 390 |
2. RETRIEVAL STRATEGIES:
|
| 391 |
-
Identify compensatory strategies
|
| 392 |
-
Analyze self-cueing attempts
|
| 393 |
-
Assess success rate
|
| 394 |
|
| 395 |
3. ERROR PATTERNS:
|
| 396 |
-
Categorize word-finding
|
| 397 |
Identify semantic vs. phonological retrieval issues
|
| 398 |
Analyze error consistency patterns
|
| 399 |
|
| 400 |
4. CONTEXTUAL FACTORS:
|
| 401 |
-
Identify contexts that
|
| 402 |
-
Assess impact
|
| 403 |
-
Evaluate
|
| 404 |
|
| 405 |
5. OBJECTIVE SUMMARY:
|
| 406 |
-
List word-finding patterns observed
|
| 407 |
Provide data summary only
|
| 408 |
|
| 409 |
-
|
| 410 |
"""
|
| 411 |
}
|
| 412 |
|
| 413 |
if analysis_area not in analysis_prompts:
|
| 414 |
return f"Error: Analysis area '{analysis_area}' not recognized. Available areas: {', '.join(analysis_prompts.keys())}"
|
| 415 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 416 |
prompt = f"""
|
| 417 |
You are a speech-language pathologist conducting a targeted analysis of a specific area.
|
| 418 |
|
| 419 |
-
TRANSCRIPT:
|
| 420 |
-
{transcript_content}{notes_section}
|
| 421 |
-
|
| 422 |
ANALYSIS FOCUS: {analysis_area}
|
| 423 |
|
| 424 |
-
{
|
| 425 |
|
| 426 |
INSTRUCTIONS:
|
| 427 |
-
|
| 428 |
-
|
| 429 |
-
|
| 430 |
-
|
| 431 |
-
|
| 432 |
|
| 433 |
Conduct the targeted analysis:
|
| 434 |
"""
|
|
|
|
| 182 |
return call_claude_api_quick_analysis(prompt)
|
| 183 |
|
| 184 |
def answer_quick_question(transcript_content, question, age, gender, slp_notes):
|
| 185 |
+
"""Answer a specific question about the transcript quickly using annotated version for accuracy"""
|
| 186 |
if not transcript_content or len(transcript_content.strip()) < 20:
|
| 187 |
return "Error: Please provide a transcript for analysis."
|
| 188 |
|
| 189 |
if not question or len(question.strip()) < 5:
|
| 190 |
return "Error: Please provide a specific question."
|
| 191 |
|
| 192 |
+
# First, annotate the transcript to get accurate markers
|
| 193 |
+
logger.info("Annotating transcript for accurate question answering...")
|
| 194 |
+
annotated_transcript = annotate_transcript(transcript_content, age, gender, slp_notes)
|
| 195 |
+
|
| 196 |
+
# Check if annotation was successful
|
| 197 |
+
if annotated_transcript.startswith("Error") or annotated_transcript.startswith("ANNOTATION INCOMPLETE"):
|
| 198 |
+
logger.warning("Using original transcript due to annotation issues")
|
| 199 |
+
analysis_transcript = transcript_content
|
| 200 |
+
else:
|
| 201 |
+
analysis_transcript = annotated_transcript
|
| 202 |
+
|
| 203 |
# Add SLP notes to the prompt if provided
|
| 204 |
notes_section = ""
|
| 205 |
if slp_notes and slp_notes.strip():
|
|
|
|
| 212 |
prompt = f"""
|
| 213 |
You are a speech-language pathologist answering a specific question about a speech sample.
|
| 214 |
|
| 215 |
+
TRANSCRIPT (with annotation markers for reference):
|
| 216 |
+
{analysis_transcript}{notes_section}
|
| 217 |
+
|
| 218 |
+
ANNOTATION MARKER REFERENCE:
|
| 219 |
+
FLUENCY: [FILLER], [FALSE_START], [REPETITION], [REVISION], [PAUSE]
|
| 220 |
+
WORD RETRIEVAL: [CIRCUMLOCUTION], [INCOMPLETE], [GENERIC], [WORD_SEARCH]
|
| 221 |
+
GRAMMAR: [GRAM_ERROR], [SYNTAX_ERROR], [MORPH_ERROR], [RUN_ON]
|
| 222 |
+
VOCABULARY: [SIMPLE_VOCAB], [COMPLEX_VOCAB], [SEMANTIC_ERROR]
|
| 223 |
+
PRAGMATICS: [TOPIC_SHIFT], [TANGENT], [INAPPROPRIATE], [COHERENCE_BREAK]
|
| 224 |
+
SENTENCE STRUCTURE: [SIMPLE_SENT], [COMPLEX_SENT], [COMPOUND_SENT], [FIGURATIVE]
|
| 225 |
+
OTHER: [PRONOUN_REF], [MAZING], [PERSEVERATION]
|
| 226 |
|
| 227 |
QUESTION: {question}
|
| 228 |
|
| 229 |
INSTRUCTIONS:
|
| 230 |
Provide a focused, detailed answer to the specific question asked
|
| 231 |
Include specific examples from the transcript with exact quotes
|
| 232 |
+
Use the annotation markers to identify and count specific features accurately
|
| 233 |
Provide quantitative data when relevant (counts, percentages, rates)
|
| 234 |
Provide objective data interpretation only
|
| 235 |
Keep the response focused on the question but thorough in analysis
|
|
|
|
| 242 |
return call_claude_api_quick_analysis(prompt)
|
| 243 |
|
| 244 |
def analyze_targeted_area(transcript_content, analysis_area, age, gender, slp_notes):
|
| 245 |
+
"""Perform targeted analysis of a specific area using annotated transcript for accuracy"""
|
| 246 |
if not transcript_content or len(transcript_content.strip()) < 20:
|
| 247 |
return "Error: Please provide a transcript for analysis."
|
| 248 |
|
| 249 |
+
# First, annotate the transcript to get accurate markers
|
| 250 |
+
logger.info("Annotating transcript for accurate analysis...")
|
| 251 |
+
annotated_transcript = annotate_transcript(transcript_content, age, gender, slp_notes)
|
| 252 |
+
|
| 253 |
+
# Check if annotation was successful
|
| 254 |
+
if annotated_transcript.startswith("Error") or annotated_transcript.startswith("ANNOTATION INCOMPLETE"):
|
| 255 |
+
logger.warning("Using original transcript due to annotation issues")
|
| 256 |
+
analysis_transcript = transcript_content
|
| 257 |
+
else:
|
| 258 |
+
analysis_transcript = annotated_transcript
|
| 259 |
+
|
| 260 |
# Add SLP notes to the prompt if provided
|
| 261 |
notes_section = ""
|
| 262 |
if slp_notes and slp_notes.strip():
|
|
|
|
| 269 |
# Define analysis prompts for different areas
|
| 270 |
analysis_prompts = {
|
| 271 |
"Fluency and Disfluencies": """
|
| 272 |
+
Conduct a comprehensive FLUENCY ANALYSIS using annotation markers as reference.
|
| 273 |
+
|
| 274 |
+
TRANSCRIPT WITH ANNOTATION MARKERS:
|
| 275 |
+
{analysis_transcript}{notes_section}
|
| 276 |
+
|
| 277 |
+
MARKER REFERENCE:
|
| 278 |
+
[FILLER] = filler words (um, uh, like, you know, etc.)
|
| 279 |
+
[FALSE_START] = false starts and self-corrections
|
| 280 |
+
[REPETITION] = word/phrase repetitions
|
| 281 |
+
[REVISION] = revisions and restarts
|
| 282 |
+
[PAUSE] = hesitations and pauses
|
| 283 |
|
| 284 |
1. DISFLUENCY TYPES AND COUNTS:
|
| 285 |
+
Count each marker type precisely from the annotated transcript
|
| 286 |
+
Provide exact quotes showing each marker
|
| 287 |
+
Calculate rates per 100 words
|
|
|
|
|
|
|
| 288 |
|
| 289 |
2. DISFLUENCY PATTERNS:
|
| 290 |
+
Identify most frequent disfluency types by count
|
| 291 |
+
Analyze clustering patterns where disfluencies concentrate
|
|
|
|
| 292 |
Assess impact on communication effectiveness
|
| 293 |
|
| 294 |
3. FLUENCY FACILITATORS:
|
| 295 |
+
Identify fluent segments with no markers
|
| 296 |
+
Note contexts that show high fluency
|
| 297 |
Assess overall speech rhythm and flow
|
| 298 |
|
| 299 |
4. OBJECTIVE SUMMARY:
|
| 300 |
+
Provide data summary with counts and rates
|
| 301 |
+
List observed patterns only
|
| 302 |
|
| 303 |
+
Do NOT use asterisks (**), hashtags (#), or bold formatting. Use plain text only.
|
| 304 |
""",
|
| 305 |
|
| 306 |
"Grammar and Syntax": """
|
| 307 |
+
Conduct a comprehensive GRAMMATICAL ANALYSIS using annotation markers as reference.
|
| 308 |
+
|
| 309 |
+
TRANSCRIPT WITH ANNOTATION MARKERS:
|
| 310 |
+
{analysis_transcript}{notes_section}
|
| 311 |
+
|
| 312 |
+
MARKER REFERENCE:
|
| 313 |
+
[GRAM_ERROR] = grammatical errors
|
| 314 |
+
[SYNTAX_ERROR] = word order/syntax problems
|
| 315 |
+
[MORPH_ERROR] = morphological errors (plurals, tense, etc.)
|
| 316 |
+
[RUN_ON] = run-on sentences
|
| 317 |
|
| 318 |
1. MORPHOLOGICAL ANALYSIS:
|
| 319 |
+
Count [MORPH_ERROR] markers and categorize by type
|
| 320 |
+
Identify patterns in morphological errors
|
| 321 |
+
Analyze error frequency
|
| 322 |
|
| 323 |
2. SYNTACTIC STRUCTURES:
|
| 324 |
+
Analyze [SIMPLE_SENT], [COMPOUND_SENT], [COMPLEX_SENT] markers
|
| 325 |
+
Count [SYNTAX_ERROR] and [GRAM_ERROR] markers
|
| 326 |
+
Assess word order patterns
|
| 327 |
+
Evaluate conjunction and subordination use
|
| 328 |
|
| 329 |
3. VERB USAGE:
|
| 330 |
+
Identify [GRAM_ERROR] markers related to verbs
|
| 331 |
+
Analyze tense consistency
|
| 332 |
Count subject-verb agreement errors
|
|
|
|
| 333 |
|
| 334 |
4. OBJECTIVE SUMMARY:
|
| 335 |
List primary grammatical patterns observed
|
| 336 |
+
Provide count data only
|
| 337 |
|
| 338 |
+
Do NOT use asterisks (**), hashtags (#), or bold formatting. Use plain text only.
|
| 339 |
""",
|
| 340 |
|
| 341 |
"Vocabulary and Semantics": """
|
| 342 |
+
Conduct a comprehensive VOCABULARY ANALYSIS using annotation markers as reference.
|
| 343 |
+
|
| 344 |
+
TRANSCRIPT WITH ANNOTATION MARKERS:
|
| 345 |
+
{analysis_transcript}{notes_section}
|
| 346 |
+
|
| 347 |
+
MARKER REFERENCE:
|
| 348 |
+
[SIMPLE_VOCAB] = basic/high-frequency words
|
| 349 |
+
[COMPLEX_VOCAB] = sophisticated/low-frequency words
|
| 350 |
+
[SEMANTIC_ERROR] = inappropriate word choices
|
| 351 |
+
[GENERIC] = vague terms (thing, stuff)
|
| 352 |
+
[CIRCUMLOCUTION] = roundabout descriptions
|
| 353 |
+
[WORD_SEARCH] = explicit word-finding attempts
|
| 354 |
|
| 355 |
1. LEXICAL DIVERSITY:
|
| 356 |
+
Count [SIMPLE_VOCAB] and [COMPLEX_VOCAB] markers
|
| 357 |
+
Calculate vocabulary sophistication ratio
|
| 358 |
+
Identify vocabulary diversity patterns
|
| 359 |
|
| 360 |
2. SEMANTIC ACCURACY:
|
| 361 |
+
Count [SEMANTIC_ERROR] markers with quotes
|
| 362 |
+
Identify [GENERIC] term usage
|
| 363 |
+
Count [CIRCUMLOCUTION] and [WORD_SEARCH] markers
|
| 364 |
+
Assess word precision
|
| 365 |
|
| 366 |
3. VOCABULARY CATEGORIES:
|
| 367 |
+
Analyze patterns in vocabulary type markers
|
| 368 |
+
Identify high-frequency vs. low-frequency word usage
|
| 369 |
+
Assess conversational vs. academic vocabulary
|
| 370 |
|
| 371 |
4. WORD RETRIEVAL:
|
| 372 |
+
Count word-finding difficulties [WORD_SEARCH], [CIRCUMLOCUTION], [GENERIC]
|
| 373 |
Identify compensatory strategies
|
| 374 |
+
Assess retrieval efficiency by frequency
|
| 375 |
|
| 376 |
5. OBJECTIVE SUMMARY:
|
| 377 |
+
List vocabulary patterns observed with counts
|
| 378 |
Provide data summary only
|
| 379 |
|
| 380 |
+
Do NOT use asterisks (**), hashtags (#), or bold formatting. Use plain text only.
|
| 381 |
""",
|
| 382 |
|
| 383 |
"Pragmatics and Discourse": """
|
| 384 |
+
Conduct a comprehensive PRAGMATIC ANALYSIS using annotation markers as reference.
|
| 385 |
+
|
| 386 |
+
TRANSCRIPT WITH ANNOTATION MARKERS:
|
| 387 |
+
{analysis_transcript}{notes_section}
|
| 388 |
+
|
| 389 |
+
MARKER REFERENCE:
|
| 390 |
+
[TOPIC_SHIFT] = topic changes
|
| 391 |
+
[TANGENT] = tangential/off-topic speech
|
| 392 |
+
[INAPPROPRIATE] = inappropriate content
|
| 393 |
+
[COHERENCE_BREAK] = incoherent statements
|
| 394 |
+
[PRONOUN_REF] = unclear pronoun references
|
| 395 |
|
| 396 |
1. DISCOURSE ORGANIZATION:
|
| 397 |
+
Count [TOPIC_SHIFT] and [TANGENT] markers
|
| 398 |
Assess narrative structure and coherence
|
| 399 |
+
Evaluate logical idea sequencing
|
| 400 |
|
| 401 |
2. CONVERSATIONAL SKILLS:
|
| 402 |
+
Analyze topic maintenance between [TOPIC_SHIFT] markers
|
| 403 |
+
Assess response appropriateness
|
| 404 |
+
Evaluate communication effectiveness
|
| 405 |
|
| 406 |
3. REFERENTIAL COMMUNICATION:
|
| 407 |
+
Count [PRONOUN_REF] markers
|
| 408 |
+
Assess clarity of pronoun use
|
| 409 |
+
Evaluate referential precision
|
| 410 |
|
| 411 |
4. PRAGMATIC APPROPRIATENESS:
|
| 412 |
+
Count [INAPPROPRIATE] markers if present
|
| 413 |
+
Assess contextual appropriateness of content
|
| 414 |
+
Evaluate social communication awareness
|
| 415 |
|
| 416 |
5. OBJECTIVE SUMMARY:
|
| 417 |
+
List pragmatic patterns observed with marker counts
|
| 418 |
Provide data summary only
|
| 419 |
|
| 420 |
+
Do NOT use asterisks (**), hashtags (#), or bold formatting. Use plain text only.
|
| 421 |
""",
|
| 422 |
|
| 423 |
"Sentence Complexity": """
|
| 424 |
+
Conduct a comprehensive SENTENCE COMPLEXITY ANALYSIS using annotation markers as reference.
|
| 425 |
+
|
| 426 |
+
TRANSCRIPT WITH ANNOTATION MARKERS:
|
| 427 |
+
{analysis_transcript}{notes_section}
|
| 428 |
+
|
| 429 |
+
MARKER REFERENCE:
|
| 430 |
+
[SIMPLE_SENT] = simple sentences
|
| 431 |
+
[COMPOUND_SENT] = compound sentences
|
| 432 |
+
[COMPLEX_SENT] = complex sentences
|
| 433 |
+
[FIGURATIVE] = figurative language/idioms
|
| 434 |
|
| 435 |
1. SENTENCE TYPES:
|
| 436 |
+
Count [SIMPLE_SENT], [COMPOUND_SENT], [COMPLEX_SENT] markers
|
| 437 |
+
Calculate percentage distribution of each type
|
| 438 |
+
Provide examples of each type
|
| 439 |
|
| 440 |
2. CLAUSE ANALYSIS:
|
| 441 |
+
Analyze clause density from complex sentence markers
|
| 442 |
+
Count subordinate and coordinate clause patterns
|
| 443 |
+
Assess coordination and subordination use
|
| 444 |
|
| 445 |
3. PHRASE STRUCTURES:
|
| 446 |
+
Analyze complexity patterns within sentence markers
|
| 447 |
+
Assess phrase elaboration levels
|
| 448 |
Evaluate prepositional phrase usage
|
| 449 |
|
| 450 |
4. SYNTACTIC MATURITY:
|
| 451 |
+
Calculate Mean Length of Utterance (MLU) from sentence length patterns
|
| 452 |
List syntactic patterns observed
|
| 453 |
|
| 454 |
5. OBJECTIVE SUMMARY:
|
| 455 |
+
Provide complexity data with counts and percentages
|
| 456 |
List observed patterns only
|
| 457 |
|
| 458 |
+
Do NOT use asterisks (**), hashtags (#), or bold formatting. Use plain text only.
|
| 459 |
""",
|
| 460 |
|
| 461 |
"Word Finding and Retrieval": """
|
| 462 |
+
Conduct a comprehensive WORD RETRIEVAL ANALYSIS using annotation markers as reference.
|
| 463 |
+
|
| 464 |
+
TRANSCRIPT WITH ANNOTATION MARKERS:
|
| 465 |
+
{analysis_transcript}{notes_section}
|
| 466 |
+
|
| 467 |
+
MARKER REFERENCE:
|
| 468 |
+
[WORD_SEARCH] = explicit word-finding attempts
|
| 469 |
+
[CIRCUMLOCUTION] = roundabout descriptions as workarounds
|
| 470 |
+
[GENERIC] = vague terms (thing, stuff, whatsit)
|
| 471 |
+
[INCOMPLETE] = abandoned thoughts/word-finding failures
|
| 472 |
|
| 473 |
1. WORD-FINDING DIFFICULTIES:
|
| 474 |
+
Count [WORD_SEARCH], [CIRCUMLOCUTION], [GENERIC], [INCOMPLETE] markers
|
| 475 |
+
Provide exact quotes showing each type
|
| 476 |
+
Calculate frequency of each difficulty type
|
| 477 |
|
| 478 |
2. RETRIEVAL STRATEGIES:
|
| 479 |
+
Identify compensatory strategies from marker patterns
|
| 480 |
+
Analyze self-cueing attempts marked with [WORD_SEARCH]
|
| 481 |
+
Assess success rate from [CIRCUMLOCUTION] effectiveness
|
| 482 |
|
| 483 |
3. ERROR PATTERNS:
|
| 484 |
+
Categorize word-finding issues by marker type
|
| 485 |
Identify semantic vs. phonological retrieval issues
|
| 486 |
Analyze error consistency patterns
|
| 487 |
|
| 488 |
4. CONTEXTUAL FACTORS:
|
| 489 |
+
Identify contexts that show high [WORD_SEARCH] density
|
| 490 |
+
Assess topic complexity impact on word retrieval
|
| 491 |
+
Evaluate linguistic complexity effects
|
| 492 |
|
| 493 |
5. OBJECTIVE SUMMARY:
|
| 494 |
+
List word-finding patterns observed with marker counts
|
| 495 |
Provide data summary only
|
| 496 |
|
| 497 |
+
Do NOT use asterisks (**), hashtags (#), or bold formatting. Use plain text only.
|
| 498 |
"""
|
| 499 |
}
|
| 500 |
|
| 501 |
if analysis_area not in analysis_prompts:
|
| 502 |
return f"Error: Analysis area '{analysis_area}' not recognized. Available areas: {', '.join(analysis_prompts.keys())}"
|
| 503 |
|
| 504 |
+
# Get the base prompt and insert the analysis transcript
|
| 505 |
+
base_prompt_template = analysis_prompts[analysis_area]
|
| 506 |
+
base_prompt = base_prompt_template.format(analysis_transcript=analysis_transcript, notes_section=notes_section)
|
| 507 |
+
|
| 508 |
prompt = f"""
|
| 509 |
You are a speech-language pathologist conducting a targeted analysis of a specific area.
|
| 510 |
|
|
|
|
|
|
|
|
|
|
| 511 |
ANALYSIS FOCUS: {analysis_area}
|
| 512 |
|
| 513 |
+
{base_prompt}
|
| 514 |
|
| 515 |
INSTRUCTIONS:
|
| 516 |
+
Provide specific examples with exact quotes from the transcript
|
| 517 |
+
Include quantitative data using marker counts and percentages
|
| 518 |
+
Provide objective data interpretation only
|
| 519 |
+
Focus on measurable observations
|
| 520 |
+
Be thorough but focused on the specified area
|
| 521 |
|
| 522 |
Conduct the targeted analysis:
|
| 523 |
"""
|