File size: 117,991 Bytes
6c55f30
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 66,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Requirement already satisfied: spacy in ./.venv/lib/python3.12/site-packages (3.7.6)\n",
      "Requirement already satisfied: spacy-legacy<3.1.0,>=3.0.11 in ./.venv/lib/python3.12/site-packages (from spacy) (3.0.12)\n",
      "Requirement already satisfied: spacy-loggers<2.0.0,>=1.0.0 in ./.venv/lib/python3.12/site-packages (from spacy) (1.0.5)\n",
      "Requirement already satisfied: murmurhash<1.1.0,>=0.28.0 in ./.venv/lib/python3.12/site-packages (from spacy) (1.0.10)\n",
      "Requirement already satisfied: cymem<2.1.0,>=2.0.2 in ./.venv/lib/python3.12/site-packages (from spacy) (2.0.8)\n",
      "Requirement already satisfied: preshed<3.1.0,>=3.0.2 in ./.venv/lib/python3.12/site-packages (from spacy) (3.0.9)\n",
      "Requirement already satisfied: thinc<8.3.0,>=8.2.2 in ./.venv/lib/python3.12/site-packages (from spacy) (8.2.5)\n",
      "Requirement already satisfied: wasabi<1.2.0,>=0.9.1 in ./.venv/lib/python3.12/site-packages (from spacy) (1.1.3)\n",
      "Requirement already satisfied: srsly<3.0.0,>=2.4.3 in ./.venv/lib/python3.12/site-packages (from spacy) (2.4.8)\n",
      "Requirement already satisfied: catalogue<2.1.0,>=2.0.6 in ./.venv/lib/python3.12/site-packages (from spacy) (2.0.10)\n",
      "Requirement already satisfied: weasel<0.5.0,>=0.1.0 in ./.venv/lib/python3.12/site-packages (from spacy) (0.4.1)\n",
      "Requirement already satisfied: typer<1.0.0,>=0.3.0 in ./.venv/lib/python3.12/site-packages (from spacy) (0.12.5)\n",
      "Requirement already satisfied: tqdm<5.0.0,>=4.38.0 in ./.venv/lib/python3.12/site-packages (from spacy) (4.66.5)\n",
      "Requirement already satisfied: requests<3.0.0,>=2.13.0 in ./.venv/lib/python3.12/site-packages (from spacy) (2.32.3)\n",
      "Requirement already satisfied: pydantic!=1.8,!=1.8.1,<3.0.0,>=1.7.4 in ./.venv/lib/python3.12/site-packages (from spacy) (2.8.2)\n",
      "Requirement already satisfied: jinja2 in ./.venv/lib/python3.12/site-packages (from spacy) (3.1.4)\n",
      "Requirement already satisfied: setuptools in ./.venv/lib/python3.12/site-packages (from spacy) (74.1.2)\n",
      "Requirement already satisfied: packaging>=20.0 in ./.venv/lib/python3.12/site-packages (from spacy) (24.1)\n",
      "Requirement already satisfied: langcodes<4.0.0,>=3.2.0 in ./.venv/lib/python3.12/site-packages (from spacy) (3.4.0)\n",
      "Requirement already satisfied: numpy>=1.19.0 in ./.venv/lib/python3.12/site-packages (from spacy) (1.26.4)\n",
      "Requirement already satisfied: language-data>=1.2 in ./.venv/lib/python3.12/site-packages (from langcodes<4.0.0,>=3.2.0->spacy) (1.2.0)\n",
      "Requirement already satisfied: annotated-types>=0.4.0 in ./.venv/lib/python3.12/site-packages (from pydantic!=1.8,!=1.8.1,<3.0.0,>=1.7.4->spacy) (0.7.0)\n",
      "Requirement already satisfied: pydantic-core==2.20.1 in ./.venv/lib/python3.12/site-packages (from pydantic!=1.8,!=1.8.1,<3.0.0,>=1.7.4->spacy) (2.20.1)\n",
      "Requirement already satisfied: typing-extensions>=4.6.1 in ./.venv/lib/python3.12/site-packages (from pydantic!=1.8,!=1.8.1,<3.0.0,>=1.7.4->spacy) (4.12.2)\n",
      "Requirement already satisfied: charset-normalizer<4,>=2 in ./.venv/lib/python3.12/site-packages (from requests<3.0.0,>=2.13.0->spacy) (3.3.2)\n",
      "Requirement already satisfied: idna<4,>=2.5 in ./.venv/lib/python3.12/site-packages (from requests<3.0.0,>=2.13.0->spacy) (3.7)\n",
      "Requirement already satisfied: urllib3<3,>=1.21.1 in ./.venv/lib/python3.12/site-packages (from requests<3.0.0,>=2.13.0->spacy) (2.2.2)\n",
      "Requirement already satisfied: certifi>=2017.4.17 in ./.venv/lib/python3.12/site-packages (from requests<3.0.0,>=2.13.0->spacy) (2024.7.4)\n",
      "Requirement already satisfied: blis<0.8.0,>=0.7.8 in ./.venv/lib/python3.12/site-packages (from thinc<8.3.0,>=8.2.2->spacy) (0.7.11)\n",
      "Requirement already satisfied: confection<1.0.0,>=0.0.1 in ./.venv/lib/python3.12/site-packages (from thinc<8.3.0,>=8.2.2->spacy) (0.1.5)\n",
      "Requirement already satisfied: click>=8.0.0 in ./.venv/lib/python3.12/site-packages (from typer<1.0.0,>=0.3.0->spacy) (8.1.7)\n",
      "Requirement already satisfied: shellingham>=1.3.0 in ./.venv/lib/python3.12/site-packages (from typer<1.0.0,>=0.3.0->spacy) (1.5.4)\n",
      "Requirement already satisfied: rich>=10.11.0 in ./.venv/lib/python3.12/site-packages (from typer<1.0.0,>=0.3.0->spacy) (13.8.0)\n",
      "Requirement already satisfied: cloudpathlib<1.0.0,>=0.7.0 in ./.venv/lib/python3.12/site-packages (from weasel<0.5.0,>=0.1.0->spacy) (0.19.0)\n",
      "Requirement already satisfied: smart-open<8.0.0,>=5.2.1 in ./.venv/lib/python3.12/site-packages (from weasel<0.5.0,>=0.1.0->spacy) (7.0.4)\n",
      "Requirement already satisfied: MarkupSafe>=2.0 in ./.venv/lib/python3.12/site-packages (from jinja2->spacy) (2.1.5)\n",
      "Requirement already satisfied: marisa-trie>=0.7.7 in ./.venv/lib/python3.12/site-packages (from language-data>=1.2->langcodes<4.0.0,>=3.2.0->spacy) (1.2.0)\n",
      "Requirement already satisfied: markdown-it-py>=2.2.0 in ./.venv/lib/python3.12/site-packages (from rich>=10.11.0->typer<1.0.0,>=0.3.0->spacy) (3.0.0)\n",
      "Requirement already satisfied: pygments<3.0.0,>=2.13.0 in ./.venv/lib/python3.12/site-packages (from rich>=10.11.0->typer<1.0.0,>=0.3.0->spacy) (2.18.0)\n",
      "Requirement already satisfied: wrapt in ./.venv/lib/python3.12/site-packages (from smart-open<8.0.0,>=5.2.1->weasel<0.5.0,>=0.1.0->spacy) (1.16.0)\n",
      "Requirement already satisfied: mdurl~=0.1 in ./.venv/lib/python3.12/site-packages (from markdown-it-py>=2.2.0->rich>=10.11.0->typer<1.0.0,>=0.3.0->spacy) (0.1.2)\n",
      "Collecting en-core-web-sm==3.7.1\n",
      "  Downloading https://github.com/explosion/spacy-models/releases/download/en_core_web_sm-3.7.1/en_core_web_sm-3.7.1-py3-none-any.whl (12.8 MB)\n",
      "\u001b[2K     \u001b[90mโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”\u001b[0m \u001b[32m12.8/12.8 MB\u001b[0m \u001b[31m22.4 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m00:01\u001b[0m0:01\u001b[0m\n",
      "\u001b[?25hRequirement already satisfied: spacy<3.8.0,>=3.7.2 in ./.venv/lib/python3.12/site-packages (from en-core-web-sm==3.7.1) (3.7.6)\n",
      "Requirement already satisfied: spacy-legacy<3.1.0,>=3.0.11 in ./.venv/lib/python3.12/site-packages (from spacy<3.8.0,>=3.7.2->en-core-web-sm==3.7.1) (3.0.12)\n",
      "Requirement already satisfied: spacy-loggers<2.0.0,>=1.0.0 in ./.venv/lib/python3.12/site-packages (from spacy<3.8.0,>=3.7.2->en-core-web-sm==3.7.1) (1.0.5)\n",
      "Requirement already satisfied: murmurhash<1.1.0,>=0.28.0 in ./.venv/lib/python3.12/site-packages (from spacy<3.8.0,>=3.7.2->en-core-web-sm==3.7.1) (1.0.10)\n",
      "Requirement already satisfied: cymem<2.1.0,>=2.0.2 in ./.venv/lib/python3.12/site-packages (from spacy<3.8.0,>=3.7.2->en-core-web-sm==3.7.1) (2.0.8)\n",
      "Requirement already satisfied: preshed<3.1.0,>=3.0.2 in ./.venv/lib/python3.12/site-packages (from spacy<3.8.0,>=3.7.2->en-core-web-sm==3.7.1) (3.0.9)\n",
      "Requirement already satisfied: thinc<8.3.0,>=8.2.2 in ./.venv/lib/python3.12/site-packages (from spacy<3.8.0,>=3.7.2->en-core-web-sm==3.7.1) (8.2.5)\n",
      "Requirement already satisfied: wasabi<1.2.0,>=0.9.1 in ./.venv/lib/python3.12/site-packages (from spacy<3.8.0,>=3.7.2->en-core-web-sm==3.7.1) (1.1.3)\n",
      "Requirement already satisfied: srsly<3.0.0,>=2.4.3 in ./.venv/lib/python3.12/site-packages (from spacy<3.8.0,>=3.7.2->en-core-web-sm==3.7.1) (2.4.8)\n",
      "Requirement already satisfied: catalogue<2.1.0,>=2.0.6 in ./.venv/lib/python3.12/site-packages (from spacy<3.8.0,>=3.7.2->en-core-web-sm==3.7.1) (2.0.10)\n",
      "Requirement already satisfied: weasel<0.5.0,>=0.1.0 in ./.venv/lib/python3.12/site-packages (from spacy<3.8.0,>=3.7.2->en-core-web-sm==3.7.1) (0.4.1)\n",
      "Requirement already satisfied: typer<1.0.0,>=0.3.0 in ./.venv/lib/python3.12/site-packages (from spacy<3.8.0,>=3.7.2->en-core-web-sm==3.7.1) (0.12.5)\n",
      "Requirement already satisfied: tqdm<5.0.0,>=4.38.0 in ./.venv/lib/python3.12/site-packages (from spacy<3.8.0,>=3.7.2->en-core-web-sm==3.7.1) (4.66.5)\n",
      "Requirement already satisfied: requests<3.0.0,>=2.13.0 in ./.venv/lib/python3.12/site-packages (from spacy<3.8.0,>=3.7.2->en-core-web-sm==3.7.1) (2.32.3)\n",
      "Requirement already satisfied: pydantic!=1.8,!=1.8.1,<3.0.0,>=1.7.4 in ./.venv/lib/python3.12/site-packages (from spacy<3.8.0,>=3.7.2->en-core-web-sm==3.7.1) (2.8.2)\n",
      "Requirement already satisfied: jinja2 in ./.venv/lib/python3.12/site-packages (from spacy<3.8.0,>=3.7.2->en-core-web-sm==3.7.1) (3.1.4)\n",
      "Requirement already satisfied: setuptools in ./.venv/lib/python3.12/site-packages (from spacy<3.8.0,>=3.7.2->en-core-web-sm==3.7.1) (74.1.2)\n",
      "Requirement already satisfied: packaging>=20.0 in ./.venv/lib/python3.12/site-packages (from spacy<3.8.0,>=3.7.2->en-core-web-sm==3.7.1) (24.1)\n",
      "Requirement already satisfied: langcodes<4.0.0,>=3.2.0 in ./.venv/lib/python3.12/site-packages (from spacy<3.8.0,>=3.7.2->en-core-web-sm==3.7.1) (3.4.0)\n",
      "Requirement already satisfied: numpy>=1.19.0 in ./.venv/lib/python3.12/site-packages (from spacy<3.8.0,>=3.7.2->en-core-web-sm==3.7.1) (1.26.4)\n",
      "Requirement already satisfied: language-data>=1.2 in ./.venv/lib/python3.12/site-packages (from langcodes<4.0.0,>=3.2.0->spacy<3.8.0,>=3.7.2->en-core-web-sm==3.7.1) (1.2.0)\n",
      "Requirement already satisfied: annotated-types>=0.4.0 in ./.venv/lib/python3.12/site-packages (from pydantic!=1.8,!=1.8.1,<3.0.0,>=1.7.4->spacy<3.8.0,>=3.7.2->en-core-web-sm==3.7.1) (0.7.0)\n",
      "Requirement already satisfied: pydantic-core==2.20.1 in ./.venv/lib/python3.12/site-packages (from pydantic!=1.8,!=1.8.1,<3.0.0,>=1.7.4->spacy<3.8.0,>=3.7.2->en-core-web-sm==3.7.1) (2.20.1)\n",
      "Requirement already satisfied: typing-extensions>=4.6.1 in ./.venv/lib/python3.12/site-packages (from pydantic!=1.8,!=1.8.1,<3.0.0,>=1.7.4->spacy<3.8.0,>=3.7.2->en-core-web-sm==3.7.1) (4.12.2)\n",
      "Requirement already satisfied: charset-normalizer<4,>=2 in ./.venv/lib/python3.12/site-packages (from requests<3.0.0,>=2.13.0->spacy<3.8.0,>=3.7.2->en-core-web-sm==3.7.1) (3.3.2)\n",
      "Requirement already satisfied: idna<4,>=2.5 in ./.venv/lib/python3.12/site-packages (from requests<3.0.0,>=2.13.0->spacy<3.8.0,>=3.7.2->en-core-web-sm==3.7.1) (3.7)\n",
      "Requirement already satisfied: urllib3<3,>=1.21.1 in ./.venv/lib/python3.12/site-packages (from requests<3.0.0,>=2.13.0->spacy<3.8.0,>=3.7.2->en-core-web-sm==3.7.1) (2.2.2)\n",
      "Requirement already satisfied: certifi>=2017.4.17 in ./.venv/lib/python3.12/site-packages (from requests<3.0.0,>=2.13.0->spacy<3.8.0,>=3.7.2->en-core-web-sm==3.7.1) (2024.7.4)\n",
      "Requirement already satisfied: blis<0.8.0,>=0.7.8 in ./.venv/lib/python3.12/site-packages (from thinc<8.3.0,>=8.2.2->spacy<3.8.0,>=3.7.2->en-core-web-sm==3.7.1) (0.7.11)\n",
      "Requirement already satisfied: confection<1.0.0,>=0.0.1 in ./.venv/lib/python3.12/site-packages (from thinc<8.3.0,>=8.2.2->spacy<3.8.0,>=3.7.2->en-core-web-sm==3.7.1) (0.1.5)\n",
      "Requirement already satisfied: click>=8.0.0 in ./.venv/lib/python3.12/site-packages (from typer<1.0.0,>=0.3.0->spacy<3.8.0,>=3.7.2->en-core-web-sm==3.7.1) (8.1.7)\n",
      "Requirement already satisfied: shellingham>=1.3.0 in ./.venv/lib/python3.12/site-packages (from typer<1.0.0,>=0.3.0->spacy<3.8.0,>=3.7.2->en-core-web-sm==3.7.1) (1.5.4)\n",
      "Requirement already satisfied: rich>=10.11.0 in ./.venv/lib/python3.12/site-packages (from typer<1.0.0,>=0.3.0->spacy<3.8.0,>=3.7.2->en-core-web-sm==3.7.1) (13.8.0)\n",
      "Requirement already satisfied: cloudpathlib<1.0.0,>=0.7.0 in ./.venv/lib/python3.12/site-packages (from weasel<0.5.0,>=0.1.0->spacy<3.8.0,>=3.7.2->en-core-web-sm==3.7.1) (0.19.0)\n",
      "Requirement already satisfied: smart-open<8.0.0,>=5.2.1 in ./.venv/lib/python3.12/site-packages (from weasel<0.5.0,>=0.1.0->spacy<3.8.0,>=3.7.2->en-core-web-sm==3.7.1) (7.0.4)\n",
      "Requirement already satisfied: MarkupSafe>=2.0 in ./.venv/lib/python3.12/site-packages (from jinja2->spacy<3.8.0,>=3.7.2->en-core-web-sm==3.7.1) (2.1.5)\n",
      "Requirement already satisfied: marisa-trie>=0.7.7 in ./.venv/lib/python3.12/site-packages (from language-data>=1.2->langcodes<4.0.0,>=3.2.0->spacy<3.8.0,>=3.7.2->en-core-web-sm==3.7.1) (1.2.0)\n",
      "Requirement already satisfied: markdown-it-py>=2.2.0 in ./.venv/lib/python3.12/site-packages (from rich>=10.11.0->typer<1.0.0,>=0.3.0->spacy<3.8.0,>=3.7.2->en-core-web-sm==3.7.1) (3.0.0)\n",
      "Requirement already satisfied: pygments<3.0.0,>=2.13.0 in ./.venv/lib/python3.12/site-packages (from rich>=10.11.0->typer<1.0.0,>=0.3.0->spacy<3.8.0,>=3.7.2->en-core-web-sm==3.7.1) (2.18.0)\n",
      "Requirement already satisfied: wrapt in ./.venv/lib/python3.12/site-packages (from smart-open<8.0.0,>=5.2.1->weasel<0.5.0,>=0.1.0->spacy<3.8.0,>=3.7.2->en-core-web-sm==3.7.1) (1.16.0)\n",
      "Requirement already satisfied: mdurl~=0.1 in ./.venv/lib/python3.12/site-packages (from markdown-it-py>=2.2.0->rich>=10.11.0->typer<1.0.0,>=0.3.0->spacy<3.8.0,>=3.7.2->en-core-web-sm==3.7.1) (0.1.2)\n",
      "\u001b[38;5;2mโœ” Download and installation successful\u001b[0m\n",
      "You can now load the package via spacy.load('en_core_web_sm')\n",
      "Collecting ipywidgets\n",
      "  Using cached ipywidgets-8.1.5-py3-none-any.whl.metadata (2.3 kB)\n",
      "Requirement already satisfied: comm>=0.1.3 in ./.venv/lib/python3.12/site-packages (from ipywidgets) (0.2.2)\n",
      "Requirement already satisfied: ipython>=6.1.0 in ./.venv/lib/python3.12/site-packages (from ipywidgets) (8.27.0)\n",
      "Requirement already satisfied: traitlets>=4.3.1 in ./.venv/lib/python3.12/site-packages (from ipywidgets) (5.14.3)\n",
      "Collecting widgetsnbextension~=4.0.12 (from ipywidgets)\n",
      "  Using cached widgetsnbextension-4.0.13-py3-none-any.whl.metadata (1.6 kB)\n",
      "Collecting jupyterlab-widgets~=3.0.12 (from ipywidgets)\n",
      "  Using cached jupyterlab_widgets-3.0.13-py3-none-any.whl.metadata (4.1 kB)\n",
      "Requirement already satisfied: decorator in ./.venv/lib/python3.12/site-packages (from ipython>=6.1.0->ipywidgets) (5.1.1)\n",
      "Requirement already satisfied: jedi>=0.16 in ./.venv/lib/python3.12/site-packages (from ipython>=6.1.0->ipywidgets) (0.19.1)\n",
      "Requirement already satisfied: matplotlib-inline in ./.venv/lib/python3.12/site-packages (from ipython>=6.1.0->ipywidgets) (0.1.7)\n",
      "Requirement already satisfied: prompt-toolkit<3.1.0,>=3.0.41 in ./.venv/lib/python3.12/site-packages (from ipython>=6.1.0->ipywidgets) (3.0.47)\n",
      "Requirement already satisfied: pygments>=2.4.0 in ./.venv/lib/python3.12/site-packages (from ipython>=6.1.0->ipywidgets) (2.18.0)\n",
      "Requirement already satisfied: stack-data in ./.venv/lib/python3.12/site-packages (from ipython>=6.1.0->ipywidgets) (0.6.3)\n",
      "Requirement already satisfied: pexpect>4.3 in ./.venv/lib/python3.12/site-packages (from ipython>=6.1.0->ipywidgets) (4.9.0)\n",
      "Requirement already satisfied: parso<0.9.0,>=0.8.3 in ./.venv/lib/python3.12/site-packages (from jedi>=0.16->ipython>=6.1.0->ipywidgets) (0.8.4)\n",
      "Requirement already satisfied: ptyprocess>=0.5 in ./.venv/lib/python3.12/site-packages (from pexpect>4.3->ipython>=6.1.0->ipywidgets) (0.7.0)\n",
      "Requirement already satisfied: wcwidth in ./.venv/lib/python3.12/site-packages (from prompt-toolkit<3.1.0,>=3.0.41->ipython>=6.1.0->ipywidgets) (0.2.13)\n",
      "Requirement already satisfied: executing>=1.2.0 in ./.venv/lib/python3.12/site-packages (from stack-data->ipython>=6.1.0->ipywidgets) (2.1.0)\n",
      "Requirement already satisfied: asttokens>=2.1.0 in ./.venv/lib/python3.12/site-packages (from stack-data->ipython>=6.1.0->ipywidgets) (2.4.1)\n",
      "Requirement already satisfied: pure-eval in ./.venv/lib/python3.12/site-packages (from stack-data->ipython>=6.1.0->ipywidgets) (0.2.3)\n",
      "Requirement already satisfied: six>=1.12.0 in ./.venv/lib/python3.12/site-packages (from asttokens>=2.1.0->stack-data->ipython>=6.1.0->ipywidgets) (1.16.0)\n",
      "Using cached ipywidgets-8.1.5-py3-none-any.whl (139 kB)\n",
      "Using cached jupyterlab_widgets-3.0.13-py3-none-any.whl (214 kB)\n",
      "Using cached widgetsnbextension-4.0.13-py3-none-any.whl (2.3 MB)\n",
      "Installing collected packages: widgetsnbextension, jupyterlab-widgets, ipywidgets\n",
      "Successfully installed ipywidgets-8.1.5 jupyterlab-widgets-3.0.13 widgetsnbextension-4.0.13\n"
     ]
    }
   ],
   "source": [
    "!pip install spacy\n",
    "!python -m spacy download en_core_web_sm\n",
    "!pip install ipywidgets"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [],
   "source": [
    "import spacy\n",
    "import dotenv\n",
    "from rich.console import Console\n",
    "\n",
    "import web_rag as wr\n",
    "import web_crawler as wc\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "True"
      ]
     },
     "execution_count": 14,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "console = Console()\n",
    "dotenv.load_dotenv()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 40,
   "metadata": {},
   "outputs": [],
   "source": [
    "if not spacy.util.is_package(\"en_core_web_sm\"):\n",
    "    print(\"Downloading en_core_web_sm model...\")\n",
    "    spacy.cli.download(\"en_core_web_sm\")\n",
    "    print(\"Model downloaded successfully!\")\n",
    "nlp = spacy.load(\"en_core_web_sm\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 41,
   "metadata": {},
   "outputs": [],
   "source": [
    "chat, embedding_model = wr.get_models(\"openai\", \"gpt-4o-mini\", 0.5)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 108,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\">Elizabeth Holmes trial verdict guilty\n",
       "</pre>\n"
      ],
      "text/plain": [
       "Elizabeth Holmes trial verdict guilty\n"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "from datetime import date\n",
    "today = date.today().strftime(\"%B %d, %Y\")\n",
    "query = f\"Is Elizabeth Holmes guilty?\"\n",
    "optimized_search_query = wr.optimize_search_query(chat, query)\n",
    "console.print(optimized_search_query)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 109,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\">retrieved <span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">5</span> contents\n",
       "</pre>\n"
      ],
      "text/plain": [
       "retrieved \u001b[1;36m5\u001b[0m contents\n"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "sources = wc.get_sources(optimized_search_query, max_pages=5)\n",
    "contents = wc.get_links_contents(sources)\n",
    "console.print(f\"retrieved {len(contents)} contents\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 110,
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "/var/folders/6k/6b1pw86x1yvc1_ds42gc1ms80000gq/T/ipykernel_7568/1451878299.py:13: UserWarning: [W007] The model you're using has no word vectors loaded, so the result of the Doc.similarity method will be based on the tagger, parser and NER, which may not give useful similarity judgements. This may happen if you're using one of the small models, e.g. `en_core_web_sm`, which don't ship with word vectors and only use context-sensitive tensors. You can always add your own word vectors, or use one of the larger models instead if available.\n",
      "  if prev_sent.similarity(curr_sent) >= similarity_threshold:\n"
     ]
    },
    {
     "data": {
      "text/html": [
       "<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\">Created <span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">115</span> semantic chunks\n",
       "</pre>\n"
      ],
      "text/plain": [
       "Created \u001b[1;36m115\u001b[0m semantic chunks\n"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/html": [
       "<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\">Sample chunk:\n",
       "</pre>\n"
      ],
      "text/plain": [
       "Sample chunk:\n"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/html": [
       "<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\"><span style=\"font-weight: bold\">{</span>\n",
       "    <span style=\"color: #008000; text-decoration-color: #008000\">'text'</span>: <span style=\"color: #008000; text-decoration-color: #008000\">\"Theranos founder Elizabeth Holmes was sentenced Friday to more than 11 years in prison for fraud after</span>\n",
       "<span style=\"color: #008000; text-decoration-color: #008000\">deceiving investors about the purported efficacy of her company's blood-testing technology.\"</span>,\n",
       "    <span style=\"color: #008000; text-decoration-color: #008000\">'metadata'</span>: <span style=\"font-weight: bold\">{</span>\n",
       "        <span style=\"color: #008000; text-decoration-color: #008000\">'title'</span>: <span style=\"color: #008000; text-decoration-color: #008000\">'Theranos founder Elizabeth Holmes sentenced to more than 11 years in prison'</span>,\n",
       "        <span style=\"color: #008000; text-decoration-color: #008000\">'source'</span>: \n",
       "<span style=\"color: #008000; text-decoration-color: #008000\">'https://www.cnbc.com/2022/11/18/former-theranos-ceo-elizabeth-holmes-sentenced-to-more-than-11-years-in-prison.htm</span>\n",
       "<span style=\"color: #008000; text-decoration-color: #008000\">l'</span>\n",
       "    <span style=\"font-weight: bold\">}</span>\n",
       "<span style=\"font-weight: bold\">}</span>\n",
       "</pre>\n"
      ],
      "text/plain": [
       "\u001b[1m{\u001b[0m\n",
       "    \u001b[32m'text'\u001b[0m: \u001b[32m\"Theranos founder Elizabeth Holmes was sentenced Friday to more than 11 years in prison for fraud after\u001b[0m\n",
       "\u001b[32mdeceiving investors about the purported efficacy of her company's blood-testing technology.\"\u001b[0m,\n",
       "    \u001b[32m'metadata'\u001b[0m: \u001b[1m{\u001b[0m\n",
       "        \u001b[32m'title'\u001b[0m: \u001b[32m'Theranos founder Elizabeth Holmes sentenced to more than 11 years in prison'\u001b[0m,\n",
       "        \u001b[32m'source'\u001b[0m: \n",
       "\u001b[32m'https://www.cnbc.com/2022/11/18/former-theranos-ceo-elizabeth-holmes-sentenced-to-more-than-11-years-in-prison.htm\u001b[0m\n",
       "\u001b[32ml'\u001b[0m\n",
       "    \u001b[1m}\u001b[0m\n",
       "\u001b[1m}\u001b[0m\n"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "from itertools import groupby\n",
    "from operator import itemgetter\n",
    "\n",
    "def group_similar_sentences(sentences, similarity_threshold=0.5):\n",
    "    grouped_sentences = []\n",
    "    for i, sentence in enumerate(sentences):\n",
    "        if i == 0:\n",
    "            grouped_sentences.append([sentence])\n",
    "        else:\n",
    "            prev_group = grouped_sentences[-1]\n",
    "            prev_sent = nlp(' '.join([s.text for s in prev_group]))\n",
    "            curr_sent = nlp(sentence.text)\n",
    "            if prev_sent.similarity(curr_sent) >= similarity_threshold:\n",
    "                prev_group.append(sentence)\n",
    "            else:\n",
    "                grouped_sentences.append([sentence])\n",
    "    return grouped_sentences\n",
    "\n",
    "# Initialize an empty list to store the semantically split content\n",
    "semantic_chunks = []\n",
    "\n",
    "# Iterate through the contents\n",
    "for content in contents:\n",
    "    # Extract the page content\n",
    "    page_content = content.get('page_content', '')\n",
    "    \n",
    "    if page_content:\n",
    "        # Process the text with spaCy\n",
    "        doc = nlp(page_content)\n",
    "        \n",
    "        # Split the content into sentences\n",
    "        sentences = list(doc.sents)\n",
    "        \n",
    "        # Group similar sentences\n",
    "        grouped_sentences = group_similar_sentences(sentences)\n",
    "        \n",
    "        for group in grouped_sentences:\n",
    "            # Create a chunk with the grouped sentences and metadata\n",
    "            chunk = {\n",
    "                'text': ' '.join([sent.text for sent in group]),\n",
    "                'metadata': {\n",
    "                    'title': content.get('title', ''),\n",
    "                    'source': content.get('link', '')\n",
    "                }\n",
    "            }\n",
    "            semantic_chunks.append(chunk)\n",
    "\n",
    "# Print the number of semantic chunks created\n",
    "console.print(f\"Created {len(semantic_chunks)} semantic chunks\")\n",
    "\n",
    "# Optionally, print a sample chunk to verify the structure\n",
    "if semantic_chunks:\n",
    "    console.print(\"Sample chunk:\")\n",
    "    console.print(semantic_chunks[0])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 103,
   "metadata": {},
   "outputs": [
    {
     "ename": "SyntaxError",
     "evalue": "invalid syntax (1591802571.py, line 33)",
     "output_type": "error",
     "traceback": [
      "\u001b[0;36m  Cell \u001b[0;32mIn[103], line 33\u001b[0;36m\u001b[0m\n\u001b[0;31m    sents, vecs = process(contents[0].)\u001b[0m\n\u001b[0m                                      ^\u001b[0m\n\u001b[0;31mSyntaxError\u001b[0m\u001b[0;31m:\u001b[0m invalid syntax\n"
     ]
    }
   ],
   "source": [
    "import numpy as np\n",
    "import spacy\n",
    "\n",
    "# Load the Spacy model\n",
    "nlp = spacy.load('en_core_web_sm')\n",
    "\n",
    "def process(text):\n",
    "    doc = nlp(text)\n",
    "    sents = list(doc.sents)\n",
    "    vecs = np.stack([sent.vector / sent.vector_norm for sent in sents])\n",
    "\n",
    "    return sents, vecs\n",
    "\n",
    "def cluster_text(sents, vecs, threshold):\n",
    "    clusters = [[0]]\n",
    "    for i in range(1, len(sents)):\n",
    "        if np.dot(vecs[i], vecs[i-1]) < threshold:\n",
    "            clusters.append([])\n",
    "        clusters[-1].append(i)\n",
    "    \n",
    "    return clusters\n",
    "\n",
    "def clean_text(text):\n",
    "    # Add your text cleaning process here\n",
    "    return text\n",
    "\n",
    "# Initialize the clusters lengths list and final texts list\n",
    "clusters_lens = []\n",
    "final_texts = []\n",
    "\n",
    "# Process the chunk\n",
    "threshold = 0.3\n",
    "sents, vecs = process(contents[0].)\n",
    "\n",
    "# Cluster the sentences\n",
    "clusters = cluster_text(sents, vecs, threshold)\n",
    "\n",
    "for cluster in clusters:\n",
    "    cluster_txt = clean_text(' '.join([sents[i].text for i in cluster]))\n",
    "    cluster_len = len(cluster_txt)\n",
    "    \n",
    "    # Check if the cluster is too short\n",
    "    if cluster_len < 60:\n",
    "        continue\n",
    "    \n",
    "    # Check if the cluster is too long\n",
    "    elif cluster_len > 3000:\n",
    "        threshold = 0.6\n",
    "        sents_div, vecs_div = process(cluster_txt)\n",
    "        reclusters = cluster_text(sents_div, vecs_div, threshold)\n",
    "        \n",
    "        for subcluster in reclusters:\n",
    "            div_txt = clean_text(' '.join([sents_div[i].text for i in subcluster]))\n",
    "            div_len = len(div_txt)\n",
    "            \n",
    "            if div_len < 60 or div_len > 3000:\n",
    "                continue\n",
    "            \n",
    "            clusters_lens.append(div_len)\n",
    "            final_texts.append(div_txt)\n",
    "            \n",
    "    else:\n",
    "        clusters_lens.append(cluster_len)\n",
    "        final_texts.append(cluster_txt)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 111,
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "/var/folders/6k/6b1pw86x1yvc1_ds42gc1ms80000gq/T/ipykernel_7568/342810436.py:8: UserWarning: [W007] The model you're using has no word vectors loaded, so the result of the Doc.similarity method will be based on the tagger, parser and NER, which may not give useful similarity judgements. This may happen if you're using one of the small models, e.g. `en_core_web_sm`, which don't ship with word vectors and only use context-sensitive tensors. You can always add your own word vectors, or use one of the larger models instead if available.\n",
      "  similarity = query_doc.similarity(chunk_doc)\n"
     ]
    },
    {
     "data": {
      "text/html": [
       "<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\">Found <span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">8</span> relevant chunks\n",
       "</pre>\n"
      ],
      "text/plain": [
       "Found \u001b[1;36m8\u001b[0m relevant chunks\n"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/html": [
       "<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\">\n",
       "Top relevant chunks:\n",
       "</pre>\n"
      ],
      "text/plain": [
       "\n",
       "Top relevant chunks:\n"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/html": [
       "<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\">\n",
       "<span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">1</span>. Similarity: <span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">0.6973</span>\n",
       "</pre>\n"
      ],
      "text/plain": [
       "\n",
       "\u001b[1;36m1\u001b[0m. Similarity: \u001b[1;36m0.6973\u001b[0m\n"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/html": [
       "<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\">Text: Related Content\n",
       "Press Release\n",
       "SAN JOSE โ€“ Elizabeth A. Holmes was sentenced today to <span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">135</span> months <span style=\"font-weight: bold\">(</span><span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">11</span> years, <span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">3</span> months<span style=\"font-weight: bold\">)</span> in federal prison for \n",
       "defrauding investors in Theranos, Inc. of hundreds of millions of dollars, announced United States Attorney \n",
       "Stephanie M. Hinds, Federal Bureau of Investigation Special Agent in Charge Robert K. Tripp, Food and Drug \n",
       "Administration <span style=\"font-weight: bold\">(</span>FDA<span style=\"font-weight: bold\">)</span> Assistant Commissioner for Criminal Investigations Catherine A. Hermsen, and U.S. Postal \n",
       "Inspection Service <span style=\"font-weight: bold\">(</span>USPIS<span style=\"font-weight: bold\">)</span> San Francisco Division Acting Inspector in Charge Kevin Rho. The sentence was handed \n",
       "down by United States District Judge Edward J. Davila.\n",
       " โ€œSilicon Valley has seen the rise of companies whose inventions have changed the world and, through intellectual \n",
       "prowess, hard work, and sheer determination, this region continues to innovate,โ€ said U.S. Attorney Stephanie M. \n",
       "Hinds.\n",
       "</pre>\n"
      ],
      "text/plain": [
       "Text: Related Content\n",
       "Press Release\n",
       "SAN JOSE โ€“ Elizabeth A. Holmes was sentenced today to \u001b[1;36m135\u001b[0m months \u001b[1m(\u001b[0m\u001b[1;36m11\u001b[0m years, \u001b[1;36m3\u001b[0m months\u001b[1m)\u001b[0m in federal prison for \n",
       "defrauding investors in Theranos, Inc. of hundreds of millions of dollars, announced United States Attorney \n",
       "Stephanie M. Hinds, Federal Bureau of Investigation Special Agent in Charge Robert K. Tripp, Food and Drug \n",
       "Administration \u001b[1m(\u001b[0mFDA\u001b[1m)\u001b[0m Assistant Commissioner for Criminal Investigations Catherine A. Hermsen, and U.S. Postal \n",
       "Inspection Service \u001b[1m(\u001b[0mUSPIS\u001b[1m)\u001b[0m San Francisco Division Acting Inspector in Charge Kevin Rho. The sentence was handed \n",
       "down by United States District Judge Edward J. Davila.\n",
       " โ€œSilicon Valley has seen the rise of companies whose inventions have changed the world and, through intellectual \n",
       "prowess, hard work, and sheer determination, this region continues to innovate,โ€ said U.S. Attorney Stephanie M. \n",
       "Hinds.\n"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/html": [
       "<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\">Source: \n",
       "<span style=\"color: #0000ff; text-decoration-color: #0000ff; text-decoration: underline\">https://www.justice.gov/usao-ndca/pr/elizabeth-holmes-sentenced-more-11-years-defrauding-theranos-investors-hundred</span>\n",
       "<span style=\"color: #0000ff; text-decoration-color: #0000ff; text-decoration: underline\">s</span>\n",
       "</pre>\n"
      ],
      "text/plain": [
       "Source: \n",
       "\u001b[4;94mhttps://www.justice.gov/usao-ndca/pr/elizabeth-holmes-sentenced-more-11-years-defrauding-theranos-investors-hundred\u001b[0m\n",
       "\u001b[4;94ms\u001b[0m\n"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/html": [
       "<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\">Title: Northern District of California | Elizabeth Holmes Sentenced To More Than <span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">11</span> Years For Defrauding Theranos \n",
       "Investors Of Hundreds Of Millions | United States Department of Justice\n",
       "</pre>\n"
      ],
      "text/plain": [
       "Title: Northern District of California | Elizabeth Holmes Sentenced To More Than \u001b[1;36m11\u001b[0m Years For Defrauding Theranos \n",
       "Investors Of Hundreds Of Millions | United States Department of Justice\n"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/html": [
       "<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\">\n",
       "<span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">2</span>. Similarity: <span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">0.6427</span>\n",
       "</pre>\n"
      ],
      "text/plain": [
       "\n",
       "\u001b[1;36m2\u001b[0m. Similarity: \u001b[1;36m0.6427\u001b[0m\n"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/html": [
       "<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\">Text: The FBI is committed to investigating corporate fraud and working with our partners to help keep our capital \n",
       "markets working effectively,โ€ said FBI Special Agent in Charge Robert K. Tripp. โ€œThe FBI and our partners worked \n",
       "tirelessly on this multi-year case and are proud justice has been served as a result.โ€\n",
       " โ€œTodayโ€™s announcement should serve as a reminder that fraud related to medical products will not be tolerated,โ€ \n",
       "said FDA Assistant Commissioner for Criminal Investigations Catherine A. Hermsen. โ€œThe FDA will continue to work \n",
       "with our law enforcement partners to bring to justice those who place profits above public health.โ€\n",
       " โ€œPostal Inspectors worked closely with our partners at the U.S. Attorneyโ€™s Office, the FDA Office of Criminal \n",
       "Investigations, and the FBI to bring this case to court,โ€ said USPIS San Francisco Division Acting Inspector in \n",
       "Charge Kevin Rho.\n",
       "</pre>\n"
      ],
      "text/plain": [
       "Text: The FBI is committed to investigating corporate fraud and working with our partners to help keep our capital \n",
       "markets working effectively,โ€ said FBI Special Agent in Charge Robert K. Tripp. โ€œThe FBI and our partners worked \n",
       "tirelessly on this multi-year case and are proud justice has been served as a result.โ€\n",
       " โ€œTodayโ€™s announcement should serve as a reminder that fraud related to medical products will not be tolerated,โ€ \n",
       "said FDA Assistant Commissioner for Criminal Investigations Catherine A. Hermsen. โ€œThe FDA will continue to work \n",
       "with our law enforcement partners to bring to justice those who place profits above public health.โ€\n",
       " โ€œPostal Inspectors worked closely with our partners at the U.S. Attorneyโ€™s Office, the FDA Office of Criminal \n",
       "Investigations, and the FBI to bring this case to court,โ€ said USPIS San Francisco Division Acting Inspector in \n",
       "Charge Kevin Rho.\n"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/html": [
       "<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\">Source: \n",
       "<span style=\"color: #0000ff; text-decoration-color: #0000ff; text-decoration: underline\">https://www.justice.gov/usao-ndca/pr/elizabeth-holmes-sentenced-more-11-years-defrauding-theranos-investors-hundred</span>\n",
       "<span style=\"color: #0000ff; text-decoration-color: #0000ff; text-decoration: underline\">s</span>\n",
       "</pre>\n"
      ],
      "text/plain": [
       "Source: \n",
       "\u001b[4;94mhttps://www.justice.gov/usao-ndca/pr/elizabeth-holmes-sentenced-more-11-years-defrauding-theranos-investors-hundred\u001b[0m\n",
       "\u001b[4;94ms\u001b[0m\n"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/html": [
       "<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\">Title: Northern District of California | Elizabeth Holmes Sentenced To More Than <span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">11</span> Years For Defrauding Theranos \n",
       "Investors Of Hundreds Of Millions | United States Department of Justice\n",
       "</pre>\n"
      ],
      "text/plain": [
       "Title: Northern District of California | Elizabeth Holmes Sentenced To More Than \u001b[1;36m11\u001b[0m Years For Defrauding Theranos \n",
       "Investors Of Hundreds Of Millions | United States Department of Justice\n"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/html": [
       "<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\">\n",
       "<span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">3</span>. Similarity: <span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">0.6053</span>\n",
       "</pre>\n"
      ],
      "text/plain": [
       "\n",
       "\u001b[1;36m3\u001b[0m. Similarity: \u001b[1;36m0.6053\u001b[0m\n"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/html": [
       "<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\">Text: The harsh ruling โ€“ which aligned with federal sentencing guidelines but was far more severe than the <span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">18</span> \n",
       "months of house arrest requested by Holmes โ€“ sends a strong message from the US government to Silicon Valley, said \n",
       "Anat Alon-Beck, a law professor at Case Western Reserve University in Ohio.\n",
       "\n",
       "</pre>\n"
      ],
      "text/plain": [
       "Text: The harsh ruling โ€“ which aligned with federal sentencing guidelines but was far more severe than the \u001b[1;36m18\u001b[0m \n",
       "months of house arrest requested by Holmes โ€“ sends a strong message from the US government to Silicon Valley, said \n",
       "Anat Alon-Beck, a law professor at Case Western Reserve University in Ohio.\n",
       "\n"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/html": [
       "<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\">Source: <span style=\"color: #0000ff; text-decoration-color: #0000ff; text-decoration: underline\">https://www.theguardian.com/us-news/2022/nov/18/elizabeth-holmes-theranos-trial-sentencing</span>\n",
       "</pre>\n"
      ],
      "text/plain": [
       "Source: \u001b[4;94mhttps://www.theguardian.com/us-news/2022/nov/18/elizabeth-holmes-theranos-trial-sentencing\u001b[0m\n"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/html": [
       "<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\">Title: Theranos founder Elizabeth Holmes sentenced to more than <span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">11</span> years for defrauding investors | Theranos | The \n",
       "Guardian\n",
       "</pre>\n"
      ],
      "text/plain": [
       "Title: Theranos founder Elizabeth Holmes sentenced to more than \u001b[1;36m11\u001b[0m years for defrauding investors | Theranos | The \n",
       "Guardian\n"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/html": [
       "<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\">\n",
       "<span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">4</span>. Similarity: <span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">0.5888</span>\n",
       "</pre>\n"
      ],
      "text/plain": [
       "\n",
       "\u001b[1;36m4\u001b[0m. Similarity: \u001b[1;36m0.5888\u001b[0m\n"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/html": [
       "<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\">Text: U.S. District Court Judge Edward Davila, who presided over Holmes' trial, handed down the sentence.\n",
       "\n",
       "</pre>\n"
      ],
      "text/plain": [
       "Text: U.S. District Court Judge Edward Davila, who presided over Holmes' trial, handed down the sentence.\n",
       "\n"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/html": [
       "<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\">Source: \n",
       "<span style=\"color: #0000ff; text-decoration-color: #0000ff; text-decoration: underline\">https://www.cnbc.com/2022/11/18/former-theranos-ceo-elizabeth-holmes-sentenced-to-more-than-11-years-in-prison.html</span>\n",
       "</pre>\n"
      ],
      "text/plain": [
       "Source: \n",
       "\u001b[4;94mhttps://www.cnbc.com/2022/11/18/former-theranos-ceo-elizabeth-holmes-sentenced-to-more-than-11-years-in-prison.html\u001b[0m\n"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/html": [
       "<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\">Title: Theranos founder Elizabeth Holmes sentenced to more than <span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">11</span> years in prison\n",
       "</pre>\n"
      ],
      "text/plain": [
       "Title: Theranos founder Elizabeth Holmes sentenced to more than \u001b[1;36m11\u001b[0m years in prison\n"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/html": [
       "<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\">\n",
       "<span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">5</span>. Similarity: <span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">0.5769</span>\n",
       "</pre>\n"
      ],
      "text/plain": [
       "\n",
       "\u001b[1;36m5\u001b[0m. Similarity: \u001b[1;36m0.5769\u001b[0m\n"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/html": [
       "<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\">Text: Assistant U.S. Attorneys Robert S. Leach, Jeff Schenk, John C. Bostic, and Kelly Volkar are prosecuting the \n",
       "case with the assistance of Madeline Wachs, Lakisha Holliman, Sara Slattery, Elise Etter, Susan Kreider, and Leeya \n",
       "Kekona. The prosecution is the result of an investigation by the FBI, USPIS, and the FDA Office of Criminal \n",
       "Investigations.\n",
       "</pre>\n"
      ],
      "text/plain": [
       "Text: Assistant U.S. Attorneys Robert S. Leach, Jeff Schenk, John C. Bostic, and Kelly Volkar are prosecuting the \n",
       "case with the assistance of Madeline Wachs, Lakisha Holliman, Sara Slattery, Elise Etter, Susan Kreider, and Leeya \n",
       "Kekona. The prosecution is the result of an investigation by the FBI, USPIS, and the FDA Office of Criminal \n",
       "Investigations.\n"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/html": [
       "<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\">Source: \n",
       "<span style=\"color: #0000ff; text-decoration-color: #0000ff; text-decoration: underline\">https://www.justice.gov/usao-ndca/pr/elizabeth-holmes-sentenced-more-11-years-defrauding-theranos-investors-hundred</span>\n",
       "<span style=\"color: #0000ff; text-decoration-color: #0000ff; text-decoration: underline\">s</span>\n",
       "</pre>\n"
      ],
      "text/plain": [
       "Source: \n",
       "\u001b[4;94mhttps://www.justice.gov/usao-ndca/pr/elizabeth-holmes-sentenced-more-11-years-defrauding-theranos-investors-hundred\u001b[0m\n",
       "\u001b[4;94ms\u001b[0m\n"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/html": [
       "<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\">Title: Northern District of California | Elizabeth Holmes Sentenced To More Than <span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">11</span> Years For Defrauding Theranos \n",
       "Investors Of Hundreds Of Millions | United States Department of Justice\n",
       "</pre>\n"
      ],
      "text/plain": [
       "Title: Northern District of California | Elizabeth Holmes Sentenced To More Than \u001b[1;36m11\u001b[0m Years For Defrauding Theranos \n",
       "Investors Of Hundreds Of Millions | United States Department of Justice\n"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "# Perform semantic search using spaCy\n",
    "def semantic_search(query, chunks, nlp, similarity_threshold=0.5):\n",
    "    query_doc = nlp(query)\n",
    "    relevant_chunks = []\n",
    "    \n",
    "    for chunk in chunks:\n",
    "        chunk_doc = nlp(chunk['text'])\n",
    "        similarity = query_doc.similarity(chunk_doc)\n",
    "        \n",
    "        if similarity > similarity_threshold:\n",
    "            relevant_chunks.append((chunk, similarity))\n",
    "    \n",
    "    # Sort the relevant chunks by similarity score in descending order\n",
    "    relevant_chunks.sort(key=lambda x: x[1], reverse=True)\n",
    "    \n",
    "    return relevant_chunks\n",
    "\n",
    "# Perform the semantic search\n",
    "relevant_results = semantic_search(optimized_search_query, semantic_chunks, nlp)\n",
    "\n",
    "# Print the number of relevant chunks found\n",
    "console.print(f\"Found {len(relevant_results)} relevant chunks\")\n",
    "\n",
    "# Print the top 5 most relevant chunks (or all if less than 5)\n",
    "console.print(\"\\nTop relevant chunks:\")\n",
    "for i, (chunk, similarity) in enumerate(relevant_results[:5], 1):\n",
    "    console.print(f\"\\n{i}. Similarity: {similarity:.4f}\")\n",
    "    console.print(f\"Text: {chunk['text']}\")\n",
    "    console.print(f\"Source: {chunk['metadata']['source']}\")\n",
    "    console.print(f\"Title: {chunk['metadata']['title']}\")\n",
    "\n",
    "# Optionally, you can store these results for further processing\n",
    "# relevant_chunks = [chunk for chunk, _ in relevant_results]\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 112,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\">Formatted chunks:\n",
       "</pre>\n"
      ],
      "text/plain": [
       "Formatted chunks:\n"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/html": [
       "<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\">\n",
       "    <span style=\"font-weight: bold\">&lt;</span><span style=\"color: #ff00ff; text-decoration-color: #ff00ff; font-weight: bold\">source</span><span style=\"color: #000000; text-decoration-color: #000000\">&gt;</span>\n",
       "<span style=\"color: #000000; text-decoration-color: #000000\">    &lt;url&gt;</span><span style=\"color: #0000ff; text-decoration-color: #0000ff; text-decoration: underline\">https://www.justice.gov/usao-ndca/pr/elizabeth-holmes-sentenced-more-11-years-defrauding-theranos-investor</span>\n",
       "<span style=\"color: #0000ff; text-decoration-color: #0000ff; text-decoration: underline\">s-hundreds</span><span style=\"color: #000000; text-decoration-color: #000000\">&lt;</span><span style=\"color: #800080; text-decoration-color: #800080\">/</span><span style=\"color: #ff00ff; text-decoration-color: #ff00ff\">url</span><span style=\"color: #000000; text-decoration-color: #000000\">&gt;</span>\n",
       "<span style=\"color: #000000; text-decoration-color: #000000\">    &lt;title&gt;Northern District of California | Elizabeth Holmes Sentenced To More Than </span><span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">11</span><span style=\"color: #000000; text-decoration-color: #000000\"> Years For Defrauding </span>\n",
       "<span style=\"color: #000000; text-decoration-color: #000000\">Theranos Investors Of Hundreds Of Millions | United States Department of Justice&lt;</span><span style=\"color: #800080; text-decoration-color: #800080\">/</span><span style=\"color: #ff00ff; text-decoration-color: #ff00ff\">title</span><span style=\"color: #000000; text-decoration-color: #000000\">&gt;</span>\n",
       "<span style=\"color: #000000; text-decoration-color: #000000\">    &lt;text&gt;Related Content</span>\n",
       "<span style=\"color: #000000; text-decoration-color: #000000\">Press Release</span>\n",
       "<span style=\"color: #000000; text-decoration-color: #000000\">SAN JOSE โ€“ Elizabeth A. Holmes was sentenced today to </span><span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">135</span><span style=\"color: #000000; text-decoration-color: #000000\"> months </span><span style=\"color: #000000; text-decoration-color: #000000; font-weight: bold\">(</span><span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">11</span><span style=\"color: #000000; text-decoration-color: #000000\"> years, </span><span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">3</span><span style=\"color: #000000; text-decoration-color: #000000\"> months</span><span style=\"color: #000000; text-decoration-color: #000000; font-weight: bold\">)</span><span style=\"color: #000000; text-decoration-color: #000000\"> in federal prison for </span>\n",
       "<span style=\"color: #000000; text-decoration-color: #000000\">defrauding investors in Theranos, Inc. of hundreds of millions of dollars, announced United States Attorney </span>\n",
       "<span style=\"color: #000000; text-decoration-color: #000000\">Stephanie M. Hinds, Federal Bureau of Investigation Special Agent in Charge Robert K. Tripp, Food and Drug </span>\n",
       "<span style=\"color: #000000; text-decoration-color: #000000\">Administration </span><span style=\"color: #000000; text-decoration-color: #000000; font-weight: bold\">(</span><span style=\"color: #000000; text-decoration-color: #000000\">FDA</span><span style=\"color: #000000; text-decoration-color: #000000; font-weight: bold\">)</span><span style=\"color: #000000; text-decoration-color: #000000\"> Assistant Commissioner for Criminal Investigations Catherine A. Hermsen, and U.S. Postal </span>\n",
       "<span style=\"color: #000000; text-decoration-color: #000000\">Inspection Service </span><span style=\"color: #000000; text-decoration-color: #000000; font-weight: bold\">(</span><span style=\"color: #000000; text-decoration-color: #000000\">USPIS</span><span style=\"color: #000000; text-decoration-color: #000000; font-weight: bold\">)</span><span style=\"color: #000000; text-decoration-color: #000000\"> San Francisco Division Acting Inspector in Charge Kevin Rho. The sentence was handed </span>\n",
       "<span style=\"color: #000000; text-decoration-color: #000000\">down by United States District Judge Edward J. Davila.</span>\n",
       "<span style=\"color: #000000; text-decoration-color: #000000\"> โ€œSilicon Valley has seen the rise of companies whose inventions have changed the world and, through intellectual </span>\n",
       "<span style=\"color: #000000; text-decoration-color: #000000\">prowess, hard work, and sheer determination, this region continues to innovate,โ€ said U.S. Attorney Stephanie M. </span>\n",
       "<span style=\"color: #000000; text-decoration-color: #000000\">Hinds.&lt;</span><span style=\"color: #800080; text-decoration-color: #800080\">/</span><span style=\"color: #ff00ff; text-decoration-color: #ff00ff\">text</span><span style=\"color: #000000; text-decoration-color: #000000\">&gt;</span>\n",
       "<span style=\"color: #000000; text-decoration-color: #000000\">    &lt;</span><span style=\"color: #800080; text-decoration-color: #800080\">/</span><span style=\"color: #ff00ff; text-decoration-color: #ff00ff\">source</span><span style=\"color: #000000; text-decoration-color: #000000\">&gt;</span>\n",
       "<span style=\"color: #000000; text-decoration-color: #000000\">    </span>\n",
       "<span style=\"color: #000000; text-decoration-color: #000000\">    </span>\n",
       "<span style=\"color: #000000; text-decoration-color: #000000\">    &lt;source&gt;</span>\n",
       "<span style=\"color: #000000; text-decoration-color: #000000\">    &lt;url&gt;</span><span style=\"color: #0000ff; text-decoration-color: #0000ff; text-decoration: underline\">https://www.justice.gov/usao-ndca/pr/elizabeth-holmes-sentenced-more-11-years-defrauding-theranos-investor</span>\n",
       "<span style=\"color: #0000ff; text-decoration-color: #0000ff; text-decoration: underline\">s-hundreds</span><span style=\"color: #000000; text-decoration-color: #000000\">&lt;</span><span style=\"color: #800080; text-decoration-color: #800080\">/</span><span style=\"color: #ff00ff; text-decoration-color: #ff00ff\">url</span><span style=\"color: #000000; text-decoration-color: #000000\">&gt;</span>\n",
       "<span style=\"color: #000000; text-decoration-color: #000000\">    &lt;title&gt;Northern District of California | Elizabeth Holmes Sentenced To More Than </span><span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">11</span><span style=\"color: #000000; text-decoration-color: #000000\"> Years For Defrauding </span>\n",
       "<span style=\"color: #000000; text-decoration-color: #000000\">Theranos Investors Of Hundreds Of Millions | United States Department of Justice&lt;</span><span style=\"color: #800080; text-decoration-color: #800080\">/</span><span style=\"color: #ff00ff; text-decoration-color: #ff00ff\">title</span><span style=\"color: #000000; text-decoration-color: #000000\">&gt;</span>\n",
       "<span style=\"color: #000000; text-decoration-color: #000000\">    &lt;text&gt;The FBI is committed to investigating corporate fraud and working with our partners to help keep our </span>\n",
       "<span style=\"color: #000000; text-decoration-color: #000000\">capital markets working effectively,โ€ said FBI Special Agent in Charge Robert K. Tripp. โ€œThe FBI and our partners </span>\n",
       "<span style=\"color: #000000; text-decoration-color: #000000\">worked tirelessly on this multi-year case and are proud justice has been served as a result.โ€</span>\n",
       "<span style=\"color: #000000; text-decoration-color: #000000\"> โ€œTodayโ€™s announcement should serve as a reminder that fraud related to medical products will not be tolerated,โ€ </span>\n",
       "<span style=\"color: #000000; text-decoration-color: #000000\">said FDA Assistant Commissioner for Criminal Investigations Catherine A. Hermsen. โ€œThe FDA will continue to work </span>\n",
       "<span style=\"color: #000000; text-decoration-color: #000000\">with our law enforcement partners to bring to justice those who place profits above public health.โ€</span>\n",
       "<span style=\"color: #000000; text-decoration-color: #000000\"> โ€œPostal Inspectors worked closely with our partners at the U.S. Attorneyโ€™s Office, the FDA Office of Criminal </span>\n",
       "<span style=\"color: #000000; text-decoration-color: #000000\">Investigations, and the FBI to bring this case to court,โ€ said USPIS San Francisco Division Acting Inspector in </span>\n",
       "<span style=\"color: #000000; text-decoration-color: #000000\">Charge Kevin Rho.&lt;</span><span style=\"color: #800080; text-decoration-color: #800080\">/</span><span style=\"color: #ff00ff; text-decoration-color: #ff00ff\">text</span><span style=\"color: #000000; text-decoration-color: #000000\">&gt;</span>\n",
       "<span style=\"color: #000000; text-decoration-color: #000000\">    &lt;</span><span style=\"color: #800080; text-decoration-color: #800080\">/</span><span style=\"color: #ff00ff; text-decoration-color: #ff00ff\">source</span><span style=\"color: #000000; text-decoration-color: #000000\">&gt;</span>\n",
       "<span style=\"color: #000000; text-decoration-color: #000000\">    </span>\n",
       "<span style=\"color: #000000; text-decoration-color: #000000\">    </span>\n",
       "<span style=\"color: #000000; text-decoration-color: #000000\">    &lt;source&gt;</span>\n",
       "<span style=\"color: #000000; text-decoration-color: #000000\">    &lt;url&gt;</span><span style=\"color: #0000ff; text-decoration-color: #0000ff; text-decoration: underline\">https://www.theguardian.com/us-news/2022/nov/18/elizabeth-holmes-theranos-trial-sentencing</span><span style=\"color: #000000; text-decoration-color: #000000\">&lt;</span><span style=\"color: #800080; text-decoration-color: #800080\">/</span><span style=\"color: #ff00ff; text-decoration-color: #ff00ff\">url</span><span style=\"color: #000000; text-decoration-color: #000000\">&gt;</span>\n",
       "<span style=\"color: #000000; text-decoration-color: #000000\">    &lt;title&gt;Theranos founder Elizabeth Holmes sentenced to more than </span><span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">11</span><span style=\"color: #000000; text-decoration-color: #000000\"> years for defrauding investors | Theranos | </span>\n",
       "<span style=\"color: #000000; text-decoration-color: #000000\">The Guardian&lt;</span><span style=\"color: #800080; text-decoration-color: #800080\">/</span><span style=\"color: #ff00ff; text-decoration-color: #ff00ff\">title</span><span style=\"color: #000000; text-decoration-color: #000000\">&gt;</span>\n",
       "<span style=\"color: #000000; text-decoration-color: #000000\">    &lt;text&gt;The harsh ruling โ€“ which aligned with federal sentencing guidelines but was far more severe than the </span><span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">18</span><span style=\"color: #000000; text-decoration-color: #000000\"> </span>\n",
       "<span style=\"color: #000000; text-decoration-color: #000000\">months of house arrest requested by Holmes โ€“ sends a strong message from the US government to Silicon Valley, said </span>\n",
       "<span style=\"color: #000000; text-decoration-color: #000000\">Anat Alon-Beck, a law professor at Case Western Reserve University in Ohio.</span>\n",
       "<span style=\"color: #000000; text-decoration-color: #000000\">&lt;</span><span style=\"color: #800080; text-decoration-color: #800080\">/</span><span style=\"color: #ff00ff; text-decoration-color: #ff00ff\">text</span><span style=\"color: #000000; text-decoration-color: #000000\">&gt;</span>\n",
       "<span style=\"color: #000000; text-decoration-color: #000000\">    &lt;</span><span style=\"color: #800080; text-decoration-color: #800080\">/</span><span style=\"color: #ff00ff; text-decoration-color: #ff00ff\">source</span><span style=\"color: #000000; text-decoration-color: #000000\">&gt;</span>\n",
       "<span style=\"color: #000000; text-decoration-color: #000000\">    </span>\n",
       "<span style=\"color: #000000; text-decoration-color: #000000\">    </span>\n",
       "<span style=\"color: #000000; text-decoration-color: #000000\">    &lt;source&gt;</span>\n",
       "<span style=\"color: #000000; text-decoration-color: #000000\">    &lt;url&gt;</span><span style=\"color: #0000ff; text-decoration-color: #0000ff; text-decoration: underline\">https://www.cnbc.com/2022/11/18/former-theranos-ceo-elizabeth-holmes-sentenced-to-more-than-11-years-in-pr</span>\n",
       "<span style=\"color: #0000ff; text-decoration-color: #0000ff; text-decoration: underline\">ison.html</span><span style=\"color: #000000; text-decoration-color: #000000\">&lt;</span><span style=\"color: #800080; text-decoration-color: #800080\">/</span><span style=\"color: #ff00ff; text-decoration-color: #ff00ff\">url</span><span style=\"color: #000000; text-decoration-color: #000000\">&gt;</span>\n",
       "<span style=\"color: #000000; text-decoration-color: #000000\">    &lt;title&gt;Theranos founder Elizabeth Holmes sentenced to more than </span><span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">11</span><span style=\"color: #000000; text-decoration-color: #000000\"> years in prison&lt;</span><span style=\"color: #800080; text-decoration-color: #800080\">/</span><span style=\"color: #ff00ff; text-decoration-color: #ff00ff\">title</span><span style=\"color: #000000; text-decoration-color: #000000\">&gt;</span>\n",
       "<span style=\"color: #000000; text-decoration-color: #000000\">    &lt;text&gt;U.S. District Court Judge Edward Davila, who presided over Holmes' trial, handed down the sentence.</span>\n",
       "<span style=\"color: #000000; text-decoration-color: #000000\">&lt;</span><span style=\"color: #800080; text-decoration-color: #800080\">/</span><span style=\"color: #ff00ff; text-decoration-color: #ff00ff\">text</span><span style=\"color: #000000; text-decoration-color: #000000\">&gt;</span>\n",
       "<span style=\"color: #000000; text-decoration-color: #000000\">    &lt;</span><span style=\"color: #800080; text-decoration-color: #800080\">/</span><span style=\"color: #ff00ff; text-decoration-color: #ff00ff\">source</span><span style=\"color: #000000; text-decoration-color: #000000\">&gt;</span>\n",
       "<span style=\"color: #000000; text-decoration-color: #000000\">    </span>\n",
       "<span style=\"color: #000000; text-decoration-color: #000000\">    </span>\n",
       "<span style=\"color: #000000; text-decoration-color: #000000\">    &lt;source&gt;</span>\n",
       "<span style=\"color: #000000; text-decoration-color: #000000\">    &lt;url&gt;</span><span style=\"color: #0000ff; text-decoration-color: #0000ff; text-decoration: underline\">https://www.justice.gov/usao-ndca/pr/elizabeth-holmes-sentenced-more-11-years-defrauding-theranos-investor</span>\n",
       "<span style=\"color: #0000ff; text-decoration-color: #0000ff; text-decoration: underline\">s-hundreds</span><span style=\"color: #000000; text-decoration-color: #000000\">&lt;</span><span style=\"color: #800080; text-decoration-color: #800080\">/</span><span style=\"color: #ff00ff; text-decoration-color: #ff00ff\">url</span><span style=\"color: #000000; text-decoration-color: #000000\">&gt;</span>\n",
       "<span style=\"color: #000000; text-decoration-color: #000000\">    &lt;title&gt;Northern District of California | Elizabeth Holmes Sentenced To More Than </span><span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">11</span><span style=\"color: #000000; text-decoration-color: #000000\"> Years For Defrauding </span>\n",
       "<span style=\"color: #000000; text-decoration-color: #000000\">Theranos Investors Of Hundreds Of Millions | United States Department of Justice&lt;</span><span style=\"color: #800080; text-decoration-color: #800080\">/</span><span style=\"color: #ff00ff; text-decoration-color: #ff00ff\">title</span><span style=\"color: #000000; text-decoration-color: #000000\">&gt;</span>\n",
       "<span style=\"color: #000000; text-decoration-color: #000000\">    &lt;text&gt;Assistant U.S. Attorneys Robert S. Leach, Jeff Schenk, John C. Bostic, and Kelly Volkar are prosecuting </span>\n",
       "<span style=\"color: #000000; text-decoration-color: #000000\">the case with the assistance of Madeline Wachs, Lakisha Holliman, Sara Slattery, Elise Etter, Susan Kreider, and </span>\n",
       "<span style=\"color: #000000; text-decoration-color: #000000\">Leeya Kekona. The prosecution is the result of an investigation by the FBI, USPIS, and the FDA Office of Criminal </span>\n",
       "<span style=\"color: #000000; text-decoration-color: #000000\">Investigations.&lt;</span><span style=\"color: #800080; text-decoration-color: #800080\">/</span><span style=\"color: #ff00ff; text-decoration-color: #ff00ff\">text</span><span style=\"color: #000000; text-decoration-color: #000000\">&gt;</span>\n",
       "<span style=\"color: #000000; text-decoration-color: #000000\">    &lt;</span><span style=\"color: #800080; text-decoration-color: #800080\">/</span><span style=\"color: #ff00ff; text-decoration-color: #ff00ff\">source</span><span style=\"color: #000000; text-decoration-color: #000000\">&gt;</span>\n",
       "<span style=\"color: #000000; text-decoration-color: #000000\">    </span>\n",
       "<span style=\"color: #000000; text-decoration-color: #000000\">    </span>\n",
       "<span style=\"color: #000000; text-decoration-color: #000000\">    &lt;source&gt;</span>\n",
       "<span style=\"color: #000000; text-decoration-color: #000000\">    &lt;url&gt;</span><span style=\"color: #0000ff; text-decoration-color: #0000ff; text-decoration: underline\">https://www.bbc.com/news/business-58336998</span><span style=\"color: #000000; text-decoration-color: #000000\">&lt;</span><span style=\"color: #800080; text-decoration-color: #800080\">/</span><span style=\"color: #ff00ff; text-decoration-color: #ff00ff\">url</span><span style=\"color: #000000; text-decoration-color: #000000\">&gt;</span>\n",
       "<span style=\"color: #000000; text-decoration-color: #000000\">    &lt;title&gt;Theranos scandal: Who is Elizabeth Holmes and why was she on trial?&lt;</span><span style=\"color: #800080; text-decoration-color: #800080\">/</span><span style=\"color: #ff00ff; text-decoration-color: #ff00ff\">title</span><span style=\"color: #000000; text-decoration-color: #000000\">&gt;</span>\n",
       "<span style=\"color: #000000; text-decoration-color: #000000\">    &lt;text&gt;US Treasury Secretary George Schultz, media tycoon Rupert Murdoch and America's richest family, the </span>\n",
       "<span style=\"color: #000000; text-decoration-color: #000000\">Waltons, were among her backers.</span>\n",
       "<span style=\"color: #000000; text-decoration-color: #000000\">&lt;</span><span style=\"color: #800080; text-decoration-color: #800080\">/</span><span style=\"color: #ff00ff; text-decoration-color: #ff00ff\">text</span><span style=\"color: #000000; text-decoration-color: #000000\">&gt;</span>\n",
       "<span style=\"color: #000000; text-decoration-color: #000000\">    &lt;</span><span style=\"color: #800080; text-decoration-color: #800080\">/</span><span style=\"color: #ff00ff; text-decoration-color: #ff00ff\">source</span><span style=\"color: #000000; text-decoration-color: #000000\">&gt;</span>\n",
       "<span style=\"color: #000000; text-decoration-color: #000000\">    </span>\n",
       "<span style=\"color: #000000; text-decoration-color: #000000\">    </span>\n",
       "<span style=\"color: #000000; text-decoration-color: #000000\">    &lt;source&gt;</span>\n",
       "<span style=\"color: #000000; text-decoration-color: #000000\">    &lt;url&gt;</span><span style=\"color: #0000ff; text-decoration-color: #0000ff; text-decoration: underline\">https://www.justice.gov/usao-ndca/pr/elizabeth-holmes-sentenced-more-11-years-defrauding-theranos-investor</span>\n",
       "<span style=\"color: #0000ff; text-decoration-color: #0000ff; text-decoration: underline\">s-hundreds</span><span style=\"color: #000000; text-decoration-color: #000000\">&lt;</span><span style=\"color: #800080; text-decoration-color: #800080\">/</span><span style=\"color: #ff00ff; text-decoration-color: #ff00ff\">url</span><span style=\"color: #000000; text-decoration-color: #000000\">&gt;</span>\n",
       "<span style=\"color: #000000; text-decoration-color: #000000\">    &lt;title&gt;Northern District of California | Elizabeth Holmes Sentenced To More Than </span><span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">11</span><span style=\"color: #000000; text-decoration-color: #000000\"> Years For Defrauding </span>\n",
       "<span style=\"color: #000000; text-decoration-color: #000000\">Theranos Investors Of Hundreds Of Millions | United States Department of Justice&lt;</span><span style=\"color: #800080; text-decoration-color: #800080\">/</span><span style=\"color: #ff00ff; text-decoration-color: #ff00ff\">title</span><span style=\"color: #000000; text-decoration-color: #000000\">&gt;</span>\n",
       "<span style=\"color: #000000; text-decoration-color: #000000\">    &lt;text&gt;The New York Times Style Magazine. Holmes dined at the White House, joined the Board of Fellows of </span>\n",
       "<span style=\"color: #000000; text-decoration-color: #000000\">Harvard Medical School, and was named by Time as one of the </span><span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">100</span><span style=\"color: #000000; text-decoration-color: #000000\"> Most Influential People in the World.&lt;</span><span style=\"color: #800080; text-decoration-color: #800080\">/</span><span style=\"color: #ff00ff; text-decoration-color: #ff00ff\">text</span><span style=\"color: #000000; text-decoration-color: #000000\">&gt;</span>\n",
       "<span style=\"color: #000000; text-decoration-color: #000000\">    &lt;</span><span style=\"color: #800080; text-decoration-color: #800080\">/</span><span style=\"color: #ff00ff; text-decoration-color: #ff00ff\">source</span><span style=\"color: #000000; text-decoration-color: #000000\">&gt;</span>\n",
       "<span style=\"color: #000000; text-decoration-color: #000000\">    </span>\n",
       "<span style=\"color: #000000; text-decoration-color: #000000\">    </span>\n",
       "<span style=\"color: #000000; text-decoration-color: #000000\">    &lt;source&gt;</span>\n",
       "<span style=\"color: #000000; text-decoration-color: #000000\">    &lt;url&gt;</span><span style=\"color: #0000ff; text-decoration-color: #0000ff; text-decoration: underline\">https://www.npr.org/2023/05/30/1178728092/elizabeth-holmes-prison-sentence-theranos-fraud-silicon-valley</span><span style=\"color: #000000; text-decoration-color: #000000\">&lt;</span><span style=\"color: #800080; text-decoration-color: #800080\">/</span>\n",
       "<span style=\"color: #ff00ff; text-decoration-color: #ff00ff\">url</span><span style=\"color: #000000; text-decoration-color: #000000\">&gt;</span>\n",
       "<span style=\"color: #000000; text-decoration-color: #000000\">    &lt;title&gt;Elizabeth Holmes has started her </span><span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">11</span><span style=\"color: #000000; text-decoration-color: #000000\">-year prison sentence. Here's what to know&lt;</span><span style=\"color: #800080; text-decoration-color: #800080\">/</span><span style=\"color: #ff00ff; text-decoration-color: #ff00ff\">title</span><span style=\"color: #000000; text-decoration-color: #000000\">&gt;</span>\n",
       "<span style=\"color: #000000; text-decoration-color: #000000\">    &lt;text&gt;Elizabeth Holmes has started her </span><span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">11</span><span style=\"color: #000000; text-decoration-color: #000000\">-year prison sentence. Here's what to know</span>\n",
       "<span style=\"color: #000000; text-decoration-color: #000000\">Disgraced Silicon Valley superstar Elizabeth Holmes has surrendered to federal prison in Texas to begin serving a </span>\n",
       "<span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">11</span><span style=\"color: #000000; text-decoration-color: #000000\">-year term for defrauding investors with her once high-flying blood-testing company Theranos.</span>\n",
       "<span style=\"color: #000000; text-decoration-color: #000000\"> Holmes, a </span><span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">39</span><span style=\"color: #000000; text-decoration-color: #000000\">-year-old mother of two, reported Tuesday to the prison camp in Bryan, Texas, an all-female facility </span>\n",
       "<span style=\"color: #000000; text-decoration-color: #000000\">about </span><span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">100</span><span style=\"color: #000000; text-decoration-color: #000000\"> miles outside of Houston, where some family members of Holmes reside.</span>\n",
       "<span style=\"color: #000000; text-decoration-color: #000000\"> Lawyers for Holmes attempted to delay the start of her prison sentence by asking that she remain free while she </span>\n",
       "<span style=\"color: #000000; text-decoration-color: #000000\">appeals her conviction, but the 9th Circuit Court of Appeals denied her request, ruling that Holmes has not raised </span>\n",
       "<span style=\"color: #000000; text-decoration-color: #000000\">a </span><span style=\"color: #008000; text-decoration-color: #008000\">\"substantial question\"</span><span style=\"color: #000000; text-decoration-color: #000000\"> of law or fact about her case.</span>\n",
       "<span style=\"color: #000000; text-decoration-color: #000000\"> Here's what to know about the incarceration of Holmes, the most high-profile tech executive to be sentenced to </span>\n",
       "<span style=\"color: #000000; text-decoration-color: #000000\">prison time.</span>\n",
       "<span style=\"color: #000000; text-decoration-color: #000000\">&lt;</span><span style=\"color: #800080; text-decoration-color: #800080\">/</span><span style=\"color: #ff00ff; text-decoration-color: #ff00ff\">text</span><span style=\"color: #000000; text-decoration-color: #000000\">&gt;</span>\n",
       "<span style=\"color: #000000; text-decoration-color: #000000\">    &lt;</span><span style=\"color: #800080; text-decoration-color: #800080\">/</span><span style=\"color: #ff00ff; text-decoration-color: #ff00ff\">source</span><span style=\"font-weight: bold\">&gt;</span>\n",
       "    \n",
       "    \n",
       "</pre>\n"
      ],
      "text/plain": [
       "\n",
       "    \u001b[1m<\u001b[0m\u001b[1;95msource\u001b[0m\u001b[39m>\u001b[0m\n",
       "\u001b[39m    <url>\u001b[0m\u001b[4;94mhttps://www.justice.gov/usao-ndca/pr/elizabeth-holmes-sentenced-more-11-years-defrauding-theranos-investor\u001b[0m\n",
       "\u001b[4;94ms-hundreds\u001b[0m\u001b[39m<\u001b[0m\u001b[35m/\u001b[0m\u001b[95murl\u001b[0m\u001b[39m>\u001b[0m\n",
       "\u001b[39m    <title>Northern District of California | Elizabeth Holmes Sentenced To More Than \u001b[0m\u001b[1;36m11\u001b[0m\u001b[39m Years For Defrauding \u001b[0m\n",
       "\u001b[39mTheranos Investors Of Hundreds Of Millions | United States Department of Justice<\u001b[0m\u001b[35m/\u001b[0m\u001b[95mtitle\u001b[0m\u001b[39m>\u001b[0m\n",
       "\u001b[39m    <text>Related Content\u001b[0m\n",
       "\u001b[39mPress Release\u001b[0m\n",
       "\u001b[39mSAN JOSE โ€“ Elizabeth A. Holmes was sentenced today to \u001b[0m\u001b[1;36m135\u001b[0m\u001b[39m months \u001b[0m\u001b[1;39m(\u001b[0m\u001b[1;36m11\u001b[0m\u001b[39m years, \u001b[0m\u001b[1;36m3\u001b[0m\u001b[39m months\u001b[0m\u001b[1;39m)\u001b[0m\u001b[39m in federal prison for \u001b[0m\n",
       "\u001b[39mdefrauding investors in Theranos, Inc. of hundreds of millions of dollars, announced United States Attorney \u001b[0m\n",
       "\u001b[39mStephanie M. Hinds, Federal Bureau of Investigation Special Agent in Charge Robert K. Tripp, Food and Drug \u001b[0m\n",
       "\u001b[39mAdministration \u001b[0m\u001b[1;39m(\u001b[0m\u001b[39mFDA\u001b[0m\u001b[1;39m)\u001b[0m\u001b[39m Assistant Commissioner for Criminal Investigations Catherine A. Hermsen, and U.S. Postal \u001b[0m\n",
       "\u001b[39mInspection Service \u001b[0m\u001b[1;39m(\u001b[0m\u001b[39mUSPIS\u001b[0m\u001b[1;39m)\u001b[0m\u001b[39m San Francisco Division Acting Inspector in Charge Kevin Rho. The sentence was handed \u001b[0m\n",
       "\u001b[39mdown by United States District Judge Edward J. Davila.\u001b[0m\n",
       "\u001b[39m โ€œSilicon Valley has seen the rise of companies whose inventions have changed the world and, through intellectual \u001b[0m\n",
       "\u001b[39mprowess, hard work, and sheer determination, this region continues to innovate,โ€ said U.S. Attorney Stephanie M. \u001b[0m\n",
       "\u001b[39mHinds.<\u001b[0m\u001b[35m/\u001b[0m\u001b[95mtext\u001b[0m\u001b[39m>\u001b[0m\n",
       "\u001b[39m    <\u001b[0m\u001b[35m/\u001b[0m\u001b[95msource\u001b[0m\u001b[39m>\u001b[0m\n",
       "\u001b[39m    \u001b[0m\n",
       "\u001b[39m    \u001b[0m\n",
       "\u001b[39m    <source>\u001b[0m\n",
       "\u001b[39m    <url>\u001b[0m\u001b[4;94mhttps://www.justice.gov/usao-ndca/pr/elizabeth-holmes-sentenced-more-11-years-defrauding-theranos-investor\u001b[0m\n",
       "\u001b[4;94ms-hundreds\u001b[0m\u001b[39m<\u001b[0m\u001b[35m/\u001b[0m\u001b[95murl\u001b[0m\u001b[39m>\u001b[0m\n",
       "\u001b[39m    <title>Northern District of California | Elizabeth Holmes Sentenced To More Than \u001b[0m\u001b[1;36m11\u001b[0m\u001b[39m Years For Defrauding \u001b[0m\n",
       "\u001b[39mTheranos Investors Of Hundreds Of Millions | United States Department of Justice<\u001b[0m\u001b[35m/\u001b[0m\u001b[95mtitle\u001b[0m\u001b[39m>\u001b[0m\n",
       "\u001b[39m    <text>The FBI is committed to investigating corporate fraud and working with our partners to help keep our \u001b[0m\n",
       "\u001b[39mcapital markets working effectively,โ€ said FBI Special Agent in Charge Robert K. Tripp. โ€œThe FBI and our partners \u001b[0m\n",
       "\u001b[39mworked tirelessly on this multi-year case and are proud justice has been served as a result.โ€\u001b[0m\n",
       "\u001b[39m โ€œTodayโ€™s announcement should serve as a reminder that fraud related to medical products will not be tolerated,โ€ \u001b[0m\n",
       "\u001b[39msaid FDA Assistant Commissioner for Criminal Investigations Catherine A. Hermsen. โ€œThe FDA will continue to work \u001b[0m\n",
       "\u001b[39mwith our law enforcement partners to bring to justice those who place profits above public health.โ€\u001b[0m\n",
       "\u001b[39m โ€œPostal Inspectors worked closely with our partners at the U.S. Attorneyโ€™s Office, the FDA Office of Criminal \u001b[0m\n",
       "\u001b[39mInvestigations, and the FBI to bring this case to court,โ€ said USPIS San Francisco Division Acting Inspector in \u001b[0m\n",
       "\u001b[39mCharge Kevin Rho.<\u001b[0m\u001b[35m/\u001b[0m\u001b[95mtext\u001b[0m\u001b[39m>\u001b[0m\n",
       "\u001b[39m    <\u001b[0m\u001b[35m/\u001b[0m\u001b[95msource\u001b[0m\u001b[39m>\u001b[0m\n",
       "\u001b[39m    \u001b[0m\n",
       "\u001b[39m    \u001b[0m\n",
       "\u001b[39m    <source>\u001b[0m\n",
       "\u001b[39m    <url>\u001b[0m\u001b[4;94mhttps://www.theguardian.com/us-news/2022/nov/18/elizabeth-holmes-theranos-trial-sentencing\u001b[0m\u001b[39m<\u001b[0m\u001b[35m/\u001b[0m\u001b[95murl\u001b[0m\u001b[39m>\u001b[0m\n",
       "\u001b[39m    <title>Theranos founder Elizabeth Holmes sentenced to more than \u001b[0m\u001b[1;36m11\u001b[0m\u001b[39m years for defrauding investors | Theranos | \u001b[0m\n",
       "\u001b[39mThe Guardian<\u001b[0m\u001b[35m/\u001b[0m\u001b[95mtitle\u001b[0m\u001b[39m>\u001b[0m\n",
       "\u001b[39m    <text>The harsh ruling โ€“ which aligned with federal sentencing guidelines but was far more severe than the \u001b[0m\u001b[1;36m18\u001b[0m\u001b[39m \u001b[0m\n",
       "\u001b[39mmonths of house arrest requested by Holmes โ€“ sends a strong message from the US government to Silicon Valley, said \u001b[0m\n",
       "\u001b[39mAnat Alon-Beck, a law professor at Case Western Reserve University in Ohio.\u001b[0m\n",
       "\u001b[39m<\u001b[0m\u001b[35m/\u001b[0m\u001b[95mtext\u001b[0m\u001b[39m>\u001b[0m\n",
       "\u001b[39m    <\u001b[0m\u001b[35m/\u001b[0m\u001b[95msource\u001b[0m\u001b[39m>\u001b[0m\n",
       "\u001b[39m    \u001b[0m\n",
       "\u001b[39m    \u001b[0m\n",
       "\u001b[39m    <source>\u001b[0m\n",
       "\u001b[39m    <url>\u001b[0m\u001b[4;94mhttps://www.cnbc.com/2022/11/18/former-theranos-ceo-elizabeth-holmes-sentenced-to-more-than-11-years-in-pr\u001b[0m\n",
       "\u001b[4;94mison.html\u001b[0m\u001b[39m<\u001b[0m\u001b[35m/\u001b[0m\u001b[95murl\u001b[0m\u001b[39m>\u001b[0m\n",
       "\u001b[39m    <title>Theranos founder Elizabeth Holmes sentenced to more than \u001b[0m\u001b[1;36m11\u001b[0m\u001b[39m years in prison<\u001b[0m\u001b[35m/\u001b[0m\u001b[95mtitle\u001b[0m\u001b[39m>\u001b[0m\n",
       "\u001b[39m    <text>U.S. District Court Judge Edward Davila, who presided over Holmes' trial, handed down the sentence.\u001b[0m\n",
       "\u001b[39m<\u001b[0m\u001b[35m/\u001b[0m\u001b[95mtext\u001b[0m\u001b[39m>\u001b[0m\n",
       "\u001b[39m    <\u001b[0m\u001b[35m/\u001b[0m\u001b[95msource\u001b[0m\u001b[39m>\u001b[0m\n",
       "\u001b[39m    \u001b[0m\n",
       "\u001b[39m    \u001b[0m\n",
       "\u001b[39m    <source>\u001b[0m\n",
       "\u001b[39m    <url>\u001b[0m\u001b[4;94mhttps://www.justice.gov/usao-ndca/pr/elizabeth-holmes-sentenced-more-11-years-defrauding-theranos-investor\u001b[0m\n",
       "\u001b[4;94ms-hundreds\u001b[0m\u001b[39m<\u001b[0m\u001b[35m/\u001b[0m\u001b[95murl\u001b[0m\u001b[39m>\u001b[0m\n",
       "\u001b[39m    <title>Northern District of California | Elizabeth Holmes Sentenced To More Than \u001b[0m\u001b[1;36m11\u001b[0m\u001b[39m Years For Defrauding \u001b[0m\n",
       "\u001b[39mTheranos Investors Of Hundreds Of Millions | United States Department of Justice<\u001b[0m\u001b[35m/\u001b[0m\u001b[95mtitle\u001b[0m\u001b[39m>\u001b[0m\n",
       "\u001b[39m    <text>Assistant U.S. Attorneys Robert S. Leach, Jeff Schenk, John C. Bostic, and Kelly Volkar are prosecuting \u001b[0m\n",
       "\u001b[39mthe case with the assistance of Madeline Wachs, Lakisha Holliman, Sara Slattery, Elise Etter, Susan Kreider, and \u001b[0m\n",
       "\u001b[39mLeeya Kekona. The prosecution is the result of an investigation by the FBI, USPIS, and the FDA Office of Criminal \u001b[0m\n",
       "\u001b[39mInvestigations.<\u001b[0m\u001b[35m/\u001b[0m\u001b[95mtext\u001b[0m\u001b[39m>\u001b[0m\n",
       "\u001b[39m    <\u001b[0m\u001b[35m/\u001b[0m\u001b[95msource\u001b[0m\u001b[39m>\u001b[0m\n",
       "\u001b[39m    \u001b[0m\n",
       "\u001b[39m    \u001b[0m\n",
       "\u001b[39m    <source>\u001b[0m\n",
       "\u001b[39m    <url>\u001b[0m\u001b[4;94mhttps://www.bbc.com/news/business-58336998\u001b[0m\u001b[39m<\u001b[0m\u001b[35m/\u001b[0m\u001b[95murl\u001b[0m\u001b[39m>\u001b[0m\n",
       "\u001b[39m    <title>Theranos scandal: Who is Elizabeth Holmes and why was she on trial?<\u001b[0m\u001b[35m/\u001b[0m\u001b[95mtitle\u001b[0m\u001b[39m>\u001b[0m\n",
       "\u001b[39m    <text>US Treasury Secretary George Schultz, media tycoon Rupert Murdoch and America's richest family, the \u001b[0m\n",
       "\u001b[39mWaltons, were among her backers.\u001b[0m\n",
       "\u001b[39m<\u001b[0m\u001b[35m/\u001b[0m\u001b[95mtext\u001b[0m\u001b[39m>\u001b[0m\n",
       "\u001b[39m    <\u001b[0m\u001b[35m/\u001b[0m\u001b[95msource\u001b[0m\u001b[39m>\u001b[0m\n",
       "\u001b[39m    \u001b[0m\n",
       "\u001b[39m    \u001b[0m\n",
       "\u001b[39m    <source>\u001b[0m\n",
       "\u001b[39m    <url>\u001b[0m\u001b[4;94mhttps://www.justice.gov/usao-ndca/pr/elizabeth-holmes-sentenced-more-11-years-defrauding-theranos-investor\u001b[0m\n",
       "\u001b[4;94ms-hundreds\u001b[0m\u001b[39m<\u001b[0m\u001b[35m/\u001b[0m\u001b[95murl\u001b[0m\u001b[39m>\u001b[0m\n",
       "\u001b[39m    <title>Northern District of California | Elizabeth Holmes Sentenced To More Than \u001b[0m\u001b[1;36m11\u001b[0m\u001b[39m Years For Defrauding \u001b[0m\n",
       "\u001b[39mTheranos Investors Of Hundreds Of Millions | United States Department of Justice<\u001b[0m\u001b[35m/\u001b[0m\u001b[95mtitle\u001b[0m\u001b[39m>\u001b[0m\n",
       "\u001b[39m    <text>The New York Times Style Magazine. Holmes dined at the White House, joined the Board of Fellows of \u001b[0m\n",
       "\u001b[39mHarvard Medical School, and was named by Time as one of the \u001b[0m\u001b[1;36m100\u001b[0m\u001b[39m Most Influential People in the World.<\u001b[0m\u001b[35m/\u001b[0m\u001b[95mtext\u001b[0m\u001b[39m>\u001b[0m\n",
       "\u001b[39m    <\u001b[0m\u001b[35m/\u001b[0m\u001b[95msource\u001b[0m\u001b[39m>\u001b[0m\n",
       "\u001b[39m    \u001b[0m\n",
       "\u001b[39m    \u001b[0m\n",
       "\u001b[39m    <source>\u001b[0m\n",
       "\u001b[39m    <url>\u001b[0m\u001b[4;94mhttps://www.npr.org/2023/05/30/1178728092/elizabeth-holmes-prison-sentence-theranos-fraud-silicon-valley\u001b[0m\u001b[39m<\u001b[0m\u001b[35m/\u001b[0m\n",
       "\u001b[95murl\u001b[0m\u001b[39m>\u001b[0m\n",
       "\u001b[39m    <title>Elizabeth Holmes has started her \u001b[0m\u001b[1;36m11\u001b[0m\u001b[39m-year prison sentence. Here's what to know<\u001b[0m\u001b[35m/\u001b[0m\u001b[95mtitle\u001b[0m\u001b[39m>\u001b[0m\n",
       "\u001b[39m    <text>Elizabeth Holmes has started her \u001b[0m\u001b[1;36m11\u001b[0m\u001b[39m-year prison sentence. Here's what to know\u001b[0m\n",
       "\u001b[39mDisgraced Silicon Valley superstar Elizabeth Holmes has surrendered to federal prison in Texas to begin serving a \u001b[0m\n",
       "\u001b[1;36m11\u001b[0m\u001b[39m-year term for defrauding investors with her once high-flying blood-testing company Theranos.\u001b[0m\n",
       "\u001b[39m Holmes, a \u001b[0m\u001b[1;36m39\u001b[0m\u001b[39m-year-old mother of two, reported Tuesday to the prison camp in Bryan, Texas, an all-female facility \u001b[0m\n",
       "\u001b[39mabout \u001b[0m\u001b[1;36m100\u001b[0m\u001b[39m miles outside of Houston, where some family members of Holmes reside.\u001b[0m\n",
       "\u001b[39m Lawyers for Holmes attempted to delay the start of her prison sentence by asking that she remain free while she \u001b[0m\n",
       "\u001b[39mappeals her conviction, but the 9th Circuit Court of Appeals denied her request, ruling that Holmes has not raised \u001b[0m\n",
       "\u001b[39ma \u001b[0m\u001b[32m\"substantial question\"\u001b[0m\u001b[39m of law or fact about her case.\u001b[0m\n",
       "\u001b[39m Here's what to know about the incarceration of Holmes, the most high-profile tech executive to be sentenced to \u001b[0m\n",
       "\u001b[39mprison time.\u001b[0m\n",
       "\u001b[39m<\u001b[0m\u001b[35m/\u001b[0m\u001b[95mtext\u001b[0m\u001b[39m>\u001b[0m\n",
       "\u001b[39m    <\u001b[0m\u001b[35m/\u001b[0m\u001b[95msource\u001b[0m\u001b[1m>\u001b[0m\n",
       "    \n",
       "    \n"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "# Initialize an empty string to store the formatted chunks\n",
    "formatted_chunks = \"\"\n",
    "\n",
    "# Iterate through the relevant chunks and format them\n",
    "for chunk, similarity in relevant_results:\n",
    "    formatted_chunk = f\"\"\"\n",
    "    <source>\n",
    "    <url>{chunk['metadata']['source']}</url>\n",
    "    <title>{chunk['metadata']['title']}</title>\n",
    "    <text>{chunk['text']}</text>\n",
    "    </source>\n",
    "    \n",
    "    \"\"\"\n",
    "    formatted_chunks += formatted_chunk\n",
    "\n",
    "# Print the formatted chunks string\n",
    "console.print(\"Formatted chunks:\")\n",
    "console.print(formatted_chunks)\n",
    "\n",
    "# Optionally, you can store this formatted_chunks string for further use\n",
    "\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 113,
   "metadata": {},
   "outputs": [],
   "source": [
    "prompt = wr.get_rag_prompt_template().format(query=query, context=formatted_chunks)  "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 114,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "application/vnd.jupyter.widget-view+json": {
       "model_id": "6960b578b16d43e286b6c98141b9cab8",
       "version_major": 2,
       "version_minor": 0
      },
      "text/plain": [
       "Output()"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/html": [
       "<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\"></pre>\n"
      ],
      "text/plain": []
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/html": [
       "<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\">โ•ญโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฎ\n",
       "โ”‚                                                                                                                 โ”‚\n",
       "โ”‚                                           <span style=\"font-weight: bold; text-decoration: underline\">Is Elizabeth Holmes Guilty?</span>                                           โ”‚\n",
       "โ”‚                                                                                                                 โ”‚\n",
       "โ”‚ Yes, Elizabeth Holmes was found guilty of defrauding investors in her blood-testing startup, Theranos. She was  โ”‚\n",
       "โ”‚ sentenced to 135 months (11 years and 3 months) in federal prison for her actions, which involved misleading    โ”‚\n",
       "โ”‚ investors about the capabilities and performance of Theranos' blood-testing technology. This sentence was       โ”‚\n",
       "โ”‚ handed down by U.S. District Judge Edward J. Davila and reflects the severity of the fraud, which involved      โ”‚\n",
       "โ”‚ hundreds of millions of dollars.                                                                                โ”‚\n",
       "โ”‚                                                                                                                 โ”‚\n",
       "โ”‚ Holmesโ€™ conviction serves as a significant legal precedent in the realm of corporate fraud, particularly in     โ”‚\n",
       "โ”‚ Silicon Valley, where the case has drawn considerable attention. The prosecution was a collaborative effort by  โ”‚\n",
       "โ”‚ the FBI, the U.S. Postal Inspection Service, and the FDA, emphasizing the seriousness with which such fraud is  โ”‚\n",
       "โ”‚ treated in the medical and corporate sectors.                                                                   โ”‚\n",
       "โ”‚                                                                                                                 โ”‚\n",
       "โ”‚                                                   <span style=\"font-weight: bold\">References</span>                                                    โ”‚\n",
       "โ”‚                                                                                                                 โ”‚\n",
       "โ”‚ <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> 1 </span><span style=\"font-weight: bold\">Northern District of California | Elizabeth Holmes Sentenced To More Than 11 Years For Defrauding Theranos </span>  โ”‚\n",
       "โ”‚ <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\">   </span><span style=\"font-weight: bold\">Investors Of Hundreds Of Millions</span>                                                                            โ”‚\n",
       "โ”‚ <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\">   </span>United States Department of Justice. <a href=\"https://www.justice.gov/usao-ndca/pr/elizabeth-holmes-sentenced-more-11-years-defrauding-theranos-investors-hundreds\" target=\"_blank\"><span style=\"color: #000080; text-decoration-color: #000080; text-decoration: underline\">Read more here</span></a>.                                                         โ”‚\n",
       "โ”‚ <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> 2 </span><span style=\"font-weight: bold\">Theranos founder Elizabeth Holmes sentenced to more than 11 years for defrauding investors</span>                   โ”‚\n",
       "โ”‚ <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\">   </span>The Guardian. <a href=\"https://www.theguardian.com/us-news/2022/nov/18/elizabeth-holmes-theranos-trial-sentencing\" target=\"_blank\"><span style=\"color: #000080; text-decoration-color: #000080; text-decoration: underline\">Read more here</span></a>.                                                                                โ”‚\n",
       "โ”‚ <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> 3 </span><span style=\"font-weight: bold\">Theranos founder Elizabeth Holmes sentenced to more than 11 years in prison</span>                                  โ”‚\n",
       "โ”‚ <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\">   </span>CNBC. <a href=\"https://www.cnbc.com/2022/11/18/former-theranos-ceo-elizabeth-holmes-sentenced-to-more-than-11-years-in-prison.html\" target=\"_blank\"><span style=\"color: #000080; text-decoration-color: #000080; text-decoration: underline\">Read more here</span></a>.                                                                                        โ”‚\n",
       "โ”‚ <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> 4 </span><span style=\"font-weight: bold\">Elizabeth Holmes has started her 11-year prison sentence. Here's what to know</span>                                โ”‚\n",
       "โ”‚ <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\">   </span>NPR. <a href=\"https://www.npr.org/2023/05/30/1178728092/elizabeth-holmes-prison-sentence-theranos-fraud-silicon-valley\" target=\"_blank\"><span style=\"color: #000080; text-decoration-color: #000080; text-decoration: underline\">Read more here</span></a>.                                                                                         โ”‚\n",
       "โ•ฐโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฏ\n",
       "</pre>\n"
      ],
      "text/plain": [
       "โ•ญโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฎ\n",
       "โ”‚                                                                                                                 โ”‚\n",
       "โ”‚                                           \u001b[1;4mIs Elizabeth Holmes Guilty?\u001b[0m                                           โ”‚\n",
       "โ”‚                                                                                                                 โ”‚\n",
       "โ”‚ Yes, Elizabeth Holmes was found guilty of defrauding investors in her blood-testing startup, Theranos. She was  โ”‚\n",
       "โ”‚ sentenced to 135 months (11 years and 3 months) in federal prison for her actions, which involved misleading    โ”‚\n",
       "โ”‚ investors about the capabilities and performance of Theranos' blood-testing technology. This sentence was       โ”‚\n",
       "โ”‚ handed down by U.S. District Judge Edward J. Davila and reflects the severity of the fraud, which involved      โ”‚\n",
       "โ”‚ hundreds of millions of dollars.                                                                                โ”‚\n",
       "โ”‚                                                                                                                 โ”‚\n",
       "โ”‚ Holmesโ€™ conviction serves as a significant legal precedent in the realm of corporate fraud, particularly in     โ”‚\n",
       "โ”‚ Silicon Valley, where the case has drawn considerable attention. The prosecution was a collaborative effort by  โ”‚\n",
       "โ”‚ the FBI, the U.S. Postal Inspection Service, and the FDA, emphasizing the seriousness with which such fraud is  โ”‚\n",
       "โ”‚ treated in the medical and corporate sectors.                                                                   โ”‚\n",
       "โ”‚                                                                                                                 โ”‚\n",
       "โ”‚                                                   \u001b[1mReferences\u001b[0m                                                    โ”‚\n",
       "โ”‚                                                                                                                 โ”‚\n",
       "โ”‚ \u001b[1;33m 1 \u001b[0m\u001b[1mNorthern District of California | Elizabeth Holmes Sentenced To More Than 11 Years For Defrauding Theranos \u001b[0m  โ”‚\n",
       "โ”‚ \u001b[1;33m   \u001b[0m\u001b[1mInvestors Of Hundreds Of Millions\u001b[0m                                                                            โ”‚\n",
       "โ”‚ \u001b[1;33m   \u001b[0mUnited States Department of Justice. \u001b]8;id=534523;https://www.justice.gov/usao-ndca/pr/elizabeth-holmes-sentenced-more-11-years-defrauding-theranos-investors-hundreds\u001b\\\u001b[4;34mRead more here\u001b[0m\u001b]8;;\u001b\\.                                                         โ”‚\n",
       "โ”‚ \u001b[1;33m 2 \u001b[0m\u001b[1mTheranos founder Elizabeth Holmes sentenced to more than 11 years for defrauding investors\u001b[0m                   โ”‚\n",
       "โ”‚ \u001b[1;33m   \u001b[0mThe Guardian. \u001b]8;id=993177;https://www.theguardian.com/us-news/2022/nov/18/elizabeth-holmes-theranos-trial-sentencing\u001b\\\u001b[4;34mRead more here\u001b[0m\u001b]8;;\u001b\\.                                                                                โ”‚\n",
       "โ”‚ \u001b[1;33m 3 \u001b[0m\u001b[1mTheranos founder Elizabeth Holmes sentenced to more than 11 years in prison\u001b[0m                                  โ”‚\n",
       "โ”‚ \u001b[1;33m   \u001b[0mCNBC. \u001b]8;id=246555;https://www.cnbc.com/2022/11/18/former-theranos-ceo-elizabeth-holmes-sentenced-to-more-than-11-years-in-prison.html\u001b\\\u001b[4;34mRead more here\u001b[0m\u001b]8;;\u001b\\.                                                                                        โ”‚\n",
       "โ”‚ \u001b[1;33m 4 \u001b[0m\u001b[1mElizabeth Holmes has started her 11-year prison sentence. Here's what to know\u001b[0m                                โ”‚\n",
       "โ”‚ \u001b[1;33m   \u001b[0mNPR. \u001b]8;id=513361;https://www.npr.org/2023/05/30/1178728092/elizabeth-holmes-prison-sentence-theranos-fraud-silicon-valley\u001b\\\u001b[4;34mRead more here\u001b[0m\u001b]8;;\u001b\\.                                                                                         โ”‚\n",
       "โ•ฐโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฏ\n"
      ]
     },
     "execution_count": 114,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "from rich.live import Live\n",
    "from rich.markdown import Markdown\n",
    "from rich.panel import Panel\n",
    "\n",
    "panel = Panel(\"AI response\")\n",
    "\n",
    "with Live(panel, auto_refresh=True) as live:\n",
    "    full_response = \"\"\n",
    "    for chunk in chat.stream(prompt):\n",
    "        full_response += chunk.content\n",
    "        panel.fit(Markdown(full_response))\n",
    "\n",
    "panel.fit(Markdown(full_response))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 59,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\">\n",
       "                                       <span style=\"font-weight: bold; text-decoration: underline\">Different Funding Stages of a Startup</span>                                       \n",
       "\n",
       "Startups typically progress through several distinct funding stages, each with its own characteristics, goals, and \n",
       "challenges. Understanding these stages is crucial for entrepreneurs seeking to navigate the startup landscape      \n",
       "effectively. Hereโ€™s an overview of the primary funding stages:                                                     \n",
       "\n",
       "                                                 <span style=\"font-weight: bold\">1. Pre-Seed Stage</span>                                                 \n",
       "\n",
       "The pre-seed stage is the earliest phase of funding. At this point, entrepreneurs often use their own resources to \n",
       "develop their ideas. The primary goal is to assemble a team and create a minimum viable product (MVP) to showcase  \n",
       "potential to attract further investment. This stage is crucial for validating the business concept and assessing   \n",
       "its viability.                                                                                                     \n",
       "\n",
       "                                                   <span style=\"font-weight: bold\">2. Seed Stage</span>                                                   \n",
       "\n",
       "Seed funding is the first official equity funding stage, where startups raise capital in exchange for equity       \n",
       "ownership. This funding typically ranges from a few thousand dollars to several million. The focus during this     \n",
       "stage is on product development and market research, as the startup aims to validate its business model and gather \n",
       "initial customer feedback. Approximately 29% of startups fail due to a lack of capital at this stage, highlighting \n",
       "its importance.                                                                                                    \n",
       "\n",
       "                                                 <span style=\"font-weight: bold\">3. Series A Stage</span>                                                 \n",
       "\n",
       "In the Series A stage, startups seek venture capital funding to scale their operations. By this time, they should  \n",
       "have a developed product and a consistent revenue stream. The typical amount raised in a Series A round ranges from\n",
       "$1 million to $15 million, with an average of around $13 million. The goal here is to optimize the product and     \n",
       "expand the customer base.                                                                                          \n",
       "\n",
       "                                                 <span style=\"font-weight: bold\">4. Series B Stage</span>                                                 \n",
       "\n",
       "Series B funding is for startups that have established a substantial user base and are looking to expand further.  \n",
       "This round often involves larger investments from venture capitalists who want to play a more significant role in  \n",
       "the company's strategy. The funds are typically used to scale operations and increase market reach.                \n",
       "\n",
       "                                              <span style=\"font-weight: bold\">5. Series C and Beyond</span>                                               \n",
       "\n",
       "Startups that have met their goals in previous stages may seek Series C funding or further rounds (Series D, etc.) \n",
       "to continue expanding or to prepare for an Initial Public Offering (IPO). This stage allows startups to solidify   \n",
       "their market position and reach additional growth milestones.                                                      \n",
       "\n",
       "                                         <span style=\"font-weight: bold\">6. IPO (Initial Public Offering)</span>                                          \n",
       "\n",
       "An IPO is the process through which a startup offers its shares to the public for the first time. This stage is    \n",
       "critical for providing liquidity for investors and raising significant capital to fuel further growth. The         \n",
       "valuation at this stage is crucial, as it determines the stock price and overall market perception of the startup. \n",
       "\n",
       "Each of these stages presents unique challenges and opportunities, and the successful navigation through them is   \n",
       "essential for the growth and sustainability of a startup.                                                          \n",
       "\n",
       "\n",
       "                                                    <span style=\"font-weight: bold; text-decoration: underline\">References</span>                                                     \n",
       "\n",
       "<span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> โ€ข </span><a href=\"https://stripe.com/resources/more/what-are-the-stages-of-a-startup\" target=\"_blank\"><span style=\"color: #000080; text-decoration-color: #000080; text-decoration: underline\">What are the startup funding stages? | Stripe</span></a>                                                                   \n",
       "<span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> โ€ข </span><a href=\"https://www.startups.com/library/expert-advice/different-stages-of-funding-for-startups\" target=\"_blank\"><span style=\"color: #000080; text-decoration-color: #000080; text-decoration: underline\">A Guide to Different Stages of Funding for Startups</span></a>                                                             \n",
       "</pre>\n"
      ],
      "text/plain": [
       "\n",
       "                                       \u001b[1;4mDifferent Funding Stages of a Startup\u001b[0m                                       \n",
       "\n",
       "Startups typically progress through several distinct funding stages, each with its own characteristics, goals, and \n",
       "challenges. Understanding these stages is crucial for entrepreneurs seeking to navigate the startup landscape      \n",
       "effectively. Hereโ€™s an overview of the primary funding stages:                                                     \n",
       "\n",
       "                                                 \u001b[1m1. Pre-Seed Stage\u001b[0m                                                 \n",
       "\n",
       "The pre-seed stage is the earliest phase of funding. At this point, entrepreneurs often use their own resources to \n",
       "develop their ideas. The primary goal is to assemble a team and create a minimum viable product (MVP) to showcase  \n",
       "potential to attract further investment. This stage is crucial for validating the business concept and assessing   \n",
       "its viability.                                                                                                     \n",
       "\n",
       "                                                   \u001b[1m2. Seed Stage\u001b[0m                                                   \n",
       "\n",
       "Seed funding is the first official equity funding stage, where startups raise capital in exchange for equity       \n",
       "ownership. This funding typically ranges from a few thousand dollars to several million. The focus during this     \n",
       "stage is on product development and market research, as the startup aims to validate its business model and gather \n",
       "initial customer feedback. Approximately 29% of startups fail due to a lack of capital at this stage, highlighting \n",
       "its importance.                                                                                                    \n",
       "\n",
       "                                                 \u001b[1m3. Series A Stage\u001b[0m                                                 \n",
       "\n",
       "In the Series A stage, startups seek venture capital funding to scale their operations. By this time, they should  \n",
       "have a developed product and a consistent revenue stream. The typical amount raised in a Series A round ranges from\n",
       "$1 million to $15 million, with an average of around $13 million. The goal here is to optimize the product and     \n",
       "expand the customer base.                                                                                          \n",
       "\n",
       "                                                 \u001b[1m4. Series B Stage\u001b[0m                                                 \n",
       "\n",
       "Series B funding is for startups that have established a substantial user base and are looking to expand further.  \n",
       "This round often involves larger investments from venture capitalists who want to play a more significant role in  \n",
       "the company's strategy. The funds are typically used to scale operations and increase market reach.                \n",
       "\n",
       "                                              \u001b[1m5. Series C and Beyond\u001b[0m                                               \n",
       "\n",
       "Startups that have met their goals in previous stages may seek Series C funding or further rounds (Series D, etc.) \n",
       "to continue expanding or to prepare for an Initial Public Offering (IPO). This stage allows startups to solidify   \n",
       "their market position and reach additional growth milestones.                                                      \n",
       "\n",
       "                                         \u001b[1m6. IPO (Initial Public Offering)\u001b[0m                                          \n",
       "\n",
       "An IPO is the process through which a startup offers its shares to the public for the first time. This stage is    \n",
       "critical for providing liquidity for investors and raising significant capital to fuel further growth. The         \n",
       "valuation at this stage is crucial, as it determines the stock price and overall market perception of the startup. \n",
       "\n",
       "Each of these stages presents unique challenges and opportunities, and the successful navigation through them is   \n",
       "essential for the growth and sustainability of a startup.                                                          \n",
       "\n",
       "\n",
       "                                                    \u001b[1;4mReferences\u001b[0m                                                     \n",
       "\n",
       "\u001b[1;33m โ€ข \u001b[0m\u001b]8;id=999288;https://stripe.com/resources/more/what-are-the-stages-of-a-startup\u001b\\\u001b[4;34mWhat are the startup funding stages? | Stripe\u001b[0m\u001b]8;;\u001b\\                                                                   \n",
       "\u001b[1;33m โ€ข \u001b[0m\u001b]8;id=935378;https://www.startups.com/library/expert-advice/different-stages-of-funding-for-startups\u001b\\\u001b[4;34mA Guide to Different Stages of Funding for Startups\u001b[0m\u001b]8;;\u001b\\                                                             \n"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "full_response = chat.invoke(prompt).content\n",
    "console.print(Markdown(full_response))"
   ]
  }
 ],
 "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.12.6"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}