File size: 860 Bytes
438c749
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
def calculate_emotion_score(emotion_counts):
    total = sum(emotion_counts.values())

    if total == 0:
        return 0

    happy = emotion_counts.get('happy', 0)
    neutral = emotion_counts.get('neutral', 0)

    score = ((happy * 1.0) + (neutral * 0.5)) / total

    return round(score * 100, 2)


def calculate_filler_score(filler_count, text):
    words = len(text.split())

    if words == 0:
        return 0

    rate = filler_count / words

    score = max(0, 100 - (rate * 200))

    return round(score, 2)


def final_score(emotion_score, filler_score):
    return round((emotion_score * 0.6 + filler_score * 0.4), 2)

def communication_score(text):
    words = text.split()
    length = len(words)

    # simple logic
    if length > 50:
        score = 90
    elif length > 20:
        score = 70
    else:
        score = 50

    return score