File size: 1,310 Bytes
d1f3f31 | 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 | def analyze_context(transcript: str, raw_features: list) -> dict:
"""
Analyzes the depth and structure of the conversation.
Longer engaged conversations should increase confidence.
"""
words = transcript.split()
length = len(words)
# Estimate turns (very rough approximation by looking at punctuation / sentence breaks)
# A real system would use diarization
turns = transcript.count("?") + transcript.count(".") + transcript.count("!")
technical_features_count = len([f for f in raw_features if f.get("label") == "FEATURE"])
score = 0.0
# 1. Transcript length baseline
if length > 200:
score += 0.4
elif length > 100:
score += 0.2
elif length > 40:
score += 0.1
# 2. Conversational turns (engagement)
if turns > 10:
score += 0.3
elif turns > 5:
score += 0.15
# 3. Technical depth
if technical_features_count > 3:
score += 0.3
elif technical_features_count > 1:
score += 0.15
# Normalize to 0-1
engagement_score = min(1.0, score)
return {
"engagement_score": engagement_score,
"word_count": length,
"estimated_turns": turns,
"technical_depth": technical_features_count
}
|