@@ -28,29 +28,30 @@ def parse_vtt_files(directory):
28
28
def classify_misogyny (sentences , model_pipeline ):
29
29
"""Classifies misogyny and non-misogyny scores for each sentence."""
30
30
misogyny_scores = []
31
- non_misogyny_scores = []
31
+ labels = []
32
32
33
33
with alive_bar (len (sentences ), title = "Processing Sentences" ) as bar :
34
34
for sentence in sentences :
35
35
result = model_pipeline (sentence )
36
36
37
37
# Default scores.
38
38
misogynist_score = 0
39
- non_misogynist_score = 0
39
+ label = "non-misogynist"
40
40
41
41
# Extract scores based on label.
42
42
for entry in result :
43
43
if entry ["label" ] == "misogynist" :
44
- # Negative for misogynistic.
45
44
misogynist_score = - entry ["score" ]
45
+ label = "misogynist"
46
46
elif entry ["label" ] == "non-misogynist" :
47
- non_misogynist_score = entry ["score" ]
47
+ misogynist_score = entry ["score" ]
48
+ label = "non-misogynist"
48
49
49
50
misogyny_scores .append (misogynist_score )
50
- non_misogyny_scores .append (non_misogynist_score )
51
+ labels .append (label )
51
52
bar ()
52
53
53
- return misogyny_scores , non_misogyny_scores
54
+ return misogyny_scores , labels
54
55
55
56
56
57
def plot_pie_chart (labels , sentences , output_filename , title ):
@@ -61,7 +62,7 @@ def plot_pie_chart(labels, sentences, output_filename, title):
61
62
non_misogynist_count = labels .count ("non-misogynist" )
62
63
63
64
# Data for pie chart.
64
- values = [misogynist_count , non_misogynist_count ]
65
+ values = [misogyny_count , non_misogynist_count ]
65
66
labels = ["Misogyny" , "Non Misogyny" ]
66
67
custom_colors = ["#ff1b6b" , "#45caff" ]
67
68
0 commit comments