File size: 33,292 Bytes
8d121da
 
 
 
f06c0b0
8d121da
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
f06c0b0
8d121da
 
 
 
 
 
 
 
 
 
 
 
f06c0b0
8d121da
 
 
f06c0b0
 
8d121da
 
 
 
f06c0b0
8d121da
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
f06c0b0
 
8d121da
 
 
 
f06c0b0
 
 
 
 
 
 
 
 
 
 
8d121da
f06c0b0
8d121da
 
 
 
 
 
f06c0b0
 
 
 
8d121da
f06c0b0
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
8d121da
f06c0b0
8d121da
 
 
 
 
 
 
 
 
 
 
 
 
 
f06c0b0
8d121da
 
 
 
 
 
f06c0b0
8d121da
 
 
 
 
 
 
 
 
 
 
 
 
f06c0b0
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
8d121da
 
 
f06c0b0
 
8d121da
 
f06c0b0
 
 
 
 
 
8d121da
 
 
 
f06c0b0
8d121da
 
 
 
 
 
 
f599167
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
8d121da
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [],
   "source": [
    "import pandas as pd \n",
    "import requests \n",
    "import datetime as dt\n",
    "import re\n",
    "import json\n",
    "from tqdm import tqdm\n",
    "import os\n",
    "import time\n",
    "from openai import OpenAI"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "#### Calculate"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [],
   "source": [
    "if \"OPENAI_API_KEY\" not in os.environ:\n",
    "    with open('/home/sagemaker-user/Sciences-POC/config/secrets/keys.txt', 'r') as f:\n",
    "        keys = json.loads(f.read())\n",
    "else : \n",
    "    keys=os.environ"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 27,
   "metadata": {},
   "outputs": [],
   "source": [
    "save_path = 'data/outputs'\n",
    "content_path = 'data/extract_sciences_po'\n",
    "\n",
    "\n",
    "def retrieve_classifications(name, mapping_prompt):\n",
    "\n",
    "    df = pd.read_csv('data/extract_sciences_po.csv')\n",
    "\n",
    "    if os.path.exists(f\"{save_path}/output_{name}.txt\"):\n",
    "        with open(f\"{save_path}/output_{name}.txt\", 'r') as f : \n",
    "            out_dict = json.loads(f.read())\n",
    "        out_df = pd.DataFrame.from_dict(out_dict)\n",
    "        out = out_dict\n",
    "    else : \n",
    "        out_df = pd.DataFrame(columns = ['item_id', 'categorie_principale', 'categorie_secondaire'])\n",
    "        out = []\n",
    "\n",
    "    df_to_process = df.loc[~df.item_id.isin(out_df.item_id)]\n",
    "\n",
    "    if mapping_prompt[name]['client']=='deepseek':\n",
    "        client = OpenAI(api_key=keys[\"DEEPSEEK_API_KEY\"], base_url=\"https://api.deepseek.com\")\n",
    "        model=\"deepseek-chat\"\n",
    "    else:\n",
    "        client=OpenAI(api_key=\"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\")\n",
    "        model=\"gpt-4o-mini\"\n",
    "\n",
    "    with open(mapping_prompt[name]['path_prompt'], 'r') as f:\n",
    "        prompt = f.read()\n",
    "\n",
    "    if mapping_prompt[name]['client']=='openai-assistant':\n",
    "        \n",
    "            assistant = client.beta.assistants.create(\n",
    "            name=\"News classifier\",\n",
    "            instructions=prompt,\n",
    "            response_format={ \"type\": \"json_object\"},\n",
    "            model=\"gpt-4o-mini\",\n",
    "            )\n",
    "\n",
    "            assistant_id = assistant.id #mapping_prompt[name]['assistant_id']\n",
    "\n",
    "    with tqdm(total=df_to_process.shape[0]) as pbar:\n",
    "\n",
    "        for i, row in df_to_process.iterrows():\n",
    "            titre_brut = f\"{row.item_id}_\"+row.titre.lower().strip().replace(f\"\\xa0\", ' ').replace(' : ', ':').replace(' ', '_').replace('/', '')\n",
    "            \n",
    "            with open(f'{content_path}/{titre_brut}.txt', 'r') as f:\n",
    "                text = f.read()\n",
    "\n",
    "            if mapping_prompt[name]['client']=='openai-assistant':\n",
    "                \n",
    "                # Step 1: Create a thread\n",
    "                thread = client.beta.threads.create()\n",
    "\n",
    "                # Step 2: Add a user message\n",
    "                client.beta.threads.messages.create(\n",
    "                    thread_id=thread.id,\n",
    "                    role=\"user\",\n",
    "                    content=text\n",
    "                )\n",
    "\n",
    "                # Step 3: Run the assistant\n",
    "                run = client.beta.threads.runs.create(\n",
    "                    thread_id=thread.id,\n",
    "                    assistant_id=assistant_id,\n",
    "                )\n",
    "\n",
    "                # Step 4: Wait for completion\n",
    "                while True:\n",
    "                    run = client.beta.threads.runs.retrieve(\n",
    "                        thread_id=thread.id,\n",
    "                        run_id=run.id,\n",
    "                    )\n",
    "                    if run.status == \"completed\":\n",
    "                        break\n",
    "                    elif run.status in [\"failed\", \"cancelled\", \"expired\"]:\n",
    "                        raise Exception(f\"\"\"Run failed with status: {run.status}\\n\n",
    "                                        {run}\"\"\")\n",
    "                    time.sleep(1)\n",
    "\n",
    "                # Step 5: Get last assistant message only\n",
    "                messages = client.beta.threads.messages.list(thread_id=thread.id)\n",
    "                assistant_messages = [m for m in messages.data if m.role == \"assistant\"]\n",
    "\n",
    "                if assistant_messages:\n",
    "                    # Get the most recent assistant message\n",
    "                    latest = assistant_messages[0]\n",
    "                    content = latest.content[0].text.value                   \n",
    "                    \n",
    "            else:\n",
    "                messages = [{\"role\": \"system\", \"content\": prompt},\n",
    "                            {\"role\": \"user\", \"content\": text}]\n",
    "\n",
    "                response = client.chat.completions.create(\n",
    "                    model=model,\n",
    "                    messages=messages,\n",
    "                    response_format={\n",
    "                        'type': 'json_object'\n",
    "                    }\n",
    "                )\n",
    "                content = response.choices[0].message.content\n",
    "            try : \n",
    "                cat_json = json.loads(content)\n",
    "\n",
    "                out.append({\n",
    "                    'item_id':row.item_id, \n",
    "                    'categorie_principale': cat_json['categorie_principale'],\n",
    "                    'categorie_secondaire': cat_json['categorie_secondaire'],\n",
    "                })\n",
    "                \n",
    "                with open(f'{save_path}/output_{name}.txt', 'w+') as f : \n",
    "                    f.write(json.dumps(out))\n",
    "\n",
    "            except Exception as e : \n",
    "                print(f'Error with article {row.item_id}')\n",
    "                pass\n",
    "\n",
    "                \n",
    "            pbar.update(1)\n",
    "\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 28,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "dimanov_et_al\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "  6%|β–Œ         | 29/509 [03:56<1:21:08, 10.14s/it]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Error with article F5TBC6SGHRGRFJGZXZYG73I2C4\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      " 13%|β–ˆβ–Ž        | 65/509 [09:58<1:19:31, 10.75s/it]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Error with article PCZQ5Q2SHJFHZANPXZW2CUQVWU\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      " 15%|β–ˆβ–        | 75/509 [10:54<39:59,  5.53s/it]  "
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Error with article KCFRPP6YOJEMZMUEP55JMHKPCI\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      " 16%|β–ˆβ–Œ        | 81/509 [11:28<39:46,  5.58s/it]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Error with article AQ3WGXNGMFC7TF5NO73LD2AQBY\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      " 17%|β–ˆβ–‹        | 87/509 [12:09<46:30,  6.61s/it]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Error with article KAO3B4ZMY5HP3NMHSSORBBHEVQ\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      " 20%|β–ˆβ–‰        | 101/509 [14:32<2:06:30, 18.60s/it]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Error with article OKZW3KTDFNHTDIOZSJTUUWTECM\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      " 21%|β–ˆβ–ˆ        | 106/509 [15:06<58:56,  8.78s/it]  "
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Error with article UBNN4MNV35BCVICDFZVGQEAPYU\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      " 21%|β–ˆβ–ˆ        | 108/509 [15:21<53:29,  8.00s/it]  "
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Error with article VWT2DL4B2RESPHBN5GLSRSKCXA\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      " 21%|β–ˆβ–ˆβ–       | 109/509 [15:26<46:12,  6.93s/it]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Error with article NE7X4E4S7BGCVN42KSQHYGPR5M\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      " 28%|β–ˆβ–ˆβ–Š       | 140/509 [20:16<43:06,  7.01s/it]  "
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Error with article 7MSP4B5UWFDURJY2ZA4E26D6Y4\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      " 28%|β–ˆβ–ˆβ–Š       | 141/509 [20:21<39:19,  6.41s/it]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Error with article 5GQ4EE3DBZBJ3FOP2J3FHRAW6Y\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      " 35%|β–ˆβ–ˆβ–ˆβ–Œ      | 180/509 [25:47<45:26,  8.29s/it]  "
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Error with article FOMV5KH4UZBFNJHHOTLIRNBTNA\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      " 36%|β–ˆβ–ˆβ–ˆβ–Œ      | 182/509 [25:58<36:52,  6.77s/it]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Error with article KXP2DEGANVHOXNRBFFU2X44KME\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      " 39%|β–ˆβ–ˆβ–ˆβ–Š      | 197/509 [28:03<50:13,  9.66s/it]  "
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Error with article HIY7OM5AGFF7NAWUFKDSFKBIQU\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      " 40%|β–ˆβ–ˆβ–ˆβ–‰      | 202/509 [29:15<1:19:59, 15.64s/it]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Error with article GK5PBHMGJNGH7IC6TRV7BPISRI\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      " 46%|β–ˆβ–ˆβ–ˆβ–ˆβ–Œ     | 235/509 [33:50<26:15,  5.75s/it]  "
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Error with article WHQXZPRU4ZGNHHFODI5AF4QREQ\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      " 48%|β–ˆβ–ˆβ–ˆβ–ˆβ–Š     | 245/509 [35:12<39:31,  8.98s/it]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Error with article JMNDPKJDOBGDPOVOT3B2TMEI3Q\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      " 53%|β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–Ž    | 272/509 [40:57<28:50,  7.30s/it]  "
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Error with article OY5WOZYJJFCUXAY2IP3MDF5DBI\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      " 54%|β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–    | 276/509 [41:21<24:21,  6.27s/it]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Error with article 4UXLV4RIYRGI3LLOJ4VIFIS3PU\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      " 56%|β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–Œ    | 286/509 [43:40<43:09, 11.61s/it]  "
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Error with article BDUEDA6Q5VFA5JVZUYKANSBEJU\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      " 58%|β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–Š    | 297/509 [45:06<30:24,  8.60s/it]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Error with article LTW4AQF5ZJFA5IYGRMTYK5KYYA\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      " 74%|β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–Ž  | 375/509 [56:16<19:53,  8.90s/it]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Error with article TYDKDANLIVFMXMGT6QNNLZXFT4\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      " 74%|β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–  | 376/509 [56:22<17:48,  8.03s/it]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Error with article B62VZRCINRBWTI2ZP5KSJCALQY\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      " 76%|β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–‹  | 389/509 [58:22<17:08,  8.57s/it]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Error with article NEIWXLDUOBFG5P7N3QJFXKRWKU\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      " 77%|β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–‹  | 391/509 [58:38<15:53,  8.08s/it]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Error with article Y4SGMAXQGJFA3EIXQM2P4ULYAA\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      " 77%|β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–‹  | 392/509 [58:49<17:23,  8.92s/it]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Error with article 2GHECSGTINFFLLDNFB6GWBWT74\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      " 82%|β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ– | 416/509 [1:03:07<16:25, 10.59s/it]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Error with article A76MZTTKFFDNTEBAHEFQR3YMWA\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      " 82%|β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ– | 418/509 [1:03:34<17:11, 11.33s/it]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Error with article RVAAO6SOURFWXLYT5UGAZQMFDI\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      " 84%|β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–Ž | 426/509 [1:04:50<14:42, 10.63s/it]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Error with article ZPJYQHA4YZA7XJVVYINHDXY52Y\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      " 84%|β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ– | 429/509 [1:06:26<32:25, 24.32s/it]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Error with article HQWSHI5H3ZFWRC6CR3EGK2CWOU\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      " 85%|β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ– | 431/509 [1:06:40<19:53, 15.30s/it]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Error with article UJCAG7SOBRC4DB4GD3YRYKHYJE\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      " 91%|β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ | 462/509 [1:13:31<10:16, 13.12s/it]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Error with article CSVWJ7KVPBHLPH4LGTSWPYA5IE\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      " 95%|β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–Œ| 484/509 [1:17:49<04:09,  9.96s/it]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Error with article BQ6E3KG74ZFQPEHRYVAUUDLTRY\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      " 97%|β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–‹| 492/509 [1:18:53<01:56,  6.83s/it]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Error with article VC2YC2LPWRA2ZGM6DM3JWZKVHY\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      " 99%|β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–‰| 505/509 [1:21:06<00:41, 10.36s/it]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Error with article AOT254SA2VDIDNF4YW7XPLWJ5E\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "100%|β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ| 509/509 [1:22:17<00:00,  9.70s/it]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "sans_titre_1\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "\n"
     ]
    },
    {
     "ename": "KeyError",
     "evalue": "'DEEPSEEK_API_KEY'",
     "output_type": "error",
     "traceback": [
      "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
      "\u001b[0;31mKeyError\u001b[0m                                  Traceback (most recent call last)",
      "Cell \u001b[0;32mIn[28], line 6\u001b[0m\n\u001b[1;32m      4\u001b[0m \u001b[38;5;28;01mfor\u001b[39;00m name \u001b[38;5;129;01min\u001b[39;00m mapping\u001b[38;5;241m.\u001b[39mkeys():\n\u001b[1;32m      5\u001b[0m     \u001b[38;5;28mprint\u001b[39m(name)\n\u001b[0;32m----> 6\u001b[0m     \u001b[43mretrieve_classifications\u001b[49m\u001b[43m(\u001b[49m\u001b[43mname\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mmapping\u001b[49m\u001b[43m)\u001b[49m\n",
      "Cell \u001b[0;32mIn[27], line 21\u001b[0m, in \u001b[0;36mretrieve_classifications\u001b[0;34m(name, mapping_prompt)\u001b[0m\n\u001b[1;32m     18\u001b[0m df_to_process \u001b[38;5;241m=\u001b[39m df\u001b[38;5;241m.\u001b[39mloc[\u001b[38;5;241m~\u001b[39mdf\u001b[38;5;241m.\u001b[39mitem_id\u001b[38;5;241m.\u001b[39misin(out_df\u001b[38;5;241m.\u001b[39mitem_id)]\n\u001b[1;32m     20\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m mapping_prompt[name][\u001b[38;5;124m'\u001b[39m\u001b[38;5;124mclient\u001b[39m\u001b[38;5;124m'\u001b[39m]\u001b[38;5;241m==\u001b[39m\u001b[38;5;124m'\u001b[39m\u001b[38;5;124mdeepseek\u001b[39m\u001b[38;5;124m'\u001b[39m:\n\u001b[0;32m---> 21\u001b[0m     client \u001b[38;5;241m=\u001b[39m OpenAI(api_key\u001b[38;5;241m=\u001b[39m\u001b[43mkeys\u001b[49m\u001b[43m[\u001b[49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43mDEEPSEEK_API_KEY\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m]\u001b[49m, base_url\u001b[38;5;241m=\u001b[39m\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mhttps://api.deepseek.com\u001b[39m\u001b[38;5;124m\"\u001b[39m)\n\u001b[1;32m     22\u001b[0m     model\u001b[38;5;241m=\u001b[39m\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mdeepseek-chat\u001b[39m\u001b[38;5;124m\"\u001b[39m\n\u001b[1;32m     23\u001b[0m \u001b[38;5;28;01melse\u001b[39;00m:\n",
      "File \u001b[0;32m<frozen os>:679\u001b[0m, in \u001b[0;36m__getitem__\u001b[0;34m(self, key)\u001b[0m\n",
      "\u001b[0;31mKeyError\u001b[0m: 'DEEPSEEK_API_KEY'"
     ]
    }
   ],
   "source": [
    "with open('config/mapping_prompts.txt', 'r') as f : \n",
    "    mapping = json.loads(f.read())\n",
    "\n",
    "for name in mapping.keys():\n",
    "    print(name)\n",
    "    retrieve_classifications(name, mapping)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 38,
   "metadata": {},
   "outputs": [],
   "source": [
    "articles = pd.read_csv('data/extract_sciences_po.csv')\n",
    "\n",
    "with open(\"data/outputs/output_favarel_et_al.txt\", 'r') as f : \n",
    "    out_dict = json.loads(f.read())\n",
    "\n",
    "\n",
    "df = pd.DataFrame.from_dict(out_dict)\n",
    "\n",
    "articles = pd.merge(df, articles, on='item_id', how='left')\n",
    "\n",
    "count_principale = df.groupby('categorie_principale').item_id.count()\n",
    "df['categorie_secondaire'] = df.apply(lambda x : x.categorie_secondaire.split(',')[0] if x.categorie_secondaire!=None else None, axis=1)\n",
    "\n",
    "    "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 40,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "application/vnd.microsoft.datawrangler.viewer.v0+json": {
       "columns": [
        {
         "name": "index",
         "rawType": "int64",
         "type": "integer"
        },
        {
         "name": "item_id",
         "rawType": "object",
         "type": "string"
        },
        {
         "name": "categorie_principale",
         "rawType": "object",
         "type": "string"
        },
        {
         "name": "categorie_secondaire",
         "rawType": "object",
         "type": "string"
        }
       ],
       "conversionMethod": "pd.DataFrame",
       "ref": "224a4e83-124d-4710-9d6a-6deb122e17de",
       "rows": [
        [
         "0",
         "I4OEKQ6MHRBP3LQVVYDDXW6T6U",
         "UPDATE ME",
         "EDUCATE ME"
        ],
        [
         "1",
         "LVA4MZBQOBECNPZD323NV6O7K4",
         "INSPIRE ME",
         "EDUCATE ME"
        ],
        [
         "2",
         "4FAEHUUZ5ZFAJKLFEV2LT5CBAQ",
         "EDUCATE ME",
         "GIVE ME PERSPECTIVE"
        ],
        [
         "3",
         "4S4G6BKFRNER3LB22CLPAEWWKY",
         "GIVE ME PERSPECTIVE",
         "INSPIRE ME"
        ],
        [
         "4",
         "ZAFHRNAHJVC6THXRSBMCB4A24I",
         "INSPIRE ME",
         "EDUCATE ME"
        ],
        [
         "5",
         "ESEADAHDJVGQRC2S3JHSZEVWHM",
         "UPDATE ME",
         "GIVE ME PERSPECTIVE"
        ],
        [
         "6",
         "FZHZS32EOZG5FAK7IKOJIB3J4I",
         "EDUCATE ME",
         "GIVE ME PERSPECTIVE"
        ],
        [
         "7",
         "H4JJGHBTL5DDFNNNETBE5T7FLI",
         "UPDATE ME",
         "EDUCATE ME"
        ],
        [
         "8",
         "JTND25UK2NA6HL2DVJRX46VCVM",
         "EDUCATE ME",
         "GIVE ME PERSPECTIVE"
        ],
        [
         "9",
         "LFRXBXICUFFULNKZUG4JN4E2NY",
         "INSPIRE ME",
         "EDUCATE ME"
        ],
        [
         "10",
         "O5546IGISVGOLAPLOUIXAHXATE",
         "EDUCATE ME",
         "GIVE ME PERSPECTIVE"
        ],
        [
         "11",
         "5LRGJN3CONBZ3OIGARTGZX7X34",
         "UPDATE ME",
         "GIVE ME PERSPECTIVE"
        ],
        [
         "12",
         "A2CXALUPDVHDZP22PBL4YMMGVU",
         "EDUCATE ME",
         "GIVE ME PERSPECTIVE"
        ],
        [
         "13",
         "6T5ESGV6CNFA5L3TIEO475EO2I",
         "GIVE ME PERSPECTIVE",
         "EDUCATE ME"
        ],
        [
         "14",
         "KGJGC5V6OJCJJEVO4D3MP5QA4Q",
         "EDUCATE ME",
         "GIVE ME PERSPECTIVE"
        ],
        [
         "15",
         "ASBHDD73HZANDM5W3WRKXGCCGI",
         "KEEP ME ON TREND",
         "EDUCATE ME"
        ],
        [
         "16",
         "YL7UVGJLQZALVK5PCV2LZLPTDQ",
         "INSPIRE ME",
         "ENTERTAIN ME"
        ],
        [
         "17",
         "2T6XZA7OHRD6RFCGPA3ZVCNJ7A",
         "GIVE ME PERSPECTIVE",
         "EDUCATE ME"
        ],
        [
         "18",
         "V3THEIGVXBDADLDXUKJZTRLLUQ",
         "UPDATE ME",
         "GIVE ME PERSPECTIVE"
        ],
        [
         "19",
         "Z3WQ6BXPKRATPCGSKMROOOMQ44",
         "UPDATE ME",
         "EDUCATE ME"
        ],
        [
         "20",
         "TUR55MJTKRA7TNJOOP62XW7NIM",
         "INSPIRE ME",
         "EDUCATE ME"
        ],
        [
         "21",
         "YGI5VTCGIJFDNOA5C4G5BOITH4",
         "EDUCATE ME",
         "GIVE ME PERSPECTIVE"
        ],
        [
         "22",
         "S2FVMMUVK5BS3HK5YN7PNU2LZE",
         "UPDATE ME",
         "GIVE ME PERSPECTIVE"
        ],
        [
         "23",
         "ZASS6FXGGVGCHFSSZKZXQ4AG2U",
         "EDUCATE ME",
         "INSPIRE ME"
        ],
        [
         "24",
         "2AZTSRRBUNBHNNHU5DCMRGG6WY",
         "GIVE ME PERSPECTIVE",
         "EDUCATE ME"
        ],
        [
         "25",
         "AKDZ7PAIQVBN5OENKR5AQ6YGNI",
         "KEEP ME ON TREND",
         "ENTERTAIN ME"
        ],
        [
         "26",
         "M4RJIWTMK5BVPAWNFEHGXZSLRY",
         "INSPIRE ME",
         "ENTERTAIN ME"
        ],
        [
         "27",
         "WLTP7ZAZ7JFUDJG2LNO5E7APZA",
         "EDUCATE ME",
         "GIVE ME PERSPECTIVE"
        ],
        [
         "28",
         "DCY4O24FUBAZZB3KOTIMMBA6MY",
         "EDUCATE ME",
         "GIVE ME PERSPECTIVE"
        ],
        [
         "29",
         "FHFB7Z3XYBH25LO7XDGHAEQ7N4",
         "UPDATE ME",
         "EDUCATE ME"
        ],
        [
         "30",
         "BPNRZFZPAVA3HPUOXUKXEUR5RY",
         "EDUCATE ME",
         "GIVE ME PERSPECTIVE"
        ],
        [
         "31",
         "NWGRYEOIQ5ADRDRXYZCU5C3VDA",
         "INSPIRE ME",
         "EDUCATE ME"
        ],
        [
         "32",
         "GORDMTE47FA5FEUA3U76M5VPOY",
         "EDUCATE ME",
         "UPDATE ME"
        ],
        [
         "33",
         "XFBX7NDGN5CMPL3OU5ZXFF6YCE",
         "UPDATE ME",
         "EDUCATE ME"
        ],
        [
         "34",
         "VYEPVCBK4ZCV7D3SW35GZ2Y5DM",
         "EDUCATE ME",
         "INSPIRE ME"
        ],
        [
         "35",
         "F5TBC6SGHRGRFJGZXZYG73I2C4",
         "EDUCATE ME",
         "UPDATE ME"
        ],
        [
         "36",
         "ZFZG6QOFBRFE3BL4VCI72HFQKQ",
         "GIVE ME PERSPECTIVE",
         "EDUCATE ME"
        ],
        [
         "37",
         "ZGPFATVT4ZFJZMX7LDXE3VS7RM",
         "INSPIRE ME",
         "GIVE ME PERSPECTIVE"
        ],
        [
         "38",
         "UBVFCLZ6OZCP5DAAYCBW2CDPJI",
         "EDUCATE ME",
         "GIVE ME PERSPECTIVE"
        ],
        [
         "39",
         "WYEBGIAY5JAUFLB4GH6IXVYP34",
         "UPDATE ME",
         "EDUCATE ME"
        ],
        [
         "40",
         "DXW7WX7ALVFBZNPFU6QKHEH3G4",
         "UPDATE ME",
         "EDUCATE ME"
        ],
        [
         "41",
         "QOFNZRU2TVES7GMVVPMZ5LSI2E",
         "EDUCATE ME",
         "INSPIRE ME"
        ],
        [
         "42",
         "WBJI7FFINZHCPC5QZL2NFY6XWE",
         "INSPIRE ME",
         "EDUCATE ME"
        ],
        [
         "43",
         "IYAAHFU3PVFOPAN6XIJDPQ5XLQ",
         "UPDATE ME",
         "EDUCATE ME"
        ],
        [
         "44",
         "SNYUYV4G5BAODBTQWJBRG5JZKM",
         "EDUCATE ME",
         "GIVE ME PERSPECTIVE"
        ],
        [
         "45",
         "PMBTTRISTNDN3P3ANDECQKSEDE",
         "EDUCATE ME",
         "GIVE ME PERSPECTIVE"
        ],
        [
         "46",
         "UHYPJFKFJNHVPHVRFV7OHNDU64",
         "GIVE ME PERSPECTIVE",
         "EDUCATE ME"
        ],
        [
         "47",
         "ESRPEZYCA5AG7HIXUIVMPHDFVQ",
         "EDUCATE ME",
         "GIVE ME PERSPECTIVE"
        ],
        [
         "48",
         "HQW7TUOY7NHUVMCLNSDSEY5X4I",
         "KEEP ME ON TREND",
         "EDUCATE ME"
        ],
        [
         "49",
         "C3BA2XUBXRG5RBNHJUSDUKP4RI",
         "ENTERTAIN ME",
         "KEEP ME ON TREND"
        ]
       ],
       "shape": {
        "columns": 3,
        "rows": 516
       }
      },
      "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>item_id</th>\n",
       "      <th>categorie_principale</th>\n",
       "      <th>categorie_secondaire</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>I4OEKQ6MHRBP3LQVVYDDXW6T6U</td>\n",
       "      <td>UPDATE ME</td>\n",
       "      <td>EDUCATE ME</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>LVA4MZBQOBECNPZD323NV6O7K4</td>\n",
       "      <td>INSPIRE ME</td>\n",
       "      <td>EDUCATE ME</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>4FAEHUUZ5ZFAJKLFEV2LT5CBAQ</td>\n",
       "      <td>EDUCATE ME</td>\n",
       "      <td>GIVE ME PERSPECTIVE</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>4S4G6BKFRNER3LB22CLPAEWWKY</td>\n",
       "      <td>GIVE ME PERSPECTIVE</td>\n",
       "      <td>INSPIRE ME</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>ZAFHRNAHJVC6THXRSBMCB4A24I</td>\n",
       "      <td>INSPIRE ME</td>\n",
       "      <td>EDUCATE ME</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>511</th>\n",
       "      <td>AOT254SA2VDIDNF4YW7XPLWJ5E</td>\n",
       "      <td>INSPIRE ME</td>\n",
       "      <td>ENTERTAIN ME</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>512</th>\n",
       "      <td>GUOUKHLPFZBK7GVR5XU7MXVD5A</td>\n",
       "      <td>INSPIRE ME</td>\n",
       "      <td>EDUCATE ME</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>513</th>\n",
       "      <td>5HT6C24ZBVDOBFXPLA4HNVOTT4</td>\n",
       "      <td>EDUCATE ME</td>\n",
       "      <td>UPDATE ME</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>514</th>\n",
       "      <td>VLV6RSQ6U5E6XJ6AIRV26AEKO4</td>\n",
       "      <td>UPDATE ME</td>\n",
       "      <td>EDUCATE ME</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>515</th>\n",
       "      <td>FVCJ6DQ5HVDNDGC4F6F276NVFM</td>\n",
       "      <td>UPDATE ME</td>\n",
       "      <td>GIVE ME PERSPECTIVE</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>516 rows Γ— 3 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "                        item_id categorie_principale categorie_secondaire\n",
       "0    I4OEKQ6MHRBP3LQVVYDDXW6T6U            UPDATE ME           EDUCATE ME\n",
       "1    LVA4MZBQOBECNPZD323NV6O7K4           INSPIRE ME           EDUCATE ME\n",
       "2    4FAEHUUZ5ZFAJKLFEV2LT5CBAQ           EDUCATE ME  GIVE ME PERSPECTIVE\n",
       "3    4S4G6BKFRNER3LB22CLPAEWWKY  GIVE ME PERSPECTIVE           INSPIRE ME\n",
       "4    ZAFHRNAHJVC6THXRSBMCB4A24I           INSPIRE ME           EDUCATE ME\n",
       "..                          ...                  ...                  ...\n",
       "511  AOT254SA2VDIDNF4YW7XPLWJ5E           INSPIRE ME         ENTERTAIN ME\n",
       "512  GUOUKHLPFZBK7GVR5XU7MXVD5A           INSPIRE ME           EDUCATE ME\n",
       "513  5HT6C24ZBVDOBFXPLA4HNVOTT4           EDUCATE ME            UPDATE ME\n",
       "514  VLV6RSQ6U5E6XJ6AIRV26AEKO4            UPDATE ME           EDUCATE ME\n",
       "515  FVCJ6DQ5HVDNDGC4F6F276NVFM            UPDATE ME  GIVE ME PERSPECTIVE\n",
       "\n",
       "[516 rows x 3 columns]"
      ]
     },
     "execution_count": 40,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "#### Ajouter images"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": ".venv",
   "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.11.11"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}