File size: 3,641 Bytes
5251bf1
9cec98e
e3551a8
 
 
9fda8e0
620c398
5251bf1
 
 
97d789e
9fda8e0
772a72f
97d789e
70ae5c9
5251bf1
dbe24d9
772a72f
 
5251bf1
e9d3a59
b8b0f87
 
772a72f
5251bf1
70ae5c9
5251bf1
 
772a72f
 
5251bf1
e9d3a59
b8b0f87
 
772a72f
5251bf1
38e37ac
 
dbe24d9
 
772a72f
 
 
 
 
38e37ac
e9d3a59
b8b0f87
 
772a72f
07990a2
5251bf1
 
f6a7bb1
 
5251bf1
b8b0f87
 
 
aabc5e5
 
 
b8b0f87
 
 
a16ad1e
b8b0f87
 
a16ad1e
b8b0f87
 
93acdbd
772a72f
f69fbea
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
import plotly.graph_objs as go

def create_charts(results):
    charts = {}
    explanations = {}
    general_impressions = {}
    
    for speaker_id, data in results.items():
        charts[speaker_id] = {}
        explanations[speaker_id] = {}
        
        # Extract general impression
        general_impressions[speaker_id] = data.get('general_impression', "No general impression provided.")

        # Attachment Styles
        attachment_data = data['attachments']
        labels = ['Secured', 'Anxious-Preoccupied', 'Dismissive-Avoidant', 'Fearful-Avoidant']
        values = [attachment_data.secured, attachment_data.anxious_preoccupied, 
                  attachment_data.dismissive_avoidant, attachment_data.fearful_avoidant]
        
        fig = go.Figure(data=[go.Bar(x=labels, y=values, marker_color=['blue', 'orange', 'green', 'red'])])
        fig.update_layout(title=f'{speaker_id}: Attachment Styles', yaxis_range=[0, 1])
        charts[speaker_id]['attachment'] = fig
        explanations[speaker_id]['attachment'] = attachment_data.explanation
        
        # Big Five Traits
        bigfive_data = data['bigfive']
        labels = ['Extraversion', 'Agreeableness', 'Conscientiousness', 'Neuroticism', 'Openness']
        values = [bigfive_data.extraversion, bigfive_data.agreeableness, 
                  bigfive_data.conscientiousness, bigfive_data.neuroticism, bigfive_data.openness]
        
        fig = go.Figure(data=[go.Bar(x=labels, y=values, marker_color=['blue', 'green', 'red', 'purple', 'orange'])])
        fig.update_layout(title=f'{speaker_id}: Big Five Traits', yaxis_range=[0, 10])
        charts[speaker_id]['bigfive'] = fig
        explanations[speaker_id]['bigfive'] = bigfive_data.explanation
        
        # Personality Disorders
        personality_data = data['personalities']
        labels = ['Depressed', 'Paranoid', 'Schizoid-Schizotypal', 'Antisocial-Psychopathic',
                  'Borderline-Dysregulated', 'Narcissistic', 'Anxious-Avoidant', 'Dependent-Victimized', 'Obsessional']
        values = [personality_data.depressed, personality_data.paranoid,
                  personality_data.schizoid_schizotypal, personality_data.antisocial_psychopathic,
                  personality_data.borderline_dysregulated, personality_data.narcissistic,
                  personality_data.anxious_avoidant, personality_data.dependent_victimized,
                  personality_data.obsessional]
        
        fig = go.Figure(data=[go.Bar(x=labels, y=values, marker_color=['black', 'orange', 'gray', 'green', 'brown', 'purple', 'red', 'cyan', 'magenta'])])
        fig.update_layout(title=f'{speaker_id}: Personality Disorders', yaxis_range=[0, 5])
        charts[speaker_id]['personality'] = fig
        explanations[speaker_id]['personality'] = personality_data.explanation

        # Attachment Dimensions (Radar Chart)
        dimensions_data = data['attachments']
        labels = ['Avoidance', 'Self', 'Anxiety', 'Others']
        values = [dimensions_data.avoidance, dimensions_data.self_model, dimensions_data.anxiety, dimensions_data.others_model]
        
        fig = go.Figure(data=go.Scatterpolar(
          r=values,
          theta=labels,
          fill='toself',
          marker=dict(color='black'),
          line=dict(color='black')
        ))
        fig.update_layout(
          polar=dict(
            radialaxis=dict(visible=True, range=[0, 10])
          ),
          showlegend=False,
          title=f'{speaker_id}: Attachment Dimensions'
        )
        charts[speaker_id]['dimensions'] = fig

    
    return charts, explanations, general_impressions