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 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
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
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "9949dcdb",
   "metadata": {},
   "source": [
    "# Prepare SST data for gender annotation\n",
    "\n",
    "* Import SST data from huggingface\n",
    "* Use word lists to automatically annotate (pre-annotate?) sentences for gender\n",
    "* Subsample gendered sentences: 400 masculine, 400 feminine, 400 neutral\n",
    "* Prepare CSVs for human annotation"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "5badcb9d",
   "metadata": {},
   "source": [
    "## Import SST data from huggingface"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "022eb689",
   "metadata": {},
   "outputs": [],
   "source": [
    "import pandas as pd"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "1f0b6c0f",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "application/vnd.jupyter.widget-view+json": {
       "model_id": "846f46d502ab4b818dd0884151663b83",
       "version_major": 2,
       "version_minor": 0
      },
      "text/plain": [
       "Downloading builder script:   0%|          | 0.00/2.59k [00:00<?, ?B/s]"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "application/vnd.jupyter.widget-view+json": {
       "model_id": "938ebd31e7e44fec8cf6558c0b3467e4",
       "version_major": 2,
       "version_minor": 0
      },
      "text/plain": [
       "Downloading metadata:   0%|          | 0.00/1.17k [00:00<?, ?B/s]"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "No config specified, defaulting to: sst/default\n",
      "Reusing dataset sst (/Users/katygero/.cache/huggingface/datasets/sst/default/1.0.0/b8a7889ef01c5d3ae8c379b84cc4080f8aad3ac2bc538701cbe0ac6416fb76ff)\n"
     ]
    },
    {
     "data": {
      "application/vnd.jupyter.widget-view+json": {
       "model_id": "7ece2dc64d6b4207949652de2450479a",
       "version_major": 2,
       "version_minor": 0
      },
      "text/plain": [
       "  0%|          | 0/3 [00:00<?, ?it/s]"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "from datasets import load_dataset\n",
    "\n",
    "dataset = load_dataset(\"sst\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "453d8782",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'sentence': \"The Rock is destined to be the 21st Century 's new `` Conan '' and that he 's going to make a splash even greater than Arnold Schwarzenegger , Jean-Claud Van Damme or Steven Segal .\",\n",
       " 'label': 0.6944400072097778,\n",
       " 'tokens': \"The|Rock|is|destined|to|be|the|21st|Century|'s|new|``|Conan|''|and|that|he|'s|going|to|make|a|splash|even|greater|than|Arnold|Schwarzenegger|,|Jean-Claud|Van|Damme|or|Steven|Segal|.\",\n",
       " 'tree': '70|70|68|67|63|62|61|60|58|58|57|56|56|64|65|55|54|53|52|51|49|47|47|46|46|45|40|40|41|39|38|38|43|37|37|69|44|39|42|41|42|43|44|45|50|48|48|49|50|51|52|53|54|55|66|57|59|59|60|61|62|63|64|65|66|67|68|69|71|71|0'}"
      ]
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "#splits: ['test', 'train', 'validation']\n",
    "dataset['train'][0]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "5f44b9c0",
   "metadata": {},
   "outputs": [],
   "source": [
    "train = pd.DataFrame(dataset['train'])\n",
    "train['split'] = 'train'\n",
    "\n",
    "val = pd.DataFrame(dataset['validation'])\n",
    "val['split'] = 'validation'\n",
    "\n",
    "test = pd.DataFrame(dataset['test'])\n",
    "test['split'] = 'test'\n",
    "\n",
    "data = pd.concat([train, val, test])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "bfc658d6",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>sentence</th>\n",
       "      <th>label</th>\n",
       "      <th>tokens</th>\n",
       "      <th>tree</th>\n",
       "      <th>split</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>The Rock is destined to be the 21st Century 's...</td>\n",
       "      <td>0.694440</td>\n",
       "      <td>The|Rock|is|destined|to|be|the|21st|Century|'s...</td>\n",
       "      <td>70|70|68|67|63|62|61|60|58|58|57|56|56|64|65|5...</td>\n",
       "      <td>train</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>The gorgeously elaborate continuation of `` Th...</td>\n",
       "      <td>0.833330</td>\n",
       "      <td>The|gorgeously|elaborate|continuation|of|``|Th...</td>\n",
       "      <td>71|70|69|69|67|67|66|64|63|62|62|61|61|58|57|5...</td>\n",
       "      <td>train</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>Singer\\/composer Bryan Adams contributes a sle...</td>\n",
       "      <td>0.625000</td>\n",
       "      <td>Singer\\/composer|Bryan|Adams|contributes|a|sle...</td>\n",
       "      <td>72|71|71|70|68|68|67|67|66|63|62|62|60|60|58|5...</td>\n",
       "      <td>train</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>You 'd think by now America would have had eno...</td>\n",
       "      <td>0.500000</td>\n",
       "      <td>You|'d|think|by|now|America|would|have|had|eno...</td>\n",
       "      <td>36|35|34|33|33|32|30|29|27|26|25|24|23|23|22|2...</td>\n",
       "      <td>train</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>Yet the act is still charming here .</td>\n",
       "      <td>0.722220</td>\n",
       "      <td>Yet|the|act|is|still|charming|here|.</td>\n",
       "      <td>15|13|13|10|9|9|11|12|10|11|12|14|14|15|0</td>\n",
       "      <td>train</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2205</th>\n",
       "      <td>An imaginative comedy\\/thriller .</td>\n",
       "      <td>0.777780</td>\n",
       "      <td>An|imaginative|comedy\\/thriller|.</td>\n",
       "      <td>7|6|5|5|6|7|0</td>\n",
       "      <td>test</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2206</th>\n",
       "      <td>( A ) rare , beautiful film .</td>\n",
       "      <td>0.916670</td>\n",
       "      <td>(|A|)|rare|,|beautiful|film|.</td>\n",
       "      <td>13|12|12|11|10|9|9|15|10|11|14|13|14|15|0</td>\n",
       "      <td>test</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2207</th>\n",
       "      <td>( An ) hilarious romantic comedy .</td>\n",
       "      <td>0.888890</td>\n",
       "      <td>(|An|)|hilarious|romantic|comedy|.</td>\n",
       "      <td>12|11|11|9|8|8|10|9|10|13|12|13|0</td>\n",
       "      <td>test</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2208</th>\n",
       "      <td>Never ( sinks ) into exploitation .</td>\n",
       "      <td>0.625000</td>\n",
       "      <td>Never|(|sinks|)|into|exploitation|.</td>\n",
       "      <td>11|10|9|9|8|8|13|12|10|11|12|13|0</td>\n",
       "      <td>test</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2209</th>\n",
       "      <td>( U ) nrelentingly stupid .</td>\n",
       "      <td>0.069444</td>\n",
       "      <td>(|U|)|nrelentingly|stupid|.</td>\n",
       "      <td>10|9|9|7|7|8|8|11|10|11|0</td>\n",
       "      <td>test</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>11855 rows × 5 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "                                               sentence     label  \\\n",
       "0     The Rock is destined to be the 21st Century 's...  0.694440   \n",
       "1     The gorgeously elaborate continuation of `` Th...  0.833330   \n",
       "2     Singer\\/composer Bryan Adams contributes a sle...  0.625000   \n",
       "3     You 'd think by now America would have had eno...  0.500000   \n",
       "4                  Yet the act is still charming here .  0.722220   \n",
       "...                                                 ...       ...   \n",
       "2205                  An imaginative comedy\\/thriller .  0.777780   \n",
       "2206                      ( A ) rare , beautiful film .  0.916670   \n",
       "2207                 ( An ) hilarious romantic comedy .  0.888890   \n",
       "2208                Never ( sinks ) into exploitation .  0.625000   \n",
       "2209                        ( U ) nrelentingly stupid .  0.069444   \n",
       "\n",
       "                                                 tokens  \\\n",
       "0     The|Rock|is|destined|to|be|the|21st|Century|'s...   \n",
       "1     The|gorgeously|elaborate|continuation|of|``|Th...   \n",
       "2     Singer\\/composer|Bryan|Adams|contributes|a|sle...   \n",
       "3     You|'d|think|by|now|America|would|have|had|eno...   \n",
       "4                  Yet|the|act|is|still|charming|here|.   \n",
       "...                                                 ...   \n",
       "2205                  An|imaginative|comedy\\/thriller|.   \n",
       "2206                      (|A|)|rare|,|beautiful|film|.   \n",
       "2207                 (|An|)|hilarious|romantic|comedy|.   \n",
       "2208                Never|(|sinks|)|into|exploitation|.   \n",
       "2209                        (|U|)|nrelentingly|stupid|.   \n",
       "\n",
       "                                                   tree  split  \n",
       "0     70|70|68|67|63|62|61|60|58|58|57|56|56|64|65|5...  train  \n",
       "1     71|70|69|69|67|67|66|64|63|62|62|61|61|58|57|5...  train  \n",
       "2     72|71|71|70|68|68|67|67|66|63|62|62|60|60|58|5...  train  \n",
       "3     36|35|34|33|33|32|30|29|27|26|25|24|23|23|22|2...  train  \n",
       "4             15|13|13|10|9|9|11|12|10|11|12|14|14|15|0  train  \n",
       "...                                                 ...    ...  \n",
       "2205                                      7|6|5|5|6|7|0   test  \n",
       "2206          13|12|12|11|10|9|9|15|10|11|14|13|14|15|0   test  \n",
       "2207                  12|11|11|9|8|8|10|9|10|13|12|13|0   test  \n",
       "2208                  11|10|9|9|8|8|13|12|10|11|12|13|0   test  \n",
       "2209                          10|9|9|7|7|8|8|11|10|11|0   test  \n",
       "\n",
       "[11855 rows x 5 columns]"
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "pd.set_option('display.max_colwidth', 50)\n",
    "data"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "ee3a4945",
   "metadata": {},
   "source": [
    "## Loosely annotate sentences (masc, femme, neutral) using word lists"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "id": "0e85a47a",
   "metadata": {},
   "outputs": [],
   "source": [
    "gender_words = {\n",
    "    'femm': ['she', 'her', 'hers', 'mum', 'mom', 'mother', 'daughter', 'sister', 'niece', 'aunt', 'grandmother',\n",
    "             'lady', 'woman', 'girl', \"ma'am\", 'female', 'wife', 'ms', 'miss', 'mrs', 'ms.', 'mrs.'],\n",
    "    'masc': ['he', 'him', 'his', 'dad', 'father', 'son', 'brother', 'nephew', 'uncle', 'grandfather',\n",
    "             'gentleman', 'man', 'boy', 'sir', 'male', 'husband', 'mr', 'mr.'],\n",
    "    'neut': ['they', 'them', 'theirs', 'parent', 'child', 'sibling',\n",
    "             'person', 'spouse']\n",
    "}\n",
    "\n",
    "def label_gender(row):\n",
    "    tokens = row['tokens'].lower().split('|')\n",
    "    gender = 'none'\n",
    "    for key, words in gender_words.items():\n",
    "        for w in words:\n",
    "            if w in tokens or w+\"s\" in tokens:\n",
    "                if gender == 'none':\n",
    "                    gender = key\n",
    "                else:\n",
    "                    gender = 'mixed'\n",
    "                break\n",
    "    return gender\n",
    "\n",
    "data['gender'] = data.apply(lambda row: label_gender(row), axis=1)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "id": "46e8b885",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "none     10001\n",
       "masc       931\n",
       "neut       420\n",
       "femm       372\n",
       "mixed      131\n",
       "Name: gender, dtype: int64"
      ]
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "data['gender'].value_counts()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "id": "91233c13",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "none     8113\n",
       "masc      743\n",
       "neut      350\n",
       "femm      303\n",
       "mixed     104\n",
       "Name: gender, dtype: int64"
      ]
     },
     "execution_count": 8,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "data_polarized = data[(data['label']>.6)|(data['label']<.4)]\n",
    "data_polarized['gender'].value_counts()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "id": "8a7a12bb",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>sentence</th>\n",
       "      <th>label</th>\n",
       "      <th>gender</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>The Rock is destined to be the 21st Century 's new `` Conan '' and that he 's going to make a splash even greater than Arnold Schwarzenegger , Jean-Claud Van Damme or Steven Segal .</td>\n",
       "      <td>0.69444</td>\n",
       "      <td>masc</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>43</th>\n",
       "      <td>`` Auto Focus '' works as an unusual biopic and document of male swingers in the Playboy era</td>\n",
       "      <td>0.65278</td>\n",
       "      <td>masc</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>44</th>\n",
       "      <td>If Mr. Zhang 's subject matter is , to some degree at least , quintessentially American , his approach to storytelling might be called Iranian .</td>\n",
       "      <td>0.52778</td>\n",
       "      <td>masc</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>52</th>\n",
       "      <td>( City ) reminds us how realistically nuanced a Robert De Niro performance can be when he is not more lucratively engaged in the shameless self-caricature of ` Analyze This ' ( 1999 ) and ` Analyze That , ' promised ( or threatened ) for later this year .</td>\n",
       "      <td>0.63889</td>\n",
       "      <td>masc</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>90</th>\n",
       "      <td>Allen shows he can outgag any of those young whippersnappers making moving pictures today .</td>\n",
       "      <td>0.76389</td>\n",
       "      <td>masc</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>98</th>\n",
       "      <td>It celebrates the group 's playful spark of nonconformity , glancing vividly back at what Hibiscus grandly called his ` angels of light . '</td>\n",
       "      <td>0.72222</td>\n",
       "      <td>masc</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>136</th>\n",
       "      <td>Writer\\/director Alexander Payne ( Election ) and his co-writer Jim Taylor brilliantly employ their quirky and fearless ability to look American angst in the eye and end up laughing .</td>\n",
       "      <td>0.75000</td>\n",
       "      <td>masc</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>141</th>\n",
       "      <td>Pacino is the best he 's been in years and Keener is marvelous .</td>\n",
       "      <td>0.88889</td>\n",
       "      <td>masc</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>146</th>\n",
       "      <td>So purely enjoyable that you might not even notice it 's a fairly straightforward remake of Hollywood comedies such as Father of the Bride .</td>\n",
       "      <td>0.79167</td>\n",
       "      <td>masc</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>150</th>\n",
       "      <td>Robin Williams has thankfully ditched the saccharine sentimentality of Bicentennial Man in favour of an altogether darker side .</td>\n",
       "      <td>0.63889</td>\n",
       "      <td>masc</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>153</th>\n",
       "      <td>Hoffman 's performance is authentic to the core of his being .</td>\n",
       "      <td>0.73611</td>\n",
       "      <td>masc</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>168</th>\n",
       "      <td>Too often , Son of the Bride becomes an exercise in trying to predict when a preordained `` big moment '' will occur and not `` if . ''</td>\n",
       "      <td>0.30556</td>\n",
       "      <td>masc</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>170</th>\n",
       "      <td>A solid piece of journalistic work that draws a picture of a man for whom political expedience became a deadly foreign policy .</td>\n",
       "      <td>0.54167</td>\n",
       "      <td>masc</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>181</th>\n",
       "      <td>In The Pianist , Polanski is saying what he has long wanted to say , confronting the roots of his own preoccupations and obsessions , and he allows nothing to get in the way .</td>\n",
       "      <td>0.72222</td>\n",
       "      <td>masc</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>194</th>\n",
       "      <td>With Dirty Deeds , David Caesar has stepped into the mainstream of filmmaking with an assurance worthy of international acclaim and with every cinematic tool well under his control -- driven by a natural sense for what works on screen .</td>\n",
       "      <td>0.81944</td>\n",
       "      <td>masc</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>230</th>\n",
       "      <td>What 's not to like about a movie with a ` children 's ' song that includes the line ` My stepdad 's not mean , he 's just adjusting ' ?</td>\n",
       "      <td>0.72222</td>\n",
       "      <td>masc</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>231</th>\n",
       "      <td>This English-language version ... does full honor to Miyazaki 's teeming and often unsettling landscape , and to the conflicted complexity of his characters .</td>\n",
       "      <td>0.58333</td>\n",
       "      <td>masc</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>240</th>\n",
       "      <td>In its dry and forceful way , it delivers the same message as Jiri Menzel 's Closely Watched Trains and Danis Tanovic 's No Man 's Land .</td>\n",
       "      <td>0.68056</td>\n",
       "      <td>masc</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>249</th>\n",
       "      <td>Beresford nicely mixes in as much humor as pathos to take us on his sentimental journey of the heart .</td>\n",
       "      <td>0.62500</td>\n",
       "      <td>masc</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>255</th>\n",
       "      <td>Visually fascinating ... an often intense character study about fathers and sons , loyalty and duty .</td>\n",
       "      <td>0.70833</td>\n",
       "      <td>masc</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                                                                                                                                                                                                                                                            sentence  \\\n",
       "0                                                                              The Rock is destined to be the 21st Century 's new `` Conan '' and that he 's going to make a splash even greater than Arnold Schwarzenegger , Jean-Claud Van Damme or Steven Segal .   \n",
       "43                                                                                                                                                                      `` Auto Focus '' works as an unusual biopic and document of male swingers in the Playboy era   \n",
       "44                                                                                                                  If Mr. Zhang 's subject matter is , to some degree at least , quintessentially American , his approach to storytelling might be called Iranian .   \n",
       "52   ( City ) reminds us how realistically nuanced a Robert De Niro performance can be when he is not more lucratively engaged in the shameless self-caricature of ` Analyze This ' ( 1999 ) and ` Analyze That , ' promised ( or threatened ) for later this year .   \n",
       "90                                                                                                                                                                       Allen shows he can outgag any of those young whippersnappers making moving pictures today .   \n",
       "98                                                                                                                       It celebrates the group 's playful spark of nonconformity , glancing vividly back at what Hibiscus grandly called his ` angels of light . '   \n",
       "136                                                                          Writer\\/director Alexander Payne ( Election ) and his co-writer Jim Taylor brilliantly employ their quirky and fearless ability to look American angst in the eye and end up laughing .   \n",
       "141                                                                                                                                                                                                 Pacino is the best he 's been in years and Keener is marvelous .   \n",
       "146                                                                                                                     So purely enjoyable that you might not even notice it 's a fairly straightforward remake of Hollywood comedies such as Father of the Bride .   \n",
       "150                                                                                                                                 Robin Williams has thankfully ditched the saccharine sentimentality of Bicentennial Man in favour of an altogether darker side .   \n",
       "153                                                                                                                                                                                                   Hoffman 's performance is authentic to the core of his being .   \n",
       "168                                                                                                                          Too often , Son of the Bride becomes an exercise in trying to predict when a preordained `` big moment '' will occur and not `` if . ''   \n",
       "170                                                                                                                                  A solid piece of journalistic work that draws a picture of a man for whom political expedience became a deadly foreign policy .   \n",
       "181                                                                                  In The Pianist , Polanski is saying what he has long wanted to say , confronting the roots of his own preoccupations and obsessions , and he allows nothing to get in the way .   \n",
       "194                     With Dirty Deeds , David Caesar has stepped into the mainstream of filmmaking with an assurance worthy of international acclaim and with every cinematic tool well under his control -- driven by a natural sense for what works on screen .   \n",
       "230                                                                                                                         What 's not to like about a movie with a ` children 's ' song that includes the line ` My stepdad 's not mean , he 's just adjusting ' ?   \n",
       "231                                                                                                   This English-language version ... does full honor to Miyazaki 's teeming and often unsettling landscape , and to the conflicted complexity of his characters .   \n",
       "240                                                                                                                        In its dry and forceful way , it delivers the same message as Jiri Menzel 's Closely Watched Trains and Danis Tanovic 's No Man 's Land .   \n",
       "249                                                                                                                                                           Beresford nicely mixes in as much humor as pathos to take us on his sentimental journey of the heart .   \n",
       "255                                                                                                                                                            Visually fascinating ... an often intense character study about fathers and sons , loyalty and duty .   \n",
       "\n",
       "       label gender  \n",
       "0    0.69444   masc  \n",
       "43   0.65278   masc  \n",
       "44   0.52778   masc  \n",
       "52   0.63889   masc  \n",
       "90   0.76389   masc  \n",
       "98   0.72222   masc  \n",
       "136  0.75000   masc  \n",
       "141  0.88889   masc  \n",
       "146  0.79167   masc  \n",
       "150  0.63889   masc  \n",
       "153  0.73611   masc  \n",
       "168  0.30556   masc  \n",
       "170  0.54167   masc  \n",
       "181  0.72222   masc  \n",
       "194  0.81944   masc  \n",
       "230  0.72222   masc  \n",
       "231  0.58333   masc  \n",
       "240  0.68056   masc  \n",
       "249  0.62500   masc  \n",
       "255  0.70833   masc  "
      ]
     },
     "execution_count": 14,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "pd.set_option('display.max_colwidth', None)\n",
    "pd.set_option('display.max_rows', None)\n",
    "data[['sentence', 'label', 'gender']][data['gender'] == 'masc'][:20]"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "b544c0c9",
   "metadata": {},
   "source": [
    "## Look at distribution of data"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 98,
   "id": "9eaa3478",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<AxesSubplot:xlabel='gender', ylabel='label'>"
      ]
     },
     "execution_count": 98,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAYIAAAEGCAYAAABo25JHAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjQuMywgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy/MnkTPAAAACXBIWXMAAAsTAAALEwEAmpwYAAAUe0lEQVR4nO3df7RdZX3n8feHxIgi6mAiUqCG0ogr/iiOEXUYxTqUFaaaLBVbsFSZOhM706itWovLDmsNzI8CS+1UmBmjZYmOiOBYvbaxGX8ATqk4uSCFBhqIASVYhiA/ilSFkO/8cXbI4XpvchPuvic3z/u1Vlb2fvZz9vnunZPzOXvvs5+TqkKS1K4DRl2AJGm0DAJJapxBIEmNMwgk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EQSAPHA1/qbvX/SZIvMxhpdFejan6xqrYDNyU5tGt7NfDZqnoU+EGSb3TtxzAYguSr3brmAX8/tK7P9bBN0rQYBNLUDmDqUTXh8SNRZoo+w8s3VNUrp1j+0BTtUu+8RiANXA28PsmB3S9GvQ74R6YeVXMq3wR+PYNfZzsM+OWufSOwKMkru3U9KckLetkSaQ8ZBBJQVesZnOe/AfgKgx+ReYCpR9Wcyp8BtzK4NvApBqNLUlUPA6cA53brup7BaSdp5Bx9VOokeVpV/SjJUxl8sl9VVdeNui6pb14jkHZak2Qpg4vEFxsCaoVHBJLUOK8RSFLjDAJJapxBIEmNMwgkqXEGgSQ17v8D3HmV/8CE+BwAAAAASUVORK5CYII=\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "%matplotlib inline\n",
    "import seaborn as sns\n",
    "\n",
    "sns.barplot(data=data, x='gender', y='label')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 99,
   "id": "379620ab",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<AxesSubplot:xlabel='gender', ylabel='count'>"
      ]
     },
     "execution_count": 99,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAZEAAAEGCAYAAACkQqisAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjQuMywgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy/MnkTPAAAACXBIWXMAAAsTAAALEwEAmpwYAAAVjUlEQVR4nO3dfbRddZ3f8feHZ8WRB0lTJNAwmsEFPoBmAIf6UHEBMkrQQQZHJShtbAcZnWo72mmlC6SVOg7yUJ3JSCRYBwREiY4OzfBkhwqSAAMExGSBShAkGkTUBTb47R/nd80B7w03m3vOyeW+X2uddff+7d/e9/fbObmfsx/Ob6eqkCSpi61G3QBJ0vRliEiSOjN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gWuT/BPwl8Nu7AAsBD6e5FZgf3rXRTblM8AdwE1Jbgf+mun3qRt6R6DbAre2Uxinjbg9W6K3Aye29/oqNj4T6G+A17TyVwI/b+W3Ao+nd9PJtLiwvjmSbE+v7++uqh8AH6B3/eRH9D6AXtj+H30TeFFVPUrv9NXftQvrDw61ve0CjSRJm80jEUlSZ4aIJKkzQ0SS1JkhIknqzBCRJHVmiEhbsCePHyVtaQwR6RkkyXT8Lo2mMUNEmiJJ/kuSu5L8Y5ILk3zwKUaoPTu9EZ3vHjvaaN/YPrdt5x+Af9a3/VckubZt64oku7fya5J8MskKeoM0SkPjpxZpCiT5XeAPgJfR+4b6TfQGGFxMb3Te1W28rE8Br2ur7Q78S3oD6C0DLgXeDOxDb6C92fS+tb+kDf9yDrCgqtYl+UN6oxq8u21ru6qaP/COSk9iiEhT4xDg8jYExaNJvkJvxN5NjVD75ar6FXBHktmt7NXAhVX1OPCDJFe18n3oDYuzvG1ra+D+vm19YQB9kp6SISINzlZMPEItPHFU10xQp3/5qqp65QTLfz5BuTRQXhORpsZ1wJuS7NCeNvdG4BdMPELtRL4B/GF6T3bcHfhXrfwuYFaSV7ZtbZtkv4H0RNoMhog0BarqRnrXNW4Fvk7vAVIPM/EItRP5ErCa3rWQC+iN1EpV/RI4BjijbesWeqfKpJFyFF9piiR5TlX9LMmz6R1RLKqqm0bdLmmQvCYiTZ3FSfald0F9qQGimcAjEUlSZ14TkSR1ZohIkjozRCRJnRkikqTODBFJUmf/H0dYGqY99ghaAAAAAElFTkSuQmCC\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "sns.countplot(data=data, x='gender')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 100,
   "id": "bd177487",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<AxesSubplot:xlabel='gender', ylabel='count'>"
      ]
     },
     "execution_count": 100,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAYUAAAEGCAYAAACKB4k+AAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjQuMywgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy/MnkTPAAAACXBIWXMAAAsTAAALEwEAmpwYAAARvklEQVR4nO3debAlZX3G8e8Dw6KoIHBDkMEMKsHCFR0RJS4Ry7gyLrgroKTGVNzRRBIrmtKYSGLELTE1igpGjYoLo3EJYTMSRWcAQUBlChcGUUZFRC00o7/8cd55uQx34A7evn1n5vupOnW7336753d6zr3P6e7T70lVIUkSwHZjFyBJWjgMBUlSZyhIkjpDQZLUGQqSpG7R2AX8Lvbcc89asmTJ2GVI0hZl9erVP6qqqZmWbdGhsGTJElatWjV2GZK0RUny3U0t8/SRJKkzFCRJnaEgSeoMBUlSZyhIkjpDQZLUGQqSpM5QkCR1hoIkqdui72i+Jff/i5PHLmHBWP1PR45dgqQtgEcKkqTOUJAkdYaCJKkzFCRJnaEgSeoMBUlSZyhIkjpDQZLUGQqSpM5QkCR1hoIkqTMUJEmdoSBJ6gwFSVJnKEiSOkNBktQZCpKkzlCQJHWGgiSpMxQkSZ2hIEnqDAVJUmcoSJI6Q0GS1BkKkqRu0FBI8vIkFyf5epIPJdk5yX5Jzk2yJsmHk+zY+u7U5te05UuGrE2SdFODhUKSfYCXAEur6p7A9sAzgOOBE6rqbsA1wDFtlWOAa1r7Ca2fJGkeDX36aBFwmySLgNsCVwGPAE5py08Cntiml7V52vLDkmTg+iRJ0wwWClV1JfAm4HtMwuBaYDXw06pa37qtBfZp0/sAV7R117f+e2y83STLk6xKsmrdunVDlS9J26QhTx/dkcm7//2AOwG7AI/+XbdbVSuqamlVLZ2amvpdNydJmmbI00ePBL5dVeuq6v+AjwOHAru100kAi4Er2/SVwL4AbfmuwI8HrE+StJEhQ+F7wCFJbtuuDRwGXAKcCRzR+hwFnNqmV7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UnuAlxeVW8DTmXybvcM4KlJ9mh9dp/fUkf3eeDFaW+nkhw0cj1bq58B307yVIBM3Kct+w5w/zZ9ODcc2V7H5PSdbkaSg5l8F8xBwCuT7Ad8GTg0yd1an12S/CHwDWBJkru21Z850zbHYigM5x+Bf0hyPjd+V/E04OtJLgDuCZxck+E83gCcneRrwJvnu9iRvZ7JH6EL22H660euZ2v2bOCY9jq7mBu+s+RdwMNa+4OAX7T2C4HftA9AbDMXmjdHkp2Y7L/nV9X3gVcwuf7wIyZvCD+U5ELaqaOqup7J6aL/bBearx6l8E1wmAtJUueRgiSpMxQkSZ2hIEnqDAVJUmcoSJI6Q0GaJxuPLyQtRIaCtEAl2VbvxNaIDAVpBkn+Jsk3k3wxyYeSvPIWRhh9Wyaj4V6+4Wig3TH8jrad/wZ+b9r275/k7LatzyfZu7WfleQtSVYxGdxPmle+E5E2kuQBwFOA+zC50/o8JgPKrWAySutlbVymfwUe0VbbG/gjJoOdrQROAZ4EHMBkULS9gEuA9yTZgcloucuqal2SpzO5o/35bVs7VtXSwZ+oNANDQbqpQ4FT23AE1yf5FJORW29uhNFPVtVvgUuS7NXaHgp8qKp+A3w/yRmt/QAmQ5yc1ra1PXDVtG19eIDnJM2KoSDNznZseoRRuPGImtlEn+nLL66qB21i+S820S4NzmsK0k2dAzwhyc7tm7IeD/ySTY8wuilfAJ6eZPt2zeCPW/s3gakkD2rb2iHJPQZ5JtJmMhSkjVTVV5lcF7gQ+CyTL+65lk2PMLopnwAuY3It4WQmo2RSVb8GjgCOb9u6gMmpKWl0jpIqzSDJ7arq50luy+Qd//KqOm/suqSheU1BmtmKJAcyucB8koGgbYVHCpKkzmsKkqTOUJAkdYaCJKkzFCRJnaEgSer+H7cvxSsW7kGkAAAAAElFTkSuQmCC\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "sns.countplot(data=data[data['gender']!='none'], x='gender')"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "c675abea",
   "metadata": {},
   "source": [
    "## Subsample for 400 from each category (masc, femm, neut)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "id": "fc4a6180",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>index</th>\n",
       "      <th>sentence</th>\n",
       "      <th>label</th>\n",
       "      <th>tokens</th>\n",
       "      <th>tree</th>\n",
       "      <th>split</th>\n",
       "      <th>gender</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>8204</td>\n",
       "      <td>As pedestrian as they come .</td>\n",
       "      <td>0.18056</td>\n",
       "      <td>As|pedestrian|as|they|come|.</td>\n",
       "      <td>10|9|9|8|7|7|8|11|10|11|0</td>\n",
       "      <td>train</td>\n",
       "      <td>neut</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>2150</td>\n",
       "      <td>Oft-described as the antidote to American Pie-...</td>\n",
       "      <td>0.33333</td>\n",
       "      <td>Oft-described|as|the|antidote|to|American|Pie-...</td>\n",
       "      <td>55|54|53|53|52|51|50|49|49|48|47|46|43|41|41|4...</td>\n",
       "      <td>test</td>\n",
       "      <td>neut</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>3960</td>\n",
       "      <td>I have a confession to make : I did n't partic...</td>\n",
       "      <td>0.25000</td>\n",
       "      <td>I|have|a|confession|to|make|:|I|did|n't|partic...</td>\n",
       "      <td>44|43|42|41|40|40|45|39|36|36|37|34|34|32|31|3...</td>\n",
       "      <td>train</td>\n",
       "      <td>masc</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>1308</td>\n",
       "      <td>Either a fascinating study of the relationship...</td>\n",
       "      <td>0.50000</td>\n",
       "      <td>Either|a|fascinating|study|of|the|relationship...</td>\n",
       "      <td>42|38|37|37|36|34|34|33|33|40|30|30|31|28|27|2...</td>\n",
       "      <td>train</td>\n",
       "      <td>femm</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>2272</td>\n",
       "      <td>Manages to please its intended audience -- chi...</td>\n",
       "      <td>0.72222</td>\n",
       "      <td>Manages|to|please|its|intended|audience|--|chi...</td>\n",
       "      <td>35|33|31|29|28|28|27|26|26|25|23|22|22|21|20|1...</td>\n",
       "      <td>train</td>\n",
       "      <td>neut</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1167</th>\n",
       "      <td>5807</td>\n",
       "      <td>( Janey ) forgets about her other obligations ...</td>\n",
       "      <td>0.23611</td>\n",
       "      <td>(|Janey|)|forgets|about|her|other|obligations|...</td>\n",
       "      <td>74|73|73|69|68|67|66|66|70|65|64|62|62|61|57|5...</td>\n",
       "      <td>train</td>\n",
       "      <td>femm</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1168</th>\n",
       "      <td>7125</td>\n",
       "      <td>It 's a frightful vanity film that , no doubt ...</td>\n",
       "      <td>0.11111</td>\n",
       "      <td>It|'s|a|frightful|vanity|film|that|,|no|doubt|...</td>\n",
       "      <td>43|41|39|38|37|37|36|35|33|33|32|30|30|29|27|2...</td>\n",
       "      <td>train</td>\n",
       "      <td>neut</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1169</th>\n",
       "      <td>143</td>\n",
       "      <td>It 's a hoot and a half , and a great way for ...</td>\n",
       "      <td>0.79167</td>\n",
       "      <td>It|'s|a|hoot|and|a|half|,|and|a|great|way|for|...</td>\n",
       "      <td>67|64|58|58|59|57|57|61|62|55|54|54|53|52|51|5...</td>\n",
       "      <td>test</td>\n",
       "      <td>masc</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1170</th>\n",
       "      <td>4452</td>\n",
       "      <td>Eventually , they will have a showdown , but ,...</td>\n",
       "      <td>0.18056</td>\n",
       "      <td>Eventually|,|they|will|have|a|showdown|,|but|,...</td>\n",
       "      <td>61|60|52|51|50|49|49|53|54|55|47|47|46|44|44|4...</td>\n",
       "      <td>train</td>\n",
       "      <td>neut</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1171</th>\n",
       "      <td>2812</td>\n",
       "      <td>Instead , she sees it as a chance to revitaliz...</td>\n",
       "      <td>0.68056</td>\n",
       "      <td>Instead|,|she|sees|it|as|a|chance|to|revitaliz...</td>\n",
       "      <td>41|40|39|36|36|35|34|33|32|31|30|28|28|27|26|2...</td>\n",
       "      <td>train</td>\n",
       "      <td>femm</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>1172 rows × 7 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "      index                                           sentence    label  \\\n",
       "0      8204                       As pedestrian as they come .  0.18056   \n",
       "1      2150  Oft-described as the antidote to American Pie-...  0.33333   \n",
       "2      3960  I have a confession to make : I did n't partic...  0.25000   \n",
       "3      1308  Either a fascinating study of the relationship...  0.50000   \n",
       "4      2272  Manages to please its intended audience -- chi...  0.72222   \n",
       "...     ...                                                ...      ...   \n",
       "1167   5807  ( Janey ) forgets about her other obligations ...  0.23611   \n",
       "1168   7125  It 's a frightful vanity film that , no doubt ...  0.11111   \n",
       "1169    143  It 's a hoot and a half , and a great way for ...  0.79167   \n",
       "1170   4452  Eventually , they will have a showdown , but ,...  0.18056   \n",
       "1171   2812  Instead , she sees it as a chance to revitaliz...  0.68056   \n",
       "\n",
       "                                                 tokens  \\\n",
       "0                          As|pedestrian|as|they|come|.   \n",
       "1     Oft-described|as|the|antidote|to|American|Pie-...   \n",
       "2     I|have|a|confession|to|make|:|I|did|n't|partic...   \n",
       "3     Either|a|fascinating|study|of|the|relationship...   \n",
       "4     Manages|to|please|its|intended|audience|--|chi...   \n",
       "...                                                 ...   \n",
       "1167  (|Janey|)|forgets|about|her|other|obligations|...   \n",
       "1168  It|'s|a|frightful|vanity|film|that|,|no|doubt|...   \n",
       "1169  It|'s|a|hoot|and|a|half|,|and|a|great|way|for|...   \n",
       "1170  Eventually|,|they|will|have|a|showdown|,|but|,...   \n",
       "1171  Instead|,|she|sees|it|as|a|chance|to|revitaliz...   \n",
       "\n",
       "                                                   tree  split gender  \n",
       "0                             10|9|9|8|7|7|8|11|10|11|0  train   neut  \n",
       "1     55|54|53|53|52|51|50|49|49|48|47|46|43|41|41|4...   test   neut  \n",
       "2     44|43|42|41|40|40|45|39|36|36|37|34|34|32|31|3...  train   masc  \n",
       "3     42|38|37|37|36|34|34|33|33|40|30|30|31|28|27|2...  train   femm  \n",
       "4     35|33|31|29|28|28|27|26|26|25|23|22|22|21|20|1...  train   neut  \n",
       "...                                                 ...    ...    ...  \n",
       "1167  74|73|73|69|68|67|66|66|70|65|64|62|62|61|57|5...  train   femm  \n",
       "1168  43|41|39|38|37|37|36|35|33|33|32|30|30|29|27|2...  train   neut  \n",
       "1169  67|64|58|58|59|57|57|61|62|55|54|54|53|52|51|5...   test   masc  \n",
       "1170  61|60|52|51|50|49|49|53|54|55|47|47|46|44|44|4...  train   neut  \n",
       "1171  41|40|39|36|36|35|34|33|32|31|30|28|28|27|26|2...  train   femm  \n",
       "\n",
       "[1172 rows x 7 columns]"
      ]
     },
     "execution_count": 17,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "subbed_data = []\n",
    "for genderword in ['masc', 'femm', 'neut']:\n",
    "    local_data = data[data['gender'] == genderword]\n",
    "    if local_data.shape[0] < 400:\n",
    "        subbed_data.append(local_data)\n",
    "    else:\n",
    "        subbed_data.append(local_data.sample(n=400, replace=False))\n",
    "        \n",
    "# shuffle data using '.sample(frac=1)'\n",
    "subsample_data = pd.concat(subbed_data).sample(frac=1).reset_index()\n",
    "\n",
    "\n",
    "pd.reset_option('^display.', silent=True)\n",
    "\n",
    "subsample_data"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "68dd053c",
   "metadata": {},
   "source": [
    "## Sample 99 sentences for each annotator as test run"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "id": "c6a11844",
   "metadata": {},
   "outputs": [],
   "source": [
    "idx = 0\n",
    "c = 99  # count\n",
    "for annotator in ['katy', 'fatma', 'anna', 'nathan', 'aashka']:\n",
    "    subset = subsample_data.loc[idx:idx+c, ['index', 'sentence', 'label', 'gender']]\n",
    "    subset.to_csv(f\"sentiment-bias-annotations_{annotator}_{idx}-{idx+c}.csv\", float_format='{:,.2f}'.format, index_label='annotation_index')\n",
    "    idx += int(c/3)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "a9b8639b",
   "metadata": {},
   "source": [
    "## Prepare rest of annotations"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "id": "416bcaa3",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "total_datapoints 787\n",
      "total_annotations 2361\n",
      "annotations_per_person 590.25\n",
      "completed_annotations 396\n",
      "remaining_annotations_per_person 491.25\n"
     ]
    }
   ],
   "source": [
    "rawdata = pd.read_csv('sentiment_data_for_annotation.csv')\n",
    "\n",
    "info = {\n",
    "    'total_datapoints': rawdata.shape[0],\n",
    "    'total_annotations': rawdata.shape[0] * 3,\n",
    "    'annotations_per_person': rawdata.shape[0] * 3/4,\n",
    "    'completed_annotations': 99*4,\n",
    "    'remaining_annotations_per_person': (rawdata.shape[0] * 3 - 99*4)/4\n",
    "}\n",
    "\n",
    "for key, val in info.items():\n",
    "    print(key, val)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "id": "32c173b8",
   "metadata": {},
   "outputs": [],
   "source": [
    "c = 591\n",
    "start = 0\n",
    "total = rawdata.shape[0]\n",
    "\n",
    "for annotator in ['katy', 'fatma', 'anna', 'nathan']:\n",
    "    end = start + c\n",
    "    subset = rawdata.loc[start:end, ['index', 'sentence', 'label', 'gender']]\n",
    "    \n",
    "    if end > total:\n",
    "        looped_idx = end - total\n",
    "        second_subset = rawdata.loc[:looped_idx, ['index', 'sentence', 'label', 'gender']]\n",
    "        subset = pd.concat([subset, second_subset])\n",
    "        end = looped_idx\n",
    "        \n",
    "    subset.to_csv(f\"sst-annotations-v3_{annotator}_{start}-{end}.csv\", \n",
    "                  float_format='{:,.2f}'.format, \n",
    "                  index_label='annotation_index')\n",
    "    start += int(c/3)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "42736e58",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.11"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}