Spaces:
Sleeping
Sleeping
Update annotated_casl_app.py
Browse files- annotated_casl_app.py +406 -377
annotated_casl_app.py
CHANGED
|
@@ -148,7 +148,7 @@ def call_claude_api_with_continuation(prompt, max_continuations=0):
|
|
| 148 |
}
|
| 149 |
|
| 150 |
data = {
|
| 151 |
-
"model": "claude-
|
| 152 |
"max_tokens": 4096,
|
| 153 |
"messages": [
|
| 154 |
{
|
|
@@ -278,7 +278,7 @@ def call_claude_api_quick_analysis(prompt):
|
|
| 278 |
}
|
| 279 |
|
| 280 |
data = {
|
| 281 |
-
"model": "claude-
|
| 282 |
"max_tokens": 4096,
|
| 283 |
"messages": [
|
| 284 |
{
|
|
@@ -729,103 +729,255 @@ def analyze_annotated_transcript(annotated_transcript, age, gender, slp_notes):
|
|
| 729 |
"""
|
| 730 |
|
| 731 |
analysis_prompt = f"""
|
| 732 |
-
You are a speech-language pathologist conducting a
|
| 733 |
|
| 734 |
Patient: {age}-year-old {gender}
|
| 735 |
|
| 736 |
ANNOTATED TRANSCRIPT:
|
| 737 |
{annotated_transcript}{notes_section}
|
| 738 |
|
| 739 |
-
|
| 740 |
-
|
| 741 |
-
|
| 742 |
-
|
| 743 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 744 |
|
| 745 |
-
|
| 746 |
|
| 747 |
-
|
| 748 |
-
-
|
| 749 |
-
|
| 750 |
-
|
| 751 |
-
|
| 752 |
-
-
|
| 753 |
-
-
|
| 754 |
-
-
|
| 755 |
|
| 756 |
-
|
| 757 |
-
- Count [CIRCUMLOCUTION] markers: List each roundabout description
|
| 758 |
-
- Count [INCOMPLETE] markers: Analyze abandoned thought patterns
|
| 759 |
-
- Count [GENERIC] markers: Calculate specificity ratio
|
| 760 |
-
- Count [WORD_SEARCH] markers: Identify retrieval difficulty areas
|
| 761 |
-
- Count [WORD_FINDING] markers: Assess overall retrieval efficiency
|
| 762 |
-
- Calculate word-finding accuracy percentage
|
| 763 |
-
|
| 764 |
-
3. GRAMMATICAL ANALYSIS (detailed error counting):
|
| 765 |
-
- Count [GRAM_ERROR] markers by subcategory:
|
| 766 |
-
* Verb tense errors
|
| 767 |
-
* Subject-verb agreement errors
|
| 768 |
-
* Pronoun errors
|
| 769 |
-
* Article errors
|
| 770 |
-
- Count [SYNTAX_ERROR] markers: Analyze word order problems
|
| 771 |
-
- Count [MORPH_ERROR] markers: Categorize morphological mistakes
|
| 772 |
-
- Count [RUN_ON] markers: Assess sentence boundary awareness
|
| 773 |
-
- Calculate grammatical accuracy rate (correct vs. total attempts)
|
| 774 |
|
| 775 |
-
|
| 776 |
-
-
|
| 777 |
-
|
| 778 |
-
|
| 779 |
-
|
| 780 |
-
-
|
| 781 |
-
-
|
|
|
|
| 782 |
|
| 783 |
-
|
| 784 |
-
-
|
| 785 |
-
|
| 786 |
-
|
| 787 |
-
-
|
| 788 |
-
-
|
| 789 |
-
|
| 790 |
-
|
| 791 |
-
|
| 792 |
-
|
| 793 |
-
-
|
| 794 |
-
|
| 795 |
-
|
| 796 |
-
-
|
| 797 |
-
-
|
| 798 |
-
|
| 799 |
-
|
| 800 |
-
|
| 801 |
-
-
|
| 802 |
-
-
|
| 803 |
-
-
|
| 804 |
-
-
|
| 805 |
-
|
| 806 |
-
|
| 807 |
-
|
| 808 |
-
|
| 809 |
-
-
|
| 810 |
-
-
|
| 811 |
-
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 812 |
- Compensatory strategies observed
|
| 813 |
|
| 814 |
-
|
| 815 |
-
- Primary
|
| 816 |
-
-
|
| 817 |
-
-
|
| 818 |
-
- Therapy targets: Specific, measurable goals
|
| 819 |
-
- Prognosis indicators: Based on error patterns and consistency
|
| 820 |
|
| 821 |
-
|
| 822 |
-
-
|
| 823 |
-
-
|
| 824 |
-
-
|
| 825 |
-
-
|
| 826 |
-
|
|
|
|
| 827 |
|
| 828 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 829 |
"""
|
| 830 |
|
| 831 |
return call_claude_api_with_continuation(analysis_prompt)
|
|
@@ -1431,7 +1583,7 @@ def call_claude_api_with_continuation(prompt):
|
|
| 1431 |
}
|
| 1432 |
|
| 1433 |
data = {
|
| 1434 |
-
"model": "claude-
|
| 1435 |
"max_tokens": 4096,
|
| 1436 |
"messages": [
|
| 1437 |
{
|
|
@@ -2176,331 +2328,208 @@ with gr.Blocks(title="Speech Analysis", theme=gr.themes.Soft()) as demo:
|
|
| 2176 |
return f"{comprehensive_report}\n\n{'='*100}\nCLINICAL INTERPRETATION BASED ON COMPREHENSIVE VERIFIED DATA\n{'='*100}\n\n{ai_interpretation}"
|
| 2177 |
|
| 2178 |
def run_ultimate_analysis(annotated_transcript, original_transcript, age, gender, slp_notes):
|
| 2179 |
-
"""
|
| 2180 |
if not annotated_transcript or len(annotated_transcript.strip()) < 50:
|
| 2181 |
return "Error: Please provide an annotated transcript for analysis."
|
| 2182 |
|
| 2183 |
-
#
|
| 2184 |
linguistic_metrics = calculate_linguistic_metrics(original_transcript)
|
| 2185 |
marker_analysis = analyze_annotation_markers(annotated_transcript)
|
| 2186 |
lexical_diversity = calculate_advanced_lexical_diversity(original_transcript)
|
| 2187 |
|
| 2188 |
-
#
|
| 2189 |
-
|
|
|
|
|
|
|
| 2190 |
|
| 2191 |
-
# STEP 3: Prepare all verified statistical values for final prompt
|
| 2192 |
stats_summary = f"""
|
| 2193 |
-
VERIFIED STATISTICAL
|
| 2194 |
-
|
| 2195 |
-
|
| 2196 |
-
|
| 2197 |
-
|
| 2198 |
-
|
| 2199 |
-
|
| 2200 |
-
|
| 2201 |
-
|
| 2202 |
-
|
| 2203 |
-
|
| 2204 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2205 |
|
| 2206 |
if lexical_diversity.get('library_available', False) and 'diversity_measures' in lexical_diversity:
|
| 2207 |
measures = lexical_diversity['diversity_measures']
|
| 2208 |
stats_summary += f"""
|
| 2209 |
-
• Simple TTR: {measures.get('simple_ttr', 'N/A')}
|
| 2210 |
-
• Root TTR: {measures.get('root_ttr', 'N/A')}
|
| 2211 |
-
• Log TTR: {measures.get('log_ttr', 'N/A')}
|
| 2212 |
-
• Maas TTR: {measures.get('maas_ttr', 'N/A')}
|
| 2213 |
-
• HDD: {measures.get('hdd', 'N/A')}
|
| 2214 |
-
• MSTTR (25-word): {measures.get('msttr_25', 'N/A')}
|
| 2215 |
-
• MSTTR (50-word): {measures.get('msttr_50', 'N/A')}
|
| 2216 |
-
• MATTR (25-word): {measures.get('mattr_25', 'N/A')}
|
| 2217 |
-
• MATTR (50-word): {measures.get('mattr_50', 'N/A')}
|
| 2218 |
-
• MTLD: {measures.get('mtld', 'N/A')}
|
| 2219 |
-
• MTLD (MA wrap): {measures.get('mtld_ma_wrap', 'N/A')}
|
| 2220 |
-
• MTLD (MA bidirectional): {measures.get('mtld_ma_bid', 'N/A')}"""
|
| 2221 |
-
else:
|
| 2222 |
-
stats_summary += "\n • Lexical diversity measures not available"
|
| 2223 |
-
|
| 2224 |
-
# Add manual annotation counts
|
| 2225 |
-
marker_counts = marker_analysis['marker_counts']
|
| 2226 |
-
category_totals = marker_analysis['category_totals']
|
| 2227 |
-
total_words = linguistic_metrics.get('total_words', 0)
|
| 2228 |
|
| 2229 |
-
|
| 2230 |
-
|
| 2231 |
-
|
| 2232 |
-
|
| 2233 |
-
|
| 2234 |
-
• REPETITION markers: {marker_counts.get('REPETITION', 0)}
|
| 2235 |
-
• REVISION markers: {marker_counts.get('REVISION', 0)}
|
| 2236 |
-
• PAUSE markers: {marker_counts.get('PAUSE', 0)}
|
| 2237 |
-
• GRAM_ERROR markers: {marker_counts.get('GRAM_ERROR', 0)}
|
| 2238 |
-
• SYNTAX_ERROR markers: {marker_counts.get('SYNTAX_ERROR', 0)}
|
| 2239 |
-
• MORPH_ERROR markers: {marker_counts.get('MORPH_ERROR', 0)}
|
| 2240 |
-
• SIMPLE_VOCAB markers: {marker_counts.get('SIMPLE_VOCAB', 0)}
|
| 2241 |
-
• COMPLEX_VOCAB markers: {marker_counts.get('COMPLEX_VOCAB', 0)}
|
| 2242 |
-
• SIMPLE_SENT markers: {marker_counts.get('SIMPLE_SENT', 0)}
|
| 2243 |
-
• COMPLEX_SENT markers: {marker_counts.get('COMPLEX_SENT', 0)}
|
| 2244 |
-
• COMPOUND_SENT markers: {marker_counts.get('COMPOUND_SENT', 0)}
|
| 2245 |
-
• FIGURATIVE markers: {marker_counts.get('FIGURATIVE', 0)}
|
| 2246 |
-
• PRONOUN_REF markers: {marker_counts.get('PRONOUN_REF', 0)}
|
| 2247 |
-
• TOPIC_SHIFT markers: {marker_counts.get('TOPIC_SHIFT', 0)}
|
| 2248 |
-
• TANGENT markers: {marker_counts.get('TANGENT', 0)}
|
| 2249 |
-
• CIRCUMLOCUTION markers: {marker_counts.get('CIRCUMLOCUTION', 0)}
|
| 2250 |
-
• GENERIC markers: {marker_counts.get('GENERIC', 0)}
|
| 2251 |
-
• WORD_SEARCH markers: {marker_counts.get('WORD_SEARCH', 0)}
|
| 2252 |
-
|
| 2253 |
-
CATEGORY TOTALS:
|
| 2254 |
-
• Total fluency issues: {category_totals['fluency_issues']} ({category_totals['fluency_issues']/total_words*100:.2f} per 100 words)
|
| 2255 |
-
• Total grammar errors: {category_totals['grammar_errors']} ({category_totals['grammar_errors']/total_words*100:.2f} per 100 words)
|
| 2256 |
-
• Vocabulary sophistication ratio: {category_totals['vocab_sophistication_ratio']:.3f}
|
| 2257 |
"""
|
| 2258 |
|
| 2259 |
-
#
|
| 2260 |
final_prompt = f"""
|
| 2261 |
-
You are a speech-language pathologist conducting the
|
| 2262 |
|
| 2263 |
Patient: {age}-year-old {gender}
|
| 2264 |
|
| 2265 |
{stats_summary}
|
| 2266 |
|
| 2267 |
-
|
| 2268 |
-
{ai_clinical_insights[:4000]}...
|
| 2269 |
-
|
| 2270 |
-
ANNOTATED TRANSCRIPT (for specific examples):
|
| 2271 |
{annotated_transcript}
|
| 2272 |
|
| 2273 |
-
|
| 2274 |
-
1. Use ONLY the verified statistical values
|
| 2275 |
-
2.
|
| 2276 |
-
3.
|
| 2277 |
-
4.
|
| 2278 |
-
|
| 2279 |
-
|
| 2280 |
-
|
| 2281 |
-
|
| 2282 |
-
|
| 2283 |
-
1. SPEECH FACTORS
|
| 2284 |
-
|
| 2285 |
-
A. Fluency Issues:
|
| 2286 |
-
- Filler words (
|
| 2287 |
-
*
|
| 2288 |
-
*
|
| 2289 |
-
*
|
| 2290 |
-
|
| 2291 |
-
|
| 2292 |
-
*
|
| 2293 |
-
|
| 2294 |
-
|
| 2295 |
-
*
|
| 2296 |
-
|
|
|
|
|
|
|
| 2297 |
|
| 2298 |
B. Word Retrieval Issues:
|
| 2299 |
-
-
|
| 2300 |
-
|
| 2301 |
-
|
| 2302 |
-
-
|
| 2303 |
-
|
| 2304 |
-
|
| 2305 |
-
-
|
| 2306 |
-
|
| 2307 |
-
|
| 2308 |
-
-
|
| 2309 |
-
|
| 2310 |
-
|
| 2311 |
-
|
| 2312 |
-
|
| 2313 |
-
|
| 2314 |
-
|
| 2315 |
-
|
| 2316 |
-
- Type-Token Ratio:
|
| 2317 |
-
-
|
| 2318 |
-
|
| 2319 |
-
|
| 2320 |
-
|
| 2321 |
-
-
|
| 2322 |
-
|
| 2323 |
-
|
| 2324 |
-
|
| 2325 |
-
|
| 2326 |
-
|
| 2327 |
-
-
|
| 2328 |
-
|
| 2329 |
-
|
| 2330 |
-
|
| 2331 |
-
|
| 2332 |
-
|
| 2333 |
-
|
| 2334 |
-
|
| 2335 |
-
-
|
| 2336 |
-
|
| 2337 |
-
|
| 2338 |
-
-
|
| 2339 |
-
-
|
| 2340 |
-
|
| 2341 |
-
|
| 2342 |
-
|
| 2343 |
-
|
| 2344 |
-
-
|
| 2345 |
-
-
|
| 2346 |
-
-
|
| 2347 |
-
-
|
| 2348 |
-
-
|
| 2349 |
-
|
| 2350 |
-
|
| 2351 |
-
-
|
| 2352 |
-
-
|
| 2353 |
-
-
|
| 2354 |
-
-
|
| 2355 |
-
|
| 2356 |
-
|
| 2357 |
-
|
| 2358 |
-
-
|
| 2359 |
-
-
|
| 2360 |
-
|
| 2361 |
-
4. FIGURATIVE LANGUAGE ANALYSIS (with ALL examples):
|
| 2362 |
-
|
| 2363 |
-
A. Similes and Metaphors:
|
| 2364 |
-
- Similes ([count]): [examples]
|
| 2365 |
-
- Metaphors ([count]): [examples]
|
| 2366 |
-
- "Like" as filler vs. comparison: [brief analysis]
|
| 2367 |
-
|
| 2368 |
-
B. Idioms and Non-literal Language:
|
| 2369 |
-
- Idioms ([count]): "get busted"
|
| 2370 |
-
- Colloquialisms ([count]): [examples]
|
| 2371 |
-
|
| 2372 |
-
5. PRAGMATIC LANGUAGE ASSESSMENT (with detailed examples):
|
| 2373 |
-
|
| 2374 |
-
A. Discourse Management:
|
| 2375 |
-
- Topic shifts: [count] - quote ALL transitions:
|
| 2376 |
-
* Bike → Golf carts: Quote exact transition
|
| 2377 |
-
* Golf carts → Food: Quote exact transition
|
| 2378 |
-
* Food → Cookies: Quote exact transition
|
| 2379 |
-
- Topic maintenance analysis:
|
| 2380 |
-
* Golf cart topic: [X utterances] - quote entire sequence
|
| 2381 |
-
* Food topic: [X utterances] - quote entire sequence
|
| 2382 |
-
- Topic elaboration: Count details provided per topic
|
| 2383 |
-
|
| 2384 |
-
B. Referential Communication:
|
| 2385 |
-
- Pronoun reference errors: [count] - quote ALL unclear references
|
| 2386 |
-
- Demonstrative use: [count] - quote ALL "this," "that" uses
|
| 2387 |
-
- Referential clarity: Analyze with specific examples
|
| 2388 |
-
|
| 2389 |
-
6. VOCABULARY AND SEMANTIC ANALYSIS (comprehensive breakdown):
|
| 2390 |
-
|
| 2391 |
-
A. Vocabulary Diversity:
|
| 2392 |
-
- ALL lexical diversity measures with interpretations:
|
| 2393 |
-
* Simple TTR: [number] - age comparison
|
| 2394 |
-
* MTLD: [number] - clinical interpretation
|
| 2395 |
-
* HDD: [number] - vocabulary range assessment
|
| 2396 |
-
* MATTR: [number] - moving average interpretation
|
| 2397 |
-
- Most frequent words: List top 20 with frequencies
|
| 2398 |
-
- Vocabulary sophistication by domain with examples
|
| 2399 |
-
|
| 2400 |
-
B. Semantic Relationships:
|
| 2401 |
-
- Word associations: Analyze patterns with examples
|
| 2402 |
-
- Semantic categories: List ALL categories used
|
| 2403 |
-
- Synonym/antonym use: Quote ALL instances
|
| 2404 |
-
- Semantic precision: Analyze accuracy with examples
|
| 2405 |
-
|
| 2406 |
-
7. MORPHOLOGICAL AND PHONOLOGICAL ANALYSIS (detailed breakdown):
|
| 2407 |
-
|
| 2408 |
-
A. Morphological Markers:
|
| 2409 |
-
- Plurals: [count] - list ALL regular and irregular examples
|
| 2410 |
-
- Verb tenses: Break down by type with ALL examples:
|
| 2411 |
-
* Present tense: List 20+ examples
|
| 2412 |
-
* Past tense regular: List ALL examples
|
| 2413 |
-
* Past tense irregular: List ALL examples
|
| 2414 |
-
- Progressive forms: [count] - list ALL "-ing" examples
|
| 2415 |
-
- Possessives: [count] - list ALL examples
|
| 2416 |
-
- Compound words: [count] - list ALL examples
|
| 2417 |
-
- Derivational morphemes: [count] - list ALL prefixes/suffixes
|
| 2418 |
-
|
| 2419 |
-
B. Phonological Patterns:
|
| 2420 |
-
- Articulation accuracy: Note any sound errors
|
| 2421 |
-
- Syllable structure: Analyze complexity with examples
|
| 2422 |
-
- Prosodic patterns: Describe rhythm and stress
|
| 2423 |
-
|
| 2424 |
-
8. COGNITIVE-LINGUISTIC FACTORS (with specific evidence):
|
| 2425 |
-
|
| 2426 |
-
A. Working Memory:
|
| 2427 |
-
- Longest successful utterance: [word count] - quote entire utterance
|
| 2428 |
-
- Complex information management: Quote examples of multi-part descriptions
|
| 2429 |
-
- Information retention across narrative: Analyze with examples
|
| 2430 |
-
|
| 2431 |
-
B. Processing Speed:
|
| 2432 |
-
- Word-finding efficiency: [count delays] - quote ALL instances
|
| 2433 |
-
- Response fluency: Analyze patterns with examples
|
| 2434 |
-
- Processing load indicators: Identify with examples
|
| 2435 |
-
|
| 2436 |
-
C. Executive Function:
|
| 2437 |
-
- Self-monitoring: [count] - quote ALL self-correction instances
|
| 2438 |
-
- Planning evidence: Analyze organization with examples
|
| 2439 |
-
- Cognitive flexibility: Analyze topic management with examples
|
| 2440 |
-
|
| 2441 |
-
9. FLUENCY AND RHYTHM ANALYSIS (comprehensive measurement):
|
| 2442 |
-
|
| 2443 |
-
A. Disfluency Patterns:
|
| 2444 |
-
- Total disfluency count: [number] with rate per 100 words
|
| 2445 |
-
- Disfluency types breakdown with ALL examples
|
| 2446 |
-
- Severity assessment compared to age norms
|
| 2447 |
-
- Impact on communication effectiveness
|
| 2448 |
-
|
| 2449 |
-
B. Language Flow:
|
| 2450 |
-
- Natural pause patterns: [count] - identify ALL appropriate pauses
|
| 2451 |
-
- Disrupted flow instances: [count] - quote ALL with analysis
|
| 2452 |
-
- Rhythm variation: Describe patterns with examples
|
| 2453 |
-
|
| 2454 |
-
10. QUANTITATIVE METRICS (report ALL data with calculations shown):
|
| 2455 |
-
- Total words: [count] (method of counting explained)
|
| 2456 |
-
- Total sentences: [count] (criteria for sentence boundaries)
|
| 2457 |
-
- Unique words: [count] (how uniqueness determined)
|
| 2458 |
-
- MLU words: [calculation] ([total words]/[utterances])
|
| 2459 |
-
- MLU morphemes: [calculation] ([total morphemes]/[utterances])
|
| 2460 |
-
- ALL lexical diversity measures: [list with values and interpretations]
|
| 2461 |
-
- Error rates: [calculations] for each error type
|
| 2462 |
-
- Age-appropriate comparisons for ALL measures
|
| 2463 |
|
| 2464 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2465 |
|
| 2466 |
-
A. Strengths (ranked with evidence):
|
| 2467 |
-
1. [Primary strength] - specific evidence with quotes and data
|
| 2468 |
-
2. [Secondary strength] - specific evidence with quotes and data
|
| 2469 |
-
3. [Continue ranking ALL strengths with supporting evidence]
|
| 2470 |
-
|
| 2471 |
B. Areas of Need (prioritized by severity):
|
| 2472 |
-
|
| 2473 |
-
|
| 2474 |
-
|
| 2475 |
-
|
| 2476 |
-
|
| 2477 |
-
|
| 2478 |
-
|
| 2479 |
-
|
| 2480 |
-
|
| 2481 |
-
|
| 2482 |
-
-
|
| 2483 |
-
-
|
| 2484 |
-
-
|
| 2485 |
-
|
| 2486 |
-
|
| 2487 |
-
|
| 2488 |
-
12. PROGNOSIS AND SUMMARY:
|
| 2489 |
-
Overall profile based on comprehensive verified data
|
| 2490 |
-
|
| 2491 |
-
REQUIREMENTS:
|
| 2492 |
-
- Complete ALL 12 sections
|
| 2493 |
-
- Use ONLY verified statistical values (never recount)
|
| 2494 |
-
- Cite specific examples from annotated transcript
|
| 2495 |
-
- Provide clinical interpretation of the verified data
|
| 2496 |
-
- If response is cut off, end with <CONTINUE>
|
| 2497 |
"""
|
| 2498 |
|
| 2499 |
-
#
|
| 2500 |
final_result = call_claude_api_with_continuation(final_prompt)
|
| 2501 |
-
|
| 2502 |
return final_result
|
| 2503 |
-
|
| 2504 |
def run_full_pipeline(transcript_content, age, gender, slp_notes):
|
| 2505 |
"""Run the complete pipeline but return annotation immediately"""
|
| 2506 |
if not transcript_content or len(transcript_content.strip()) < 50:
|
|
|
|
| 148 |
}
|
| 149 |
|
| 150 |
data = {
|
| 151 |
+
"model": "claude-sonnet-4-5",
|
| 152 |
"max_tokens": 4096,
|
| 153 |
"messages": [
|
| 154 |
{
|
|
|
|
| 278 |
}
|
| 279 |
|
| 280 |
data = {
|
| 281 |
+
"model": "claude-sonnet-4-5",
|
| 282 |
"max_tokens": 4096,
|
| 283 |
"messages": [
|
| 284 |
{
|
|
|
|
| 729 |
"""
|
| 730 |
|
| 731 |
analysis_prompt = f"""
|
| 732 |
+
You are a speech-language pathologist conducting a comprehensive analysis of an annotated speech sample. Provide a complete, clinically useful analysis without excessive formatting.
|
| 733 |
|
| 734 |
Patient: {age}-year-old {gender}
|
| 735 |
|
| 736 |
ANNOTATED TRANSCRIPT:
|
| 737 |
{annotated_transcript}{notes_section}
|
| 738 |
|
| 739 |
+
INSTRUCTIONS: Complete ALL 12 sections below. Use simple formatting (no excessive markdown, headers, or bullets). Focus on clinical utility and completeness. Count all markers precisely and provide specific examples.
|
| 740 |
+
|
| 741 |
+
COMPREHENSIVE SPEECH SAMPLE ANALYSIS
|
| 742 |
+
|
| 743 |
+
1. SPEECH FACTORS
|
| 744 |
+
|
| 745 |
+
A. Fluency Issues (count each marker type precisely):
|
| 746 |
+
- Filler words ([FILLER]): Count all instances, calculate rate per 100 words
|
| 747 |
+
* List each type: "um," "uh," "like," "you know," etc.
|
| 748 |
+
* Provide specific examples with context
|
| 749 |
+
* Calculate percentage of total words
|
| 750 |
+
- False starts ([FALSE_START]): Count and categorize
|
| 751 |
+
* Word-level false starts: "I was go- going"
|
| 752 |
+
* Phrase-level false starts: "My bike is- I mean my bike looks"
|
| 753 |
+
* Provide exact quotes from transcript
|
| 754 |
+
- Repetitions ([REPETITION]): Count and categorize by type
|
| 755 |
+
* Word repetitions: "I I went"
|
| 756 |
+
* Phrase repetitions: "to the store to the store"
|
| 757 |
+
* Sound repetitions: "b-b-bike"
|
| 758 |
+
- Revisions ([REVISION]): Count self-corrections and analyze patterns
|
| 759 |
+
* Grammatical revisions: "I goed- I went"
|
| 760 |
+
* Lexical revisions: "big- huge dog"
|
| 761 |
+
* Semantic revisions: "car- I mean bike"
|
| 762 |
+
- Pauses ([PAUSE]): Count hesitation markers and silent pauses
|
| 763 |
+
- Total disfluency rate: Calculate combined rate per 100 words
|
| 764 |
+
- Severity assessment: Compare to age norms
|
| 765 |
+
|
| 766 |
+
B. Word Retrieval Issues (detailed analysis):
|
| 767 |
+
- Circumlocutions ([CIRCUMLOCUTION]): Count and analyze strategies
|
| 768 |
+
* Functional descriptions: "the thing you write with"
|
| 769 |
+
* Category + description: "that type of fish in the salad"
|
| 770 |
+
* Provide exact quotes and analyze effectiveness
|
| 771 |
+
- Incomplete thoughts ([INCOMPLETE]): Count abandoned utterances
|
| 772 |
+
* Analyze patterns: topic-related, complexity-related, retrieval-related
|
| 773 |
+
- Generic terms ([GENERIC]): Count vague language
|
| 774 |
+
* "thing," "stuff," "something," "whatsit"
|
| 775 |
+
* Calculate specificity ratio
|
| 776 |
+
- Word searches ([WORD_SEARCH]): Count explicit retrieval attempts
|
| 777 |
+
* "What do you call it," "I can't think of the word"
|
| 778 |
+
- Overall efficiency: Calculate success rate of retrieval attempts
|
| 779 |
+
|
| 780 |
+
C. Grammatical Errors (comprehensive breakdown):
|
| 781 |
+
- Grammatical errors ([GRAM_ERROR]): Count by subcategory
|
| 782 |
+
* Subject-verb agreement: "He don't like it"
|
| 783 |
+
* Verb tense errors: "Yesterday I go to store"
|
| 784 |
+
* Pronoun errors: "Me and him went"
|
| 785 |
+
* Article errors: "I saw a elephant"
|
| 786 |
+
- Syntax errors ([SYNTAX_ERROR]): Count word order problems
|
| 787 |
+
- Morphological errors ([MORPH_ERROR]): Count and categorize
|
| 788 |
+
* Plural errors: "childs," "foots"
|
| 789 |
+
* Past tense errors: "runned," "catched"
|
| 790 |
+
* Comparative errors: "more better"
|
| 791 |
+
- Run-on sentences ([RUN_ON]): Count and assess boundary awareness
|
| 792 |
+
- Calculate grammatical accuracy rate
|
| 793 |
+
|
| 794 |
+
2. LANGUAGE SKILLS ASSESSMENT
|
| 795 |
+
|
| 796 |
+
A. Vocabulary Analysis (detailed breakdown):
|
| 797 |
+
- Simple vocabulary ([SIMPLE_VOCAB]): Count and categorize
|
| 798 |
+
* High-frequency words: "go," "big," "good"
|
| 799 |
+
* Basic descriptors: "nice," "fun," "cool"
|
| 800 |
+
* Calculate percentage of total vocabulary
|
| 801 |
+
- Complex vocabulary ([COMPLEX_VOCAB]): Count and analyze
|
| 802 |
+
* Academic vocabulary: "magnificent," "elaborate"
|
| 803 |
+
* Technical terms: "carburetor," "photosynthesis"
|
| 804 |
+
* Low-frequency words: "churrasco," "anchovies"
|
| 805 |
+
- Vocabulary sophistication ratio: Complex/simple vocabulary
|
| 806 |
+
- Type-token ratio: Unique words/total words
|
| 807 |
+
- Semantic appropriateness: Analyze precision and context fit
|
| 808 |
+
- Word frequency analysis: Identify most common words used
|
| 809 |
+
|
| 810 |
+
B. Grammar and Morphology (systematic analysis):
|
| 811 |
+
- Morphological complexity assessment
|
| 812 |
+
- Derivational morpheme use: prefixes, suffixes
|
| 813 |
+
- Inflectional morphology: plurals, tense, agreement
|
| 814 |
+
- Compound word formation
|
| 815 |
+
- Error pattern analysis by morpheme type
|
| 816 |
+
|
| 817 |
+
3. COMPLEX SENTENCE ANALYSIS
|
| 818 |
+
|
| 819 |
+
A. Sentence Structure Distribution:
|
| 820 |
+
- Simple sentences ([SIMPLE_SENT]): Count and calculate percentage
|
| 821 |
+
* Subject + predicate: "I went home"
|
| 822 |
+
* Analyze average length and complexity
|
| 823 |
+
- Complex sentences ([COMPLEX_SENT]): Count subordination patterns
|
| 824 |
+
* Adverbial clauses: "When I got home, I ate dinner"
|
| 825 |
+
* Relative clauses: "The bike that I rode was red"
|
| 826 |
+
* Noun clauses: "I know that he likes pizza"
|
| 827 |
+
- Compound sentences ([COMPOUND_SENT]): Count coordination patterns
|
| 828 |
+
* Coordinating conjunctions: "and," "but," "or," "so"
|
| 829 |
+
* Analyze balance and appropriateness
|
| 830 |
+
|
| 831 |
+
B. Syntactic Complexity Measures:
|
| 832 |
+
- Mean Length of Utterance (MLU): Words and morphemes
|
| 833 |
+
- Clauses per utterance ratio
|
| 834 |
+
- Subordination index
|
| 835 |
+
- Coordination index
|
| 836 |
+
- Developmental appropriateness assessment
|
| 837 |
|
| 838 |
+
4. FIGURATIVE LANGUAGE ANALYSIS
|
| 839 |
|
| 840 |
+
A. Non-literal Language Use:
|
| 841 |
+
- Figurative expressions ([FIGURATIVE]): Count and analyze
|
| 842 |
+
* Metaphors: "Time is money"
|
| 843 |
+
* Similes: "Fast as lightning"
|
| 844 |
+
* Idioms: "Raining cats and dogs"
|
| 845 |
+
- Appropriateness assessment: Context and age-level
|
| 846 |
+
- Comprehension vs. production abilities
|
| 847 |
+
- Abstract language development indicators
|
| 848 |
|
| 849 |
+
5. PRAGMATIC LANGUAGE ASSESSMENT
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 850 |
|
| 851 |
+
A. Discourse Management:
|
| 852 |
+
- Topic management ([TOPIC_SHIFT]): Count and assess appropriateness
|
| 853 |
+
* Smooth transitions vs. abrupt shifts
|
| 854 |
+
* Topic maintenance duration
|
| 855 |
+
* Elaboration and detail provision
|
| 856 |
+
- Tangential speech ([TANGENT]): Count off-topic instances
|
| 857 |
+
- Discourse coherence ([COHERENCE_BREAK]): Analyze logical flow
|
| 858 |
+
- Narrative structure and organization
|
| 859 |
|
| 860 |
+
B. Referential Communication:
|
| 861 |
+
- Referential clarity ([PRONOUN_REF]): Count unclear references
|
| 862 |
+
* Ambiguous pronouns: "He told him that he was wrong"
|
| 863 |
+
* Missing referents: "It was really good" (unclear antecedent)
|
| 864 |
+
- Demonstrative use: "this," "that," "these," "those"
|
| 865 |
+
- Overall conversational competence assessment
|
| 866 |
+
|
| 867 |
+
6. VOCABULARY AND SEMANTIC ANALYSIS
|
| 868 |
+
|
| 869 |
+
A. Semantic Accuracy and Precision:
|
| 870 |
+
- Semantic errors ([SEMANTIC_ERROR]): Count inappropriate word choices
|
| 871 |
+
* Word substitutions: "I drove my bicycle"
|
| 872 |
+
* Category errors: "I petted the bird" (for touched)
|
| 873 |
+
- Word association patterns and semantic relationships
|
| 874 |
+
- Semantic categories: Analyze breadth and organization
|
| 875 |
+
- Precision of word choice: Specific vs. general terms
|
| 876 |
+
|
| 877 |
+
B. Lexical Diversity and Sophistication:
|
| 878 |
+
- Vocabulary breadth: Range of semantic categories
|
| 879 |
+
- Vocabulary depth: Precision and nuance within categories
|
| 880 |
+
- Academic vs. conversational vocabulary ratio
|
| 881 |
+
- Age-appropriate vocabulary development
|
| 882 |
+
|
| 883 |
+
7. MORPHOLOGICAL AND PHONOLOGICAL ANALYSIS
|
| 884 |
+
|
| 885 |
+
A. Morphological Patterns:
|
| 886 |
+
- Derivational morphology: Prefixes and suffixes
|
| 887 |
+
- Inflectional morphology: Tense, number, case markers
|
| 888 |
+
- Morphological awareness indicators
|
| 889 |
+
- Error patterns and developmental appropriateness
|
| 890 |
+
|
| 891 |
+
B. Phonological Considerations:
|
| 892 |
+
- Sound pattern analysis (if evident in transcript)
|
| 893 |
+
- Syllable structure complexity
|
| 894 |
+
- Phonological awareness indicators
|
| 895 |
+
|
| 896 |
+
8. COGNITIVE-LINGUISTIC FACTORS
|
| 897 |
+
|
| 898 |
+
A. Working Memory Indicators:
|
| 899 |
+
- Sentence length and complexity management
|
| 900 |
+
- Information retention across utterances
|
| 901 |
+
- Complex information processing evidence
|
| 902 |
+
|
| 903 |
+
B. Processing Speed and Efficiency:
|
| 904 |
+
- Word-finding speed and accuracy
|
| 905 |
+
- Response latency patterns
|
| 906 |
+
- Processing load indicators
|
| 907 |
+
|
| 908 |
+
C. Executive Function Evidence:
|
| 909 |
+
- Self-monitoring and error correction
|
| 910 |
+
- Planning and organization in discourse
|
| 911 |
+
- Cognitive flexibility in topic management
|
| 912 |
+
|
| 913 |
+
9. FLUENCY AND RHYTHM ANALYSIS
|
| 914 |
+
|
| 915 |
+
A. Disfluency Patterns:
|
| 916 |
+
- Total disfluency count and rate per 100 words
|
| 917 |
+
- Disfluency type distribution
|
| 918 |
+
- Clustering patterns and severity assessment
|
| 919 |
+
- Impact on communication effectiveness
|
| 920 |
+
|
| 921 |
+
B. Speech Flow and Rhythm:
|
| 922 |
+
- Natural pause patterns vs. disrupted flow
|
| 923 |
+
- Rhythm and prosodic patterns (if evident)
|
| 924 |
+
- Overall fluency profile and age-appropriateness
|
| 925 |
+
|
| 926 |
+
10. QUANTITATIVE METRICS
|
| 927 |
+
|
| 928 |
+
A. Basic Measures:
|
| 929 |
+
- Total words: [exact count]
|
| 930 |
+
- Total sentences: [exact count]
|
| 931 |
+
- Unique words: [exact count]
|
| 932 |
+
- MLU words: [calculation with formula shown]
|
| 933 |
+
- MLU morphemes: [calculation with formula shown]
|
| 934 |
+
- Type-Token Ratio: [calculation and interpretation]
|
| 935 |
+
|
| 936 |
+
B. Error Rates and Ratios:
|
| 937 |
+
- Disfluency rate per 100 words
|
| 938 |
+
- Grammatical accuracy percentage
|
| 939 |
+
- Vocabulary sophistication ratio
|
| 940 |
+
- Sentence complexity distribution percentages
|
| 941 |
+
|
| 942 |
+
11. CLINICAL IMPLICATIONS
|
| 943 |
+
|
| 944 |
+
A. Strengths (ranked by prominence):
|
| 945 |
+
- Primary strengths with supporting evidence
|
| 946 |
+
- Secondary strengths with examples
|
| 947 |
- Compensatory strategies observed
|
| 948 |
|
| 949 |
+
B. Areas of Need (prioritized by severity):
|
| 950 |
+
- Primary concerns with impact assessment
|
| 951 |
+
- Secondary concerns with supporting data
|
| 952 |
+
- Developmental vs. disorder considerations
|
|
|
|
|
|
|
| 953 |
|
| 954 |
+
C. Treatment Recommendations:
|
| 955 |
+
- Specific, measurable therapy goals
|
| 956 |
+
- Intervention approaches and techniques
|
| 957 |
+
- Frequency and duration recommendations
|
| 958 |
+
- Progress monitoring strategies
|
| 959 |
+
|
| 960 |
+
12. PROGNOSIS AND SUMMARY
|
| 961 |
|
| 962 |
+
A. Overall Communication Profile:
|
| 963 |
+
- Comprehensive summary of findings
|
| 964 |
+
- Developmental appropriateness assessment
|
| 965 |
+
- Functional communication impact
|
| 966 |
+
|
| 967 |
+
B. Treatment Planning:
|
| 968 |
+
- Priority intervention targets
|
| 969 |
+
- Expected outcomes and timeline
|
| 970 |
+
- Follow-up assessment recommendations
|
| 971 |
+
- Family/educational recommendations
|
| 972 |
+
|
| 973 |
+
CRITICAL REQUIREMENTS:
|
| 974 |
+
1. Complete ALL 12 sections - do not stop early
|
| 975 |
+
2. Provide exact counts for all markers with specific examples
|
| 976 |
+
3. Calculate all percentages and rates with formulas shown
|
| 977 |
+
4. Include direct quotes from transcript for examples
|
| 978 |
+
5. Analyze patterns and provide clinical interpretations
|
| 979 |
+
6. Focus on actionable, clinically relevant insights
|
| 980 |
+
7. If response is incomplete, end with <CONTINUE>
|
| 981 |
"""
|
| 982 |
|
| 983 |
return call_claude_api_with_continuation(analysis_prompt)
|
|
|
|
| 1583 |
}
|
| 1584 |
|
| 1585 |
data = {
|
| 1586 |
+
"model": "claude-sonnet-4-5",
|
| 1587 |
"max_tokens": 4096,
|
| 1588 |
"messages": [
|
| 1589 |
{
|
|
|
|
| 2328 |
return f"{comprehensive_report}\n\n{'='*100}\nCLINICAL INTERPRETATION BASED ON COMPREHENSIVE VERIFIED DATA\n{'='*100}\n\n{ai_interpretation}"
|
| 2329 |
|
| 2330 |
def run_ultimate_analysis(annotated_transcript, original_transcript, age, gender, slp_notes):
|
| 2331 |
+
"""Clean comprehensive analysis using verified statistical data"""
|
| 2332 |
if not annotated_transcript or len(annotated_transcript.strip()) < 50:
|
| 2333 |
return "Error: Please provide an annotated transcript for analysis."
|
| 2334 |
|
| 2335 |
+
# Gather statistical data
|
| 2336 |
linguistic_metrics = calculate_linguistic_metrics(original_transcript)
|
| 2337 |
marker_analysis = analyze_annotation_markers(annotated_transcript)
|
| 2338 |
lexical_diversity = calculate_advanced_lexical_diversity(original_transcript)
|
| 2339 |
|
| 2340 |
+
# Prepare verified statistics
|
| 2341 |
+
marker_counts = marker_analysis['marker_counts']
|
| 2342 |
+
category_totals = marker_analysis['category_totals']
|
| 2343 |
+
total_words = linguistic_metrics.get('total_words', 0)
|
| 2344 |
|
|
|
|
| 2345 |
stats_summary = f"""
|
| 2346 |
+
VERIFIED STATISTICAL DATA:
|
| 2347 |
+
|
| 2348 |
+
Basic Metrics:
|
| 2349 |
+
- Total words: {total_words}
|
| 2350 |
+
- Total sentences: {linguistic_metrics.get('total_sentences', 0)}
|
| 2351 |
+
- Unique words: {linguistic_metrics.get('unique_words', 0)}
|
| 2352 |
+
- MLU words: {linguistic_metrics.get('mlu_words', 0):.2f}
|
| 2353 |
+
- MLU morphemes: {linguistic_metrics.get('mlu_morphemes', 0):.2f}
|
| 2354 |
+
- Average sentence length: {linguistic_metrics.get('avg_sentence_length', 0):.2f}
|
| 2355 |
+
|
| 2356 |
+
Annotation Counts:
|
| 2357 |
+
- Filler markers: {marker_counts.get('FILLER', 0)} ({marker_counts.get('FILLER', 0)/total_words*100:.2f} per 100 words)
|
| 2358 |
+
- False starts: {marker_counts.get('FALSE_START', 0)}
|
| 2359 |
+
- Repetitions: {marker_counts.get('REPETITION', 0)}
|
| 2360 |
+
- Grammar errors: {marker_counts.get('GRAM_ERROR', 0)}
|
| 2361 |
+
- Simple vocabulary: {marker_counts.get('SIMPLE_VOCAB', 0)}
|
| 2362 |
+
- Complex vocabulary: {marker_counts.get('COMPLEX_VOCAB', 0)}
|
| 2363 |
+
- Simple sentences: {marker_counts.get('SIMPLE_SENT', 0)}
|
| 2364 |
+
- Complex sentences: {marker_counts.get('COMPLEX_SENT', 0)}
|
| 2365 |
+
- Compound sentences: {marker_counts.get('COMPOUND_SENT', 0)}
|
| 2366 |
+
|
| 2367 |
+
Category Totals:
|
| 2368 |
+
- Total fluency issues: {category_totals['fluency_issues']} ({category_totals['fluency_issues']/total_words*100:.2f} per 100 words)
|
| 2369 |
+
- Total grammar errors: {category_totals['grammar_errors']}
|
| 2370 |
+
- Vocabulary sophistication ratio: {category_totals['vocab_sophistication_ratio']:.3f}
|
| 2371 |
+
"""
|
| 2372 |
|
| 2373 |
if lexical_diversity.get('library_available', False) and 'diversity_measures' in lexical_diversity:
|
| 2374 |
measures = lexical_diversity['diversity_measures']
|
| 2375 |
stats_summary += f"""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2376 |
|
| 2377 |
+
Lexical Diversity:
|
| 2378 |
+
- Simple TTR: {measures.get('simple_ttr', 'N/A')}
|
| 2379 |
+
- HDD: {measures.get('hdd', 'N/A')}
|
| 2380 |
+
- MTLD: {measures.get('mtld', 'N/A')}
|
| 2381 |
+
- MATTR: {measures.get('mattr_25', 'N/A')}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2382 |
"""
|
| 2383 |
|
| 2384 |
+
# Create comprehensive analysis prompt
|
| 2385 |
final_prompt = f"""
|
| 2386 |
+
You are a speech-language pathologist conducting a comprehensive speech analysis. Use the verified statistical data provided and complete ALL 12 sections with detailed structure.
|
| 2387 |
|
| 2388 |
Patient: {age}-year-old {gender}
|
| 2389 |
|
| 2390 |
{stats_summary}
|
| 2391 |
|
| 2392 |
+
ANNOTATED TRANSCRIPT (for examples and quotes):
|
|
|
|
|
|
|
|
|
|
| 2393 |
{annotated_transcript}
|
| 2394 |
|
| 2395 |
+
INSTRUCTIONS:
|
| 2396 |
+
1. Use ONLY the verified statistical values above - do not recount anything
|
| 2397 |
+
2. Complete ALL 12 sections without stopping
|
| 2398 |
+
3. Provide specific examples and quotes from the transcript
|
| 2399 |
+
4. Calculate rates and percentages using verified counts
|
| 2400 |
+
5. Focus on clinical interpretation and actionable insights
|
| 2401 |
+
6. If response is incomplete, end with <CONTINUE>
|
| 2402 |
+
|
| 2403 |
+
COMPREHENSIVE SPEECH SAMPLE ANALYSIS
|
| 2404 |
+
|
| 2405 |
+
1. SPEECH FACTORS
|
| 2406 |
+
|
| 2407 |
+
A. Fluency Issues (use verified counts):
|
| 2408 |
+
- Filler words: Use verified count of {marker_counts.get('FILLER', 0)} fillers
|
| 2409 |
+
* Calculate rate per 100 words: {marker_counts.get('FILLER', 0)/total_words*100:.2f}%
|
| 2410 |
+
* Identify types and provide examples from transcript
|
| 2411 |
+
* Assess severity and impact on communication
|
| 2412 |
+
- False starts: Use verified count of {marker_counts.get('FALSE_START', 0)}
|
| 2413 |
+
* Provide specific examples from transcript
|
| 2414 |
+
* Analyze patterns and self-correction abilities
|
| 2415 |
+
- Repetitions: Use verified count of {marker_counts.get('REPETITION', 0)}
|
| 2416 |
+
* Categorize types (word, phrase, sound level)
|
| 2417 |
+
* Provide examples and assess severity
|
| 2418 |
+
- Total disfluency assessment: Use verified total of {category_totals['fluency_issues']}
|
| 2419 |
+
* Rate: {category_totals['fluency_issues']/total_words*100:.2f} per 100 words
|
| 2420 |
+
* Compare to age norms and assess severity
|
| 2421 |
|
| 2422 |
B. Word Retrieval Issues:
|
| 2423 |
+
- Circumlocutions: Count and analyze from transcript
|
| 2424 |
+
- Incomplete thoughts: Identify abandoned utterances
|
| 2425 |
+
- Generic language use: Count vague terms
|
| 2426 |
+
- Word-finding efficiency: Assess retrieval success rate
|
| 2427 |
+
|
| 2428 |
+
C. Grammatical Errors (use verified counts):
|
| 2429 |
+
- Grammar errors: Use verified count of {marker_counts.get('GRAM_ERROR', 0)}
|
| 2430 |
+
- Syntax errors: Use verified count of {marker_counts.get('SYNTAX_ERROR', 0)}
|
| 2431 |
+
- Morphological errors: Use verified count of {marker_counts.get('MORPH_ERROR', 0)}
|
| 2432 |
+
- Calculate overall grammatical accuracy rate
|
| 2433 |
+
|
| 2434 |
+
2. LANGUAGE SKILLS ASSESSMENT
|
| 2435 |
+
|
| 2436 |
+
A. Vocabulary Analysis (use verified data):
|
| 2437 |
+
- Simple vocabulary: Use verified count of {marker_counts.get('SIMPLE_VOCAB', 0)}
|
| 2438 |
+
- Complex vocabulary: Use verified count of {marker_counts.get('COMPLEX_VOCAB', 0)}
|
| 2439 |
+
- Sophistication ratio: Use verified ratio of {category_totals['vocab_sophistication_ratio']:.3f}
|
| 2440 |
+
- Type-Token Ratio: Use verified TTR from basic metrics
|
| 2441 |
+
- Provide examples of each vocabulary level from transcript
|
| 2442 |
+
|
| 2443 |
+
B. Grammar and Morphology:
|
| 2444 |
+
- Error pattern analysis using verified counts
|
| 2445 |
+
- Developmental appropriateness assessment
|
| 2446 |
+
- Morphological complexity evaluation
|
| 2447 |
+
|
| 2448 |
+
3. COMPLEX SENTENCE ANALYSIS (use verified counts)
|
| 2449 |
+
|
| 2450 |
+
A. Sentence Structure Distribution:
|
| 2451 |
+
- Simple sentences: Use verified count of {marker_counts.get('SIMPLE_SENT', 0)}
|
| 2452 |
+
- Complex sentences: Use verified count of {marker_counts.get('COMPLEX_SENT', 0)}
|
| 2453 |
+
- Compound sentences: Use verified count of {marker_counts.get('COMPOUND_SENT', 0)}
|
| 2454 |
+
- Calculate percentages of each type
|
| 2455 |
+
|
| 2456 |
+
B. Syntactic Complexity:
|
| 2457 |
+
- MLU analysis: Use verified MLU of {linguistic_metrics.get('mlu_words', 0):.2f} words
|
| 2458 |
+
- Average sentence length: Use verified length of {linguistic_metrics.get('avg_sentence_length', 0):.2f} words
|
| 2459 |
+
- Subordination and coordination patterns
|
| 2460 |
+
|
| 2461 |
+
4. FIGURATIVE LANGUAGE ANALYSIS
|
| 2462 |
+
- Figurative expressions: Use verified count of {marker_counts.get('FIGURATIVE', 0)}
|
| 2463 |
+
- Metaphor and idiom identification from transcript
|
| 2464 |
+
- Age-appropriate development assessment
|
| 2465 |
+
- Abstract language abilities
|
| 2466 |
+
|
| 2467 |
+
5. PRAGMATIC LANGUAGE ASSESSMENT
|
| 2468 |
+
- Topic shifts: Use verified count of {marker_counts.get('TOPIC_SHIFT', 0)}
|
| 2469 |
+
- Tangential speech: Use verified count of {marker_counts.get('TANGENT', 0)}
|
| 2470 |
+
- Coherence breaks: Use verified count of {marker_counts.get('COHERENCE_BREAK', 0)}
|
| 2471 |
+
- Referential clarity: Use verified count of {marker_counts.get('PRONOUN_REF', 0)}
|
| 2472 |
+
- Overall conversational competence assessment
|
| 2473 |
+
|
| 2474 |
+
6. VOCABULARY AND SEMANTIC ANALYSIS
|
| 2475 |
+
- Semantic errors: Use verified count of {marker_counts.get('SEMANTIC_ERROR', 0)}
|
| 2476 |
+
- Lexical diversity: Use verified measures from stats summary
|
| 2477 |
+
- Word association patterns from transcript analysis
|
| 2478 |
+
- Semantic precision and appropriateness
|
| 2479 |
+
|
| 2480 |
+
7. MORPHOLOGICAL AND PHONOLOGICAL ANALYSIS
|
| 2481 |
+
- Morphological complexity assessment
|
| 2482 |
+
- Derivational and inflectional morphology patterns
|
| 2483 |
+
- Error analysis using verified counts
|
| 2484 |
+
- Developmental appropriateness
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2485 |
|
| 2486 |
+
8. COGNITIVE-LINGUISTIC FACTORS
|
| 2487 |
+
- Working memory indicators from sentence complexity
|
| 2488 |
+
- Processing speed markers from fluency patterns
|
| 2489 |
+
- Executive function evidence from self-corrections
|
| 2490 |
+
- Attention and cognitive load management
|
| 2491 |
+
|
| 2492 |
+
9. FLUENCY AND RHYTHM ANALYSIS
|
| 2493 |
+
- Disfluency pattern analysis using verified counts
|
| 2494 |
+
- Speech rhythm and flow assessment
|
| 2495 |
+
- Natural vs. disrupted pause patterns
|
| 2496 |
+
- Overall fluency profile
|
| 2497 |
+
|
| 2498 |
+
10. QUANTITATIVE METRICS (use ALL verified data)
|
| 2499 |
+
- Total words: {total_words}
|
| 2500 |
+
- Total sentences: {linguistic_metrics.get('total_sentences', 0)}
|
| 2501 |
+
- Unique words: {linguistic_metrics.get('unique_words', 0)}
|
| 2502 |
+
- MLU words: {linguistic_metrics.get('mlu_words', 0):.2f}
|
| 2503 |
+
- MLU morphemes: {linguistic_metrics.get('mlu_morphemes', 0):.2f}
|
| 2504 |
+
- All error rates and ratios from verified counts
|
| 2505 |
+
|
| 2506 |
+
11. CLINICAL IMPLICATIONS
|
| 2507 |
+
A. Strengths (with supporting evidence):
|
| 2508 |
+
- Identify primary strengths using verified data
|
| 2509 |
+
- Provide specific examples from transcript
|
| 2510 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2511 |
B. Areas of Need (prioritized by severity):
|
| 2512 |
+
- Primary concerns based on verified counts and rates
|
| 2513 |
+
- Secondary areas for intervention
|
| 2514 |
+
|
| 2515 |
+
C. Treatment Recommendations:
|
| 2516 |
+
- Specific, measurable therapy goals
|
| 2517 |
+
- Evidence-based intervention approaches
|
| 2518 |
+
- Progress monitoring strategies
|
| 2519 |
+
|
| 2520 |
+
12. PROGNOSIS AND SUMMARY
|
| 2521 |
+
- Overall communication profile synthesis
|
| 2522 |
+
- Functional impact assessment
|
| 2523 |
+
- Treatment planning and expected outcomes
|
| 2524 |
+
- Follow-up recommendations
|
| 2525 |
+
|
| 2526 |
+
CRITICAL: Complete ALL 12 sections using verified data and specific transcript examples.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2527 |
"""
|
| 2528 |
|
| 2529 |
+
# Get comprehensive analysis
|
| 2530 |
final_result = call_claude_api_with_continuation(final_prompt)
|
|
|
|
| 2531 |
return final_result
|
| 2532 |
+
|
| 2533 |
def run_full_pipeline(transcript_content, age, gender, slp_notes):
|
| 2534 |
"""Run the complete pipeline but return annotation immediately"""
|
| 2535 |
if not transcript_content or len(transcript_content.strip()) < 50:
|