File size: 67,703 Bytes
e62e0c5
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "a5c7b436",
   "metadata": {},
   "source": [
    "# Analysis of Retrieval Results"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "6082ebb6",
   "metadata": {},
   "source": [
    "## Load annotations and retrieval results"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "fefb786d",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>UUID</th>\n",
       "      <th>FILE</th>\n",
       "      <th>QUOTE_TRANSCRIPTION</th>\n",
       "      <th>ANCHOR</th>\n",
       "      <th>COMMENTS</th>\n",
       "      <th>TAGS</th>\n",
       "      <th>PAGE</th>\n",
       "      <th>TRANSCRIPTION_CLEANED</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>551</th>\n",
       "      <td>2faf6dce-7806-48b6-8e8b-2bf926fc88fc</td>\n",
       "      <td>Z166069305_merged.txt</td>\n",
       "      <td>Negypten aber hat nicht allein Wunder der Kunſ...</td>\n",
       "      <td>char-offset:2567</td>\n",
       "      <td>p. 8</td>\n",
       "      <td>'plants vegetation 25G'</td>\n",
       "      <td>8</td>\n",
       "      <td>('n? Negypten aber hat nicht allein Wunder der...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>552</th>\n",
       "      <td>2e026f81-cbe7-43ba-9b37-5f5bd2760119</td>\n",
       "      <td>Z166069305_merged.txt</td>\n",
       "      <td>Barbaren bewohnen jezt das Land und Räuber beh...</td>\n",
       "      <td>char-offset:3391</td>\n",
       "      <td>p. 8</td>\n",
       "      <td>'plants vegetation 25G'</td>\n",
       "      <td>8</td>\n",
       "      <td>('r. Barbaren bewohnen jezt das Land und Raube...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>553</th>\n",
       "      <td>0d5708db-1bf6-4de4-ad64-9759ebb4fa3c</td>\n",
       "      <td>Z166069305_merged.txt</td>\n",
       "      <td>Die Waffen eines Mamefu den zu Pferde find zwe...</td>\n",
       "      <td>char-offset:5538</td>\n",
       "      <td>p. 9-10\\n</td>\n",
       "      <td>'animals 25F', 'horses and kindred animals 46C...</td>\n",
       "      <td>10</td>\n",
       "      <td>('n. Die Waffen eines Mamefu den zu Pferde fin...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>554</th>\n",
       "      <td>64b5828e-b14d-49dc-8d88-f97de52f9202</td>\n",
       "      <td>Z166069305_merged.txt</td>\n",
       "      <td>Den Zaum reines Pferdes nimmt er zwiſchen die ...</td>\n",
       "      <td>char-offset:5987</td>\n",
       "      <td>p. 10\\n</td>\n",
       "      <td>'animals 25F', 'horses and kindred animals 46C...</td>\n",
       "      <td>10</td>\n",
       "      <td>('l. Den Zaum reines Pferdes nimmt er zwischen...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>555</th>\n",
       "      <td>fa2e8b0d-d8aa-46c8-ac97-1a8e2b14600d</td>\n",
       "      <td>Z166069305_merged.txt</td>\n",
       "      <td>Seine Häuſer ſind arms felige Kothhütten, und ...</td>\n",
       "      <td>char-offset:8769</td>\n",
       "      <td>p. 11-12</td>\n",
       "      <td>'plants vegetation 25G'</td>\n",
       "      <td>12</td>\n",
       "      <td>(' Hauser sind arms felige Kothhutten, und fei...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1117</th>\n",
       "      <td>3d4a21ad-ddd8-4d3a-b018-d7dbb9f186dc</td>\n",
       "      <td>Z166069305_merged.txt</td>\n",
       "      <td>Bittt adit2: 001), ont ma Des Abends begaben ſ...</td>\n",
       "      <td>char-offset:821475</td>\n",
       "      <td>NaN</td>\n",
       "      <td>'animals 25F', 'birds 25F3'</td>\n",
       "      <td>504</td>\n",
       "      <td>(\"00 Bittt adit2: 001), ont ma Des Abends bega...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1118</th>\n",
       "      <td>2aefbba4-e796-4add-bdb1-0768afe0a3ce</td>\n",
       "      <td>Z166069305_merged.txt</td>\n",
       "      <td>57 3 Chazelle lieb Chazelles</td>\n",
       "      <td>char-offset:823734</td>\n",
       "      <td>NaN</td>\n",
       "      <td>'animals 25F', 'hoofed animalGAZELLE 25F24'</td>\n",
       "      <td>504</td>\n",
       "      <td>('ue 57 3 Chazelle lieb Chazelles 65', 814073)</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1119</th>\n",
       "      <td>f50b57c6-d751-4d41-8670-8b5254d964ec</td>\n",
       "      <td>Z166069305_merged.txt</td>\n",
       "      <td>Ein' to svil, dulu UPUN Fahn irlichin( jiyi vo...</td>\n",
       "      <td>char-offset:824751</td>\n",
       "      <td>NaN</td>\n",
       "      <td>'animals 25F'</td>\n",
       "      <td>504</td>\n",
       "      <td>(\"c. Ein' to suil, dulu UPUN Fahn irlichin( ji...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1120</th>\n",
       "      <td>d8cfcc30-5f00-4681-826b-c5c7a87e768b</td>\n",
       "      <td>Z166069305_merged.txt</td>\n",
       "      <td>Dez HENNÈI, Blüthen. Eine Blüthe ron natiiitic...</td>\n",
       "      <td>char-offset:824901</td>\n",
       "      <td>NaN</td>\n",
       "      <td>'plants vegetation 25G'</td>\n",
       "      <td>504</td>\n",
       "      <td>('-- Dez HENNEI, Bluthen. Eine Bluthe ron nati...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1121</th>\n",
       "      <td>bbf95b5f-40d1-476a-a392-2dabb1278c16</td>\n",
       "      <td>Z166069305_merged.txt</td>\n",
       "      <td>Riedel fee. Fig. 1, ATLÉ, A, Stamn.2.7weig. Fi...</td>\n",
       "      <td>char-offset:825427</td>\n",
       "      <td>NaN</td>\n",
       "      <td>'plants vegetation 25G'</td>\n",
       "      <td>504</td>\n",
       "      <td>(\" 1 Riedel fee. Fig. 1, ATLE, A, Stamn.2.7wei...</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>571 rows × 8 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "                                      UUID                   FILE  \\\n",
       "551   2faf6dce-7806-48b6-8e8b-2bf926fc88fc  Z166069305_merged.txt   \n",
       "552   2e026f81-cbe7-43ba-9b37-5f5bd2760119  Z166069305_merged.txt   \n",
       "553   0d5708db-1bf6-4de4-ad64-9759ebb4fa3c  Z166069305_merged.txt   \n",
       "554   64b5828e-b14d-49dc-8d88-f97de52f9202  Z166069305_merged.txt   \n",
       "555   fa2e8b0d-d8aa-46c8-ac97-1a8e2b14600d  Z166069305_merged.txt   \n",
       "...                                    ...                    ...   \n",
       "1117  3d4a21ad-ddd8-4d3a-b018-d7dbb9f186dc  Z166069305_merged.txt   \n",
       "1118  2aefbba4-e796-4add-bdb1-0768afe0a3ce  Z166069305_merged.txt   \n",
       "1119  f50b57c6-d751-4d41-8670-8b5254d964ec  Z166069305_merged.txt   \n",
       "1120  d8cfcc30-5f00-4681-826b-c5c7a87e768b  Z166069305_merged.txt   \n",
       "1121  bbf95b5f-40d1-476a-a392-2dabb1278c16  Z166069305_merged.txt   \n",
       "\n",
       "                                    QUOTE_TRANSCRIPTION              ANCHOR  \\\n",
       "551   Negypten aber hat nicht allein Wunder der Kunſ...    char-offset:2567   \n",
       "552   Barbaren bewohnen jezt das Land und Räuber beh...    char-offset:3391   \n",
       "553   Die Waffen eines Mamefu den zu Pferde find zwe...    char-offset:5538   \n",
       "554   Den Zaum reines Pferdes nimmt er zwiſchen die ...    char-offset:5987   \n",
       "555   Seine Häuſer ſind arms felige Kothhütten, und ...    char-offset:8769   \n",
       "...                                                 ...                 ...   \n",
       "1117  Bittt adit2: 001), ont ma Des Abends begaben ſ...  char-offset:821475   \n",
       "1118                       57 3 Chazelle lieb Chazelles  char-offset:823734   \n",
       "1119  Ein' to svil, dulu UPUN Fahn irlichin( jiyi vo...  char-offset:824751   \n",
       "1120  Dez HENNÈI, Blüthen. Eine Blüthe ron natiiitic...  char-offset:824901   \n",
       "1121  Riedel fee. Fig. 1, ATLÉ, A, Stamn.2.7weig. Fi...  char-offset:825427   \n",
       "\n",
       "       COMMENTS                                               TAGS  PAGE  \\\n",
       "551        p. 8                            'plants vegetation 25G'     8   \n",
       "552        p. 8                            'plants vegetation 25G'     8   \n",
       "553   p. 9-10\\n  'animals 25F', 'horses and kindred animals 46C...    10   \n",
       "554     p. 10\\n  'animals 25F', 'horses and kindred animals 46C...    10   \n",
       "555    p. 11-12                            'plants vegetation 25G'    12   \n",
       "...         ...                                                ...   ...   \n",
       "1117        NaN                        'animals 25F', 'birds 25F3'   504   \n",
       "1118        NaN        'animals 25F', 'hoofed animalGAZELLE 25F24'   504   \n",
       "1119        NaN                                      'animals 25F'   504   \n",
       "1120        NaN                            'plants vegetation 25G'   504   \n",
       "1121        NaN                            'plants vegetation 25G'   504   \n",
       "\n",
       "                                  TRANSCRIPTION_CLEANED  \n",
       "551   ('n? Negypten aber hat nicht allein Wunder der...  \n",
       "552   ('r. Barbaren bewohnen jezt das Land und Raube...  \n",
       "553   ('n. Die Waffen eines Mamefu den zu Pferde fin...  \n",
       "554   ('l. Den Zaum reines Pferdes nimmt er zwischen...  \n",
       "555   (' Hauser sind arms felige Kothhutten, und fei...  \n",
       "...                                                 ...  \n",
       "1117  (\"00 Bittt adit2: 001), ont ma Des Abends bega...  \n",
       "1118     ('ue 57 3 Chazelle lieb Chazelles 65', 814073)  \n",
       "1119  (\"c. Ein' to suil, dulu UPUN Fahn irlichin( ji...  \n",
       "1120  ('-- Dez HENNEI, Bluthen. Eine Bluthe ron nati...  \n",
       "1121  (\" 1 Riedel fee. Fig. 1, ATLE, A, Stamn.2.7wei...  \n",
       "\n",
       "[571 rows x 8 columns]"
      ]
     },
     "execution_count": 1,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "import pandas as pd\n",
    "import os\n",
    "import re\n",
    "\n",
    "text_annotations_path = \"data/annotations/\"\n",
    "filename = 'DHd2025_referenceReports_merged-cleaned__annotations.xlsx'\n",
    "\n",
    "annotations = pd.read_excel(os.path.join(text_annotations_path, filename))\n",
    "\n",
    "## Remove unwanted tags from list\n",
    "unwanted_strings = ['pages', 'subheading', 'footnote', 'table of contents', 'footnote irrelevant', 'title', 'scan mistake', 'dictionary']\n",
    "\n",
    "# Remove rows where 'TAGS' contains any unwanted string\n",
    "annotations = annotations[~annotations['TAGS'].str.contains('|'.join(unwanted_strings), case=False, na=False)].reset_index(drop=True)\n",
    "annotations = annotations[annotations['FILE'].str.contains('Z166069305', case=False, na=False)]\n",
    "\n",
    "annotations"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "c6bff210",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Number of excluded sentences: 0\n",
      "Number of annotated mentions: 48\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "{'id': '0d5708db-1bf6-4de4-ad64-9759ebb4fa3c',\n",
       " 'annotated_text': \"('n. Die Waffen eines Mamefu den zu Pferde find zwei --- 00010_page10_cleaned.txt --- grose Flinten, die ihm seine Diener zur Seite nach: tragen und die er ein einziges mal losschiest. Da', 5402)\",\n",
       " 'comment': 'p. 9-10\\n',\n",
       " 'page': 10,\n",
       " 'file': 'Z166069305_merged.txt'}"
      ]
     },
     "execution_count": 2,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "## Filter the DataFrame\n",
    "filtered_df = annotations[annotations['TAGS'].str.contains('horse', na=False)]\n",
    "# Count the number of rows before filtering short sentences\n",
    "before_filter_count = len(filtered_df)\n",
    "\n",
    "# Filter sentences that are 5 words or longer in 'QUOTE_TRANSCRIPTION'\n",
    "filtered_df = filtered_df[filtered_df['TRANSCRIPTION_CLEANED'].apply(lambda x: len(x.split()) >= 5)]\n",
    "# Count the number of rows after filtering short sentences\n",
    "after_filter_count = len(filtered_df)\n",
    "excluded_count = before_filter_count - after_filter_count\n",
    "print(f\"Number of excluded sentences: {excluded_count}\")\n",
    "\n",
    "mentions_dict = filtered_df.set_index('UUID').to_dict(orient='index')\n",
    "\n",
    "mentions = [{\"id\": key, \"annotated_text\": v['TRANSCRIPTION_CLEANED'], \"comment\": v['COMMENTS'], \"page\": v['PAGE'], \"file\": v['FILE']} for key, v in mentions_dict.items()]\n",
    "\n",
    "print(f\"Number of annotated mentions: {len(filtered_df)}\")\n",
    "mentions[0]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "cc29b140",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Total annotations: 48\n",
      "On total pages: 40\n"
     ]
    }
   ],
   "source": [
    "## Summary of annotations\n",
    "\n",
    "# Total annotations:\n",
    "# Remove duplicates based on \"page\"\n",
    "unique_annot = {entry[\"id\"]: entry for entry in mentions}.values()\n",
    "\n",
    "# Remove duplicates based on \"page\"\n",
    "unique_pages_annot = {entry[\"page\"]: entry for entry in mentions}.values()\n",
    "\n",
    "# Extract the \"page\" value from each dictionary of unique pages found\n",
    "unique_pages_list = [item['page'] for item in unique_pages_annot]\n",
    "\n",
    "print(f'Total annotations: {len(unique_annot)}')\n",
    "print(f'On total pages: {len(unique_pages_annot)}')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "bd863c3b",
   "metadata": {},
   "outputs": [],
   "source": [
    "## Load retrieval results with Marqo DHd2025\n",
    "\n",
    "## Pferd, Pferde\n",
    "retr_orig = pd.read_csv('data/retrieval_results/sonnini_original_OCR/i_onit-test-index-sonnini-q_Pferd-Pferde.csv')\n",
    "retr_prep = pd.read_csv('data/retrieval_results/sonnini_llm_corrected/i_onit-sonnini-DHd2025-prep-q_Pferd, Pferde.csv')\n",
    "retr_clean = pd.read_csv('data/retrieval_results/sonnini_cleaned/i_onit-sonnini-DHd2025-clean-q_Pferd, Pferde.csv')"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "6b4a54bd",
   "metadata": {},
   "source": [
    "## Evaluation of results"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "id": "296250aa",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "200\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "{'id': '01b71d37-9ead-4eb2-8504-d16cbd00e866',\n",
       " 'text_document': 'befand mich in einiger Entfernung davon, und der Ueber- rest unserer Begleitung folgte in ziemlicher Weite nach. Ein Trupp Beduinen zu Pferde. brach auf einmal hinter den Mauern hervor. Ich konnte sie an. fanglich unter den Staubwolken, die sie erregten, nicht unterscheiden: als fie fich aber ausgebreitet hatten, erfannte ich sowohl die Ort als die Anzahl von Leuten, mit denen wir zu thun haben sollten. Ich wandte sogleich inein Pferd um, und mit diefem vortreflichen Reuter, auf welchem man mich nicht hatte einbohlen konnen, hatte ich bald meine Gefahrten erreicht, die auch von ihren Came len herab diese. Reuterei gewahr worden waren. Ich fand sie zu Fus und in geschlossene Glieder gestellt. Ich sturzte mich von meinem Pferde herab und munterte fie zu einenu muthigen Widerstande auf. Wir waren im Ganzen rechs Personen, unter welchen wir nur auf drei | rechnen konnten. Zwei Eingebohrne fonnten nicht viel helfen, und der Zeichner war noch jung und ohne Erfah- rung, und konnte keine Flinte losschiesen. ut Die Standhaftigkeit einer Handvou Menschen, die fich mitten in einer Sandflache allein befanden, und die von keiner Seite gedekt waren, liberraschte eine Schwa: dron von ungefahr hundert Beduinen: man kann daraus schliesen, wie wenig furchtbar solche Feinde find, deren Muth fich blos darauf beschrankt, das fie fich in zahlreichen Horden versammeln, um eine leichte Plundes rung zu veruben, und auf eine feige Art den kleinen Krieg zu fuhren. Ob fie gleich in starkem Galop auf uns zuge. ritten kamen, so machten sie doch plozlich, etwann hundert Schritte von uns, halt. Sie riefen uns zu, kein Feuer zu geben, und ich erwiederte ihnen, fie sollten nicht vors rucken. Sie blieben einige Augenblicke in einer Art von Ungewisheit, was sie thun souten, wahrend welcher wir fie unter einander berathschlagen sahen. Sie theilten sich',\n",
       " 'text_vector': 'befand mich in einiger Entfernung davon, und der Ueber- rest unserer Begleitung folgte in ziemlicher Weite nach. Ein Trupp Beduinen zu Pferde.',\n",
       " 'page': 430,\n",
       " 'rerank': 1,\n",
       " 'barcode': 'Z166069305',\n",
       " 'onb_link': 'https://digital.onb.ac.at/OnbViewer/viewer.faces?doc=ABO_%2BZ166069305'}"
      ]
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "## Analyse overlap of retrieved texts with annotated texts\n",
    "\n",
    "\"\"\"\n",
    "In this notebook, we attempted to compare the heterogeneous texts that were annotated during the project\n",
    "with the retrieval results by comparing n-word phrases from the annotated sentences with the retrieved\n",
    "sentence vectors. This approach is experimental. An alternative evaluation by calculating the Levenshtein\n",
    "distance between the annotated text vectors and the retrieved text vectors will be done in future.\n",
    "\"\"\"\n",
    "\n",
    "## Create dict from retrieved texts\n",
    "#retr = retr_orig.head(200)\n",
    "#retr = retr_prep.head(200)\n",
    "retr = retr_clean.head(200)\n",
    "\n",
    "retrieved_dict = retr.set_index('_id').to_dict(orient='index')\n",
    "\n",
    "retrieved = [\n",
    "    {\n",
    "        \"id\": key,\n",
    "        \"text_document\": v['text_clean'], # 'text', 'text_clean'\n",
    "        \"text_vector\": v['unpacked_highlights'] if pd.notna(v['unpacked_highlights']) else v['text'],\n",
    "        \"page\": v['page'], #int((re.search(r'\\d+', v['page'])).group()),\n",
    "        \"rerank\": v['rerank'],\n",
    "        \"barcode\": v['barcode'],\n",
    "        \"onb_link\": v['onb_viewer_link']\n",
    "    }\n",
    "    for key, v in retrieved_dict.items()\n",
    "]\n",
    "\n",
    "print(len(retrieved))\n",
    "retrieved[0]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "id": "307ab5c6",
   "metadata": {
    "code_folding": []
   },
   "outputs": [],
   "source": [
    "## Function to generate n-word phrases from a sentence\n",
    "def generate_n_word_phrases(sentence, n):\n",
    "    words = sentence.lower().split()\n",
    "    return [' '.join(words[i:i+n]) for i in range(len(words) - n + 1)]\n",
    "\n",
    "## Function to check if any of the n-word phrases is in the text_vector\n",
    "## and store the first matching phrase\n",
    "def check_sentence_in_text_vector(sentence, text_vector, n):\n",
    "    text_vector_lower = text_vector.lower()\n",
    "    phrases = generate_n_word_phrases(sentence, n)\n",
    "    for phrase in phrases:\n",
    "        if phrase in text_vector_lower:\n",
    "            return True, phrase  # Return True and the matching phrase\n",
    "    return False, None  # No match found, return None\n",
    "    #return any(phrase in text_vector_lower for phrase in phrases)\n",
    "\n",
    "# Number of words in the phrase to check\n",
    "n = 5  # Change this to the desired number of words\n",
    "\n",
    "# List to store results\n",
    "results = []\n",
    "\n",
    "# Iterate through each sentence in the mentions list\n",
    "for sentence in mentions:\n",
    "    found = False\n",
    "    # Check if any n-word phrase from this sentence is present in any of the text_vector fields\n",
    "    for entry in retrieved:\n",
    "        #print(entry['text_vector'])\n",
    "        match_found, match = check_sentence_in_text_vector(sentence['annotated_text'], entry['text_vector'], n)\n",
    "        if match_found == True:\n",
    "            found = True\n",
    "            break  # No need to check further if a match is found\n",
    "    if found == True:\n",
    "        results.append({\n",
    "            \"sentence_annotation\": sentence['annotated_text'],\n",
    "            \"id_annotation\": sentence['id'],\n",
    "            \"page_annotation\": sentence['page'],\n",
    "            \"comment\": sentence['comment'],\n",
    "            \"found_in_text_vector\": found,\n",
    "            \"text_vector\": entry['text_vector'],\n",
    "            \"matching_phrase\": match,\n",
    "            \"id_text_vector\": entry['id'],\n",
    "            \"barcode\": entry['barcode'],\n",
    "            \"page_text\": entry['page'],\n",
    "            \"onb_link\": entry['onb_link'],\n",
    "            \"file_annotation\": sentence['file']\n",
    "            })\n",
    "    else:\n",
    "        results.append({\n",
    "            \"sentence_annotation\": sentence['annotated_text'],\n",
    "            \"id_annotation\": sentence['id'],\n",
    "            \"page_annotation\": sentence['page'],\n",
    "            \"file_annotation\": sentence['file'],\n",
    "            \"found_in_text_vector\": found\n",
    "            })\n",
    "\n",
    "retrieved_df = pd.DataFrame(retrieved)\n",
    "retrieved_df.rename(columns={'id': 'id_text_vector'}, inplace=True)\n",
    "mat_df = pd.DataFrame(results)\n",
    "matches_df = retrieved_df.merge(mat_df, on='id_text_vector', how='outer')\n",
    "\n",
    "# Sort the DataFrame based on the 'rrf_rank' column in ascending order\n",
    "matches_df = matches_df.sort_values(by='rerank', ascending=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "id": "68868787",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "True Positives: Found 27 relevant mentions on 27 pages of 48 relevant mentions on 40 pages\n",
      "(67.50%).\n",
      "Found average of 1.00 found mentions per page vs. GT of 1.20 annotations per page.\n"
     ]
    },
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>sentence_annotation</th>\n",
       "      <th>text_vector_x</th>\n",
       "      <th>rerank</th>\n",
       "      <th>id_annotation</th>\n",
       "      <th>page</th>\n",
       "      <th>page_annotation</th>\n",
       "      <th>file_annotation</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>('h. Ein Trupp Beduinen zu Pferde. brach auf e...</td>\n",
       "      <td>befand mich in einiger Entfernung davon, und d...</td>\n",
       "      <td>1.0</td>\n",
       "      <td>ffbabe61-0a21-4e4f-b6e4-2ddc4724b40c</td>\n",
       "      <td>430.0</td>\n",
       "      <td>434.0</td>\n",
       "      <td>Z166069305_merged.txt</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>('n. Man muntert beide auch mit einem Klatsche...</td>\n",
       "      <td>Man muntert beide auch mit einem Klatschen der...</td>\n",
       "      <td>2.0</td>\n",
       "      <td>9a41db07-a5c8-4b3f-931a-43418f800768</td>\n",
       "      <td>399.0</td>\n",
       "      <td>403.0</td>\n",
       "      <td>Z166069305_merged.txt</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>('t. Ein kriegerisches und eroberungssuchtiges...</td>\n",
       "      <td>Eine weife Nation hingegen, die den Ackerbau f...</td>\n",
       "      <td>3.0</td>\n",
       "      <td>2caacee3-c22d-4a76-a2d7-ba794856a103</td>\n",
       "      <td>175.0</td>\n",
       "      <td>176.0</td>\n",
       "      <td>Z166069305_merged.txt</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>('n. Die Waffen eines Mamefu den zu Pferde fin...</td>\n",
       "      <td>Die Waffen eines Mamefu den zu Pferde find zwei</td>\n",
       "      <td>4.0</td>\n",
       "      <td>0d5708db-1bf6-4de4-ad64-9759ebb4fa3c</td>\n",
       "      <td>9.0</td>\n",
       "      <td>10.0</td>\n",
       "      <td>Z166069305_merged.txt</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>('r. Das heise Clima dieser Gegenden des Alter...</td>\n",
       "      <td>Das Pferd, das eben fo feurig ist als die Luft...</td>\n",
       "      <td>5.0</td>\n",
       "      <td>4f7c0172-b25f-4e62-9cb5-a1c1213c6d7d</td>\n",
       "      <td>220.0</td>\n",
       "      <td>222.0</td>\n",
       "      <td>Z166069305_merged.txt</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>(\"n. Diese Banditen waren nicht damit zufriede...</td>\n",
       "      <td>Andere Uraber erwiesen meinen Gefahrten diesel...</td>\n",
       "      <td>6.0</td>\n",
       "      <td>c86544f5-33f0-4d9a-b048-4995ae36c493</td>\n",
       "      <td>435.0</td>\n",
       "      <td>439.0</td>\n",
       "      <td>Z166069305_merged.txt</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>('s. ?. Wir fahen zwei Beduinen zu Pferde; fie...</td>\n",
       "      <td>?. Wir fahen zwei Beduinen zu Pferde; fie floh...</td>\n",
       "      <td>7.0</td>\n",
       "      <td>3a1cf968-2b82-48d9-a784-d3a7f5198890</td>\n",
       "      <td>413.0</td>\n",
       "      <td>417.0</td>\n",
       "      <td>Z166069305_merged.txt</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7</th>\n",
       "      <td>(\"b. Der Hraber muste mir fur den taglichen Pr...</td>\n",
       "      <td>Der Hraber muste mir fur den taglichen Preis v...</td>\n",
       "      <td>8.0</td>\n",
       "      <td>b0450149-d074-4079-87c4-cdc252ce7c67</td>\n",
       "      <td>383.0</td>\n",
       "      <td>387.0</td>\n",
       "      <td>Z166069305_merged.txt</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8</th>\n",
       "      <td>('r. Ich war mit meinem Pferde uorausgeritten,...</td>\n",
       "      <td>Ich war mit meinem Pferde vorausgeritten, und ...</td>\n",
       "      <td>9.0</td>\n",
       "      <td>a16c02e9-16a6-4780-b65e-51510b8db6fb</td>\n",
       "      <td>406.0</td>\n",
       "      <td>410.0</td>\n",
       "      <td>Z166069305_merged.txt</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9</th>\n",
       "      <td>('-- Das Lager stand etwan einige hundert Fus ...</td>\n",
       "      <td>Man bauete verschiedente Arten Viehfutter dara...</td>\n",
       "      <td>10.0</td>\n",
       "      <td>b8a8f0ea-926e-4d89-b21d-e89e69a35c2f</td>\n",
       "      <td>394.0</td>\n",
       "      <td>397.0</td>\n",
       "      <td>Z166069305_merged.txt</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>10</th>\n",
       "      <td>(\"n. Ich bemerkte oft frische Spuren uon Strau...</td>\n",
       "      <td>Ihre Jagd ist eine von den Leibesubuns gen, wo...</td>\n",
       "      <td>11.0</td>\n",
       "      <td>2703eecd-2bb6-432b-beaf-c92933736058</td>\n",
       "      <td>424.0</td>\n",
       "      <td>428.0</td>\n",
       "      <td>Z166069305_merged.txt</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>11</th>\n",
       "      <td>('b. Ich bestieg ein sehr schones Pferd, und i...</td>\n",
       "      <td>Ich bestieg ein sehr schones Pferd, und ich wu...</td>\n",
       "      <td>12.0</td>\n",
       "      <td>3f08cff7-7220-4c5e-9d1f-1b8d4fc92028</td>\n",
       "      <td>405.0</td>\n",
       "      <td>409.0</td>\n",
       "      <td>Z166069305_merged.txt</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>12</th>\n",
       "      <td>('n. Sie halten sich mit ihren trefa lich klei...</td>\n",
       "      <td>Sie halten sich mit ihren trefa lich kleinen P...</td>\n",
       "      <td>13.0</td>\n",
       "      <td>28370a93-4521-48d0-a8da-50545822debc</td>\n",
       "      <td>12.0</td>\n",
       "      <td>12.0</td>\n",
       "      <td>Z166069305_merged.txt</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>13</th>\n",
       "      <td>('n. Es war eine sehr gunstige Gelegenheit: di...</td>\n",
       "      <td>mittel herum, die man ihnen gereicht hatte: ih...</td>\n",
       "      <td>14.0</td>\n",
       "      <td>d9613671-efc9-4a0e-9770-d2b8432d71de</td>\n",
       "      <td>455.0</td>\n",
       "      <td>460.0</td>\n",
       "      <td>Z166069305_merged.txt</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>14</th>\n",
       "      <td>('r. Ihre ganze Nahrung besteht in Brodt oder ...</td>\n",
       "      <td>Und wirklich sind diejenigen, die in der Wuste...</td>\n",
       "      <td>15.0</td>\n",
       "      <td>5913d181-6da7-4169-9187-9eb885d33e33</td>\n",
       "      <td>448.0</td>\n",
       "      <td>452.0</td>\n",
       "      <td>Z166069305_merged.txt</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>15</th>\n",
       "      <td>('g. Sie waren bald bei uns und hatten uns, oh...</td>\n",
       "      <td>Es verdros mich, das ich mich solchen Raubern ...</td>\n",
       "      <td>16.0</td>\n",
       "      <td>1a1ef27f-0449-4664-8f6c-e929f089504a</td>\n",
       "      <td>431.0</td>\n",
       "      <td>435.0</td>\n",
       "      <td>Z166069305_merged.txt</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>17</th>\n",
       "      <td>('d. Der Efel, der den Munduorrath trug und ei...</td>\n",
       "      <td>Der Efel, der den Mundvorrath trug und einer l...</td>\n",
       "      <td>18.0</td>\n",
       "      <td>5892d1ea-8016-4e3e-9176-f6f6df833125</td>\n",
       "      <td>148.0</td>\n",
       "      <td>149.0</td>\n",
       "      <td>Z166069305_merged.txt</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>18</th>\n",
       "      <td>('t. Man reitet zu Pferde durch dieselbe, wenn...</td>\n",
       "      <td>Man reitet zu Pferde durch dieselbe, wenn nich...</td>\n",
       "      <td>19.0</td>\n",
       "      <td>e422911b-8c7b-4a1e-a4aa-df3d3f617c51</td>\n",
       "      <td>152.0</td>\n",
       "      <td>153.0</td>\n",
       "      <td>Z166069305_merged.txt</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>19</th>\n",
       "      <td>(\"n. Eine Viertelmeile weit richteten wir unse...</td>\n",
       "      <td>Eine Viertelmeile weit richteten wir unsern We...</td>\n",
       "      <td>20.0</td>\n",
       "      <td>2602d32c-2c40-4add-893c-abfc115b3c38</td>\n",
       "      <td>415.0</td>\n",
       "      <td>419.0</td>\n",
       "      <td>Z166069305_merged.txt</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>20</th>\n",
       "      <td>(\"n. Auf den Strasen uerkaufte man Bokshornste...</td>\n",
       "      <td>Auf den Strasen verkaufte man Bokshornstengel*...</td>\n",
       "      <td>21.0</td>\n",
       "      <td>b3a06b70-a367-4eef-a21e-788142390022</td>\n",
       "      <td>261.0</td>\n",
       "      <td>263.0</td>\n",
       "      <td>Z166069305_merged.txt</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>21</th>\n",
       "      <td>('l. Den Zaum reines Pferdes nimmt er zwischen...</td>\n",
       "      <td>Sein letztes Hulfeitrittet find jwei Sa: bel. ...</td>\n",
       "      <td>22.0</td>\n",
       "      <td>64b5828e-b14d-49dc-8d88-f97de52f9202</td>\n",
       "      <td>10.0</td>\n",
       "      <td>10.0</td>\n",
       "      <td>Z166069305_merged.txt</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>22</th>\n",
       "      <td>('n. Es giebt ein gutes Futter, das die Pferde...</td>\n",
       "      <td>machten Eigenschaften verdient der Anbau das B...</td>\n",
       "      <td>23.0</td>\n",
       "      <td>3bf200db-aeb9-4823-8923-6458b1f01d7e</td>\n",
       "      <td>263.0</td>\n",
       "      <td>266.0</td>\n",
       "      <td>Z166069305_merged.txt</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>24</th>\n",
       "      <td>('-- Wir kamen aus einer Stadt, wo die Menge u...</td>\n",
       "      <td>Wir kamen aus einer Stadt, wo die Menge von Ma...</td>\n",
       "      <td>25.0</td>\n",
       "      <td>cdd8f310-f15e-44d7-bd06-3e91351e3eae</td>\n",
       "      <td>59.0</td>\n",
       "      <td>59.0</td>\n",
       "      <td>Z166069305_merged.txt</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>25</th>\n",
       "      <td>(\"n. Den Sag nach der Ankunft dieses Mannes en...</td>\n",
       "      <td>Den Sag nach der Ankunft dieses Mannes entdekt...</td>\n",
       "      <td>26.0</td>\n",
       "      <td>59c9905e-6cfa-4544-8805-dfbd53e7ed29</td>\n",
       "      <td>454.0</td>\n",
       "      <td>459.0</td>\n",
       "      <td>Z166069305_merged.txt</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>26</th>\n",
       "      <td>('n. Die Araber uerfolgen fte zu Pferde; und m...</td>\n",
       "      <td>Sie entfernen Fich aber sogleich, fo bald fie ...</td>\n",
       "      <td>27.0</td>\n",
       "      <td>63f2c3e0-69a8-4a22-a356-7d0dd570dee1</td>\n",
       "      <td>422.0</td>\n",
       "      <td>426.0</td>\n",
       "      <td>Z166069305_merged.txt</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>33</th>\n",
       "      <td>(\"t. Jene artige Art uon uierfusigent Thieren,...</td>\n",
       "      <td>brauch von ihnen zu machen. Diese Fufe' find w...</td>\n",
       "      <td>34.0</td>\n",
       "      <td>1f056aa1-5980-4f62-9bff-147a9b409fd9</td>\n",
       "      <td>423.0</td>\n",
       "      <td>427.0</td>\n",
       "      <td>Z166069305_merged.txt</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>62</th>\n",
       "      <td>('t. Wir erkletterten auf Maulefeln die Sandhu...</td>\n",
       "      <td>Wir erkletterten auf Maulefeln die Sandhugel, ...</td>\n",
       "      <td>63.0</td>\n",
       "      <td>e4074c9a-c71c-4076-a22e-dce3f7e263c9</td>\n",
       "      <td>264.0</td>\n",
       "      <td>267.0</td>\n",
       "      <td>Z166069305_merged.txt</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                                  sentence_annotation  \\\n",
       "0   ('h. Ein Trupp Beduinen zu Pferde. brach auf e...   \n",
       "1   ('n. Man muntert beide auch mit einem Klatsche...   \n",
       "2   ('t. Ein kriegerisches und eroberungssuchtiges...   \n",
       "3   ('n. Die Waffen eines Mamefu den zu Pferde fin...   \n",
       "4   ('r. Das heise Clima dieser Gegenden des Alter...   \n",
       "5   (\"n. Diese Banditen waren nicht damit zufriede...   \n",
       "6   ('s. ?. Wir fahen zwei Beduinen zu Pferde; fie...   \n",
       "7   (\"b. Der Hraber muste mir fur den taglichen Pr...   \n",
       "8   ('r. Ich war mit meinem Pferde uorausgeritten,...   \n",
       "9   ('-- Das Lager stand etwan einige hundert Fus ...   \n",
       "10  (\"n. Ich bemerkte oft frische Spuren uon Strau...   \n",
       "11  ('b. Ich bestieg ein sehr schones Pferd, und i...   \n",
       "12  ('n. Sie halten sich mit ihren trefa lich klei...   \n",
       "13  ('n. Es war eine sehr gunstige Gelegenheit: di...   \n",
       "14  ('r. Ihre ganze Nahrung besteht in Brodt oder ...   \n",
       "15  ('g. Sie waren bald bei uns und hatten uns, oh...   \n",
       "17  ('d. Der Efel, der den Munduorrath trug und ei...   \n",
       "18  ('t. Man reitet zu Pferde durch dieselbe, wenn...   \n",
       "19  (\"n. Eine Viertelmeile weit richteten wir unse...   \n",
       "20  (\"n. Auf den Strasen uerkaufte man Bokshornste...   \n",
       "21  ('l. Den Zaum reines Pferdes nimmt er zwischen...   \n",
       "22  ('n. Es giebt ein gutes Futter, das die Pferde...   \n",
       "24  ('-- Wir kamen aus einer Stadt, wo die Menge u...   \n",
       "25  (\"n. Den Sag nach der Ankunft dieses Mannes en...   \n",
       "26  ('n. Die Araber uerfolgen fte zu Pferde; und m...   \n",
       "33  (\"t. Jene artige Art uon uierfusigent Thieren,...   \n",
       "62  ('t. Wir erkletterten auf Maulefeln die Sandhu...   \n",
       "\n",
       "                                        text_vector_x  rerank  \\\n",
       "0   befand mich in einiger Entfernung davon, und d...     1.0   \n",
       "1   Man muntert beide auch mit einem Klatschen der...     2.0   \n",
       "2   Eine weife Nation hingegen, die den Ackerbau f...     3.0   \n",
       "3     Die Waffen eines Mamefu den zu Pferde find zwei     4.0   \n",
       "4   Das Pferd, das eben fo feurig ist als die Luft...     5.0   \n",
       "5   Andere Uraber erwiesen meinen Gefahrten diesel...     6.0   \n",
       "6   ?. Wir fahen zwei Beduinen zu Pferde; fie floh...     7.0   \n",
       "7   Der Hraber muste mir fur den taglichen Preis v...     8.0   \n",
       "8   Ich war mit meinem Pferde vorausgeritten, und ...     9.0   \n",
       "9   Man bauete verschiedente Arten Viehfutter dara...    10.0   \n",
       "10  Ihre Jagd ist eine von den Leibesubuns gen, wo...    11.0   \n",
       "11  Ich bestieg ein sehr schones Pferd, und ich wu...    12.0   \n",
       "12  Sie halten sich mit ihren trefa lich kleinen P...    13.0   \n",
       "13  mittel herum, die man ihnen gereicht hatte: ih...    14.0   \n",
       "14  Und wirklich sind diejenigen, die in der Wuste...    15.0   \n",
       "15  Es verdros mich, das ich mich solchen Raubern ...    16.0   \n",
       "17  Der Efel, der den Mundvorrath trug und einer l...    18.0   \n",
       "18  Man reitet zu Pferde durch dieselbe, wenn nich...    19.0   \n",
       "19  Eine Viertelmeile weit richteten wir unsern We...    20.0   \n",
       "20  Auf den Strasen verkaufte man Bokshornstengel*...    21.0   \n",
       "21  Sein letztes Hulfeitrittet find jwei Sa: bel. ...    22.0   \n",
       "22  machten Eigenschaften verdient der Anbau das B...    23.0   \n",
       "24  Wir kamen aus einer Stadt, wo die Menge von Ma...    25.0   \n",
       "25  Den Sag nach der Ankunft dieses Mannes entdekt...    26.0   \n",
       "26  Sie entfernen Fich aber sogleich, fo bald fie ...    27.0   \n",
       "33  brauch von ihnen zu machen. Diese Fufe' find w...    34.0   \n",
       "62  Wir erkletterten auf Maulefeln die Sandhugel, ...    63.0   \n",
       "\n",
       "                           id_annotation   page  page_annotation  \\\n",
       "0   ffbabe61-0a21-4e4f-b6e4-2ddc4724b40c  430.0            434.0   \n",
       "1   9a41db07-a5c8-4b3f-931a-43418f800768  399.0            403.0   \n",
       "2   2caacee3-c22d-4a76-a2d7-ba794856a103  175.0            176.0   \n",
       "3   0d5708db-1bf6-4de4-ad64-9759ebb4fa3c    9.0             10.0   \n",
       "4   4f7c0172-b25f-4e62-9cb5-a1c1213c6d7d  220.0            222.0   \n",
       "5   c86544f5-33f0-4d9a-b048-4995ae36c493  435.0            439.0   \n",
       "6   3a1cf968-2b82-48d9-a784-d3a7f5198890  413.0            417.0   \n",
       "7   b0450149-d074-4079-87c4-cdc252ce7c67  383.0            387.0   \n",
       "8   a16c02e9-16a6-4780-b65e-51510b8db6fb  406.0            410.0   \n",
       "9   b8a8f0ea-926e-4d89-b21d-e89e69a35c2f  394.0            397.0   \n",
       "10  2703eecd-2bb6-432b-beaf-c92933736058  424.0            428.0   \n",
       "11  3f08cff7-7220-4c5e-9d1f-1b8d4fc92028  405.0            409.0   \n",
       "12  28370a93-4521-48d0-a8da-50545822debc   12.0             12.0   \n",
       "13  d9613671-efc9-4a0e-9770-d2b8432d71de  455.0            460.0   \n",
       "14  5913d181-6da7-4169-9187-9eb885d33e33  448.0            452.0   \n",
       "15  1a1ef27f-0449-4664-8f6c-e929f089504a  431.0            435.0   \n",
       "17  5892d1ea-8016-4e3e-9176-f6f6df833125  148.0            149.0   \n",
       "18  e422911b-8c7b-4a1e-a4aa-df3d3f617c51  152.0            153.0   \n",
       "19  2602d32c-2c40-4add-893c-abfc115b3c38  415.0            419.0   \n",
       "20  b3a06b70-a367-4eef-a21e-788142390022  261.0            263.0   \n",
       "21  64b5828e-b14d-49dc-8d88-f97de52f9202   10.0             10.0   \n",
       "22  3bf200db-aeb9-4823-8923-6458b1f01d7e  263.0            266.0   \n",
       "24  cdd8f310-f15e-44d7-bd06-3e91351e3eae   59.0             59.0   \n",
       "25  59c9905e-6cfa-4544-8805-dfbd53e7ed29  454.0            459.0   \n",
       "26  63f2c3e0-69a8-4a22-a356-7d0dd570dee1  422.0            426.0   \n",
       "33  1f056aa1-5980-4f62-9bff-147a9b409fd9  423.0            427.0   \n",
       "62  e4074c9a-c71c-4076-a22e-dce3f7e263c9  264.0            267.0   \n",
       "\n",
       "          file_annotation  \n",
       "0   Z166069305_merged.txt  \n",
       "1   Z166069305_merged.txt  \n",
       "2   Z166069305_merged.txt  \n",
       "3   Z166069305_merged.txt  \n",
       "4   Z166069305_merged.txt  \n",
       "5   Z166069305_merged.txt  \n",
       "6   Z166069305_merged.txt  \n",
       "7   Z166069305_merged.txt  \n",
       "8   Z166069305_merged.txt  \n",
       "9   Z166069305_merged.txt  \n",
       "10  Z166069305_merged.txt  \n",
       "11  Z166069305_merged.txt  \n",
       "12  Z166069305_merged.txt  \n",
       "13  Z166069305_merged.txt  \n",
       "14  Z166069305_merged.txt  \n",
       "15  Z166069305_merged.txt  \n",
       "17  Z166069305_merged.txt  \n",
       "18  Z166069305_merged.txt  \n",
       "19  Z166069305_merged.txt  \n",
       "20  Z166069305_merged.txt  \n",
       "21  Z166069305_merged.txt  \n",
       "22  Z166069305_merged.txt  \n",
       "24  Z166069305_merged.txt  \n",
       "25  Z166069305_merged.txt  \n",
       "26  Z166069305_merged.txt  \n",
       "33  Z166069305_merged.txt  \n",
       "62  Z166069305_merged.txt  "
      ]
     },
     "execution_count": 9,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# Filter rows where 'found_in_text_vector' is True --> True Positives\n",
    "found = matches_df[matches_df['found_in_text_vector'] == True]\n",
    "found_fil = found['id_annotation'].drop_duplicates(keep='first')\n",
    "found_pages = found['page'].drop_duplicates(keep='first')\n",
    "\n",
    "# Extract the \"page\" value from each dictionary of unique pages found\n",
    "unique_foundPages_list = found_pages.to_list()\n",
    "\n",
    "# Filter rows where the absolute difference between 'page_annotation' and 'page_text' is less than or equal to 4\n",
    "#found = found[abs(found['page_annotation'] - found['page_text']) <= 6]\n",
    "\n",
    "print(f\"True Positives: Found {len(found_fil)} relevant mentions on {len(unique_foundPages_list)} pages of {len(unique_annot)} relevant mentions on {len(unique_pages_list)} pages\")\n",
    "print(f\"({len(unique_foundPages_list)/len(unique_pages_list)*100:.2f}%).\")\n",
    "print(f\"Found average of {len(found_fil)/len(found_pages):.2f} found mentions per page vs. GT of {len(unique_annot)/len(unique_pages_annot):.2f} annotations per page.\")\n",
    "\n",
    "found[['sentence_annotation', 'text_vector_x', 'rerank', 'id_annotation', 'page', 'page_annotation', 'file_annotation']]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "id": "1e9beb8e",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "False Negatives: Missed 21 mentions on 20 pages, of which 0 pages were retrieved with another vector.\n",
      "(50.00%).\n"
     ]
    },
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>sentence_annotation</th>\n",
       "      <th>id_annotation</th>\n",
       "      <th>page_annotation</th>\n",
       "      <th>file_annotation</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>200</th>\n",
       "      <td>('r. Wir giengen in geschloffenen Reihen und m...</td>\n",
       "      <td>a406cecb-48dc-4b27-9e2e-e831301a59bc</td>\n",
       "      <td>149.0</td>\n",
       "      <td>Z166069305_merged.txt</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>201</th>\n",
       "      <td>('s. Da die Wagen nicht gewohnlich sind, so be...</td>\n",
       "      <td>53e38871-8353-4ea1-acc5-e60964d4b02d</td>\n",
       "      <td>151.0</td>\n",
       "      <td>Z166069305_merged.txt</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>202</th>\n",
       "      <td>('t. Man tritt mit den Fusen allerhand Muschel...</td>\n",
       "      <td>32cc068f-6a60-4040-aa4a-0575f48b5c52</td>\n",
       "      <td>155.0</td>\n",
       "      <td>Z166069305_merged.txt</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>203</th>\n",
       "      <td>('r. Sie kennen kein ander Spaziergehen, --- 0...</td>\n",
       "      <td>638cd5aa-72b7-46a0-bbf1-82ec0f884747</td>\n",
       "      <td>186.0</td>\n",
       "      <td>Z166069305_merged.txt</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>204</th>\n",
       "      <td>('s. In dem Departement, wo ich wohne und in d...</td>\n",
       "      <td>8438c431-385f-40f0-b167-51527c2c8e7e</td>\n",
       "      <td>221.0</td>\n",
       "      <td>Z166069305_merged.txt</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>205</th>\n",
       "      <td>('t. Ich wuste, das er besucht zu werden uerdi...</td>\n",
       "      <td>41bd83f1-06ec-4186-af2e-63dea256dfc8</td>\n",
       "      <td>267.0</td>\n",
       "      <td>Z166069305_merged.txt</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>206</th>\n",
       "      <td>('n. Sie hatten in ihrem Hause ein Paar rothe ...</td>\n",
       "      <td>e5ebef45-e36c-4742-9976-702dfad43fc5</td>\n",
       "      <td>270.0</td>\n",
       "      <td>Z166069305_merged.txt</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>207</th>\n",
       "      <td>('e. Nach diesem Kaufe nahmen wir uon dem gute...</td>\n",
       "      <td>a02a872b-8602-4ff4-93bd-f539ff93ada6</td>\n",
       "      <td>276.0</td>\n",
       "      <td>Z166069305_merged.txt</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>208</th>\n",
       "      <td>('n. Der Viceconsul, rein Drogman und ein fran...</td>\n",
       "      <td>a5b12bfb-3a78-46ac-8d62-73d5bf4425c9</td>\n",
       "      <td>277.0</td>\n",
       "      <td>Z166069305_merged.txt</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>209</th>\n",
       "      <td>('n. Unsere Esel Fielen nieder, sanken in den ...</td>\n",
       "      <td>ceed7937-1824-4222-ba6c-686b2b4d7738</td>\n",
       "      <td>278.0</td>\n",
       "      <td>Z166069305_merged.txt</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>210</th>\n",
       "      <td>('tu Wir hatten Maulefel, womit man gewohnlich...</td>\n",
       "      <td>94d76c3d-1115-4a4e-91b5-501f6e88de65</td>\n",
       "      <td>386.0</td>\n",
       "      <td>Z166069305_merged.txt</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>211</th>\n",
       "      <td>('. Ich trug kein Bedenken, mich ihnen anzuuer...</td>\n",
       "      <td>acc36476-9315-4751-9646-bba3a2231e07</td>\n",
       "      <td>386.0</td>\n",
       "      <td>Z166069305_merged.txt</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>212</th>\n",
       "      <td>('e. Damit man nun nicht an meiner Furchtlosig...</td>\n",
       "      <td>b9449bfd-c3bb-4b97-9c45-305b10b7aeca</td>\n",
       "      <td>389.0</td>\n",
       "      <td>Z166069305_merged.txt</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>213</th>\n",
       "      <td>('). Bei meiner Rukkunft nach Abukir fand ich ...</td>\n",
       "      <td>995c9029-3950-44cb-a7c7-e6f91a96ecf7</td>\n",
       "      <td>391.0</td>\n",
       "      <td>Z166069305_merged.txt</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>214</th>\n",
       "      <td>('-- Plinius berichtet nach dem Xenophon, die ...</td>\n",
       "      <td>fe020016-1d51-4a1f-bbc1-d4a65973bf67</td>\n",
       "      <td>402.0</td>\n",
       "      <td>Z166069305_merged.txt</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>215</th>\n",
       "      <td>('g. Ehe wir noch an dieseru Ore anlangten, sa...</td>\n",
       "      <td>4795c52d-1f6e-4de6-b87f-a5ae17735dad</td>\n",
       "      <td>419.0</td>\n",
       "      <td>Z166069305_merged.txt</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>216</th>\n",
       "      <td>('ort. Wir kamen auf einen\\' bedekten Sand, de...</td>\n",
       "      <td>92f4ee0e-d411-4c55-bda6-02b5f8aefce6</td>\n",
       "      <td>433.0</td>\n",
       "      <td>Z166069305_merged.txt</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>217</th>\n",
       "      <td>('n. Ob fie gleich in starkem Galop auf uns zu...</td>\n",
       "      <td>0c529bb3-6ce7-4a2f-8741-1aaa4f2205d4</td>\n",
       "      <td>434.0</td>\n",
       "      <td>Z166069305_merged.txt</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>218</th>\n",
       "      <td>('li Wenn man den Arabern glaubt, die der Mein...</td>\n",
       "      <td>9a71ef03-d718-402b-b7f9-14844f486a22</td>\n",
       "      <td>452.0</td>\n",
       "      <td>Z166069305_merged.txt</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>219</th>\n",
       "      <td>('t, Ich hatte einen uon den Landleuten, die i...</td>\n",
       "      <td>e6e36f7b-3376-4624-a48b-ff2d88ba6167</td>\n",
       "      <td>460.0</td>\n",
       "      <td>Z166069305_merged.txt</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>220</th>\n",
       "      <td>('91 Ich uerlies endlich diesen. heltischer Au...</td>\n",
       "      <td>39769078-50ac-4faf-b32a-e74fd7cc46b0</td>\n",
       "      <td>462.0</td>\n",
       "      <td>Z166069305_merged.txt</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                                   sentence_annotation  \\\n",
       "200  ('r. Wir giengen in geschloffenen Reihen und m...   \n",
       "201  ('s. Da die Wagen nicht gewohnlich sind, so be...   \n",
       "202  ('t. Man tritt mit den Fusen allerhand Muschel...   \n",
       "203  ('r. Sie kennen kein ander Spaziergehen, --- 0...   \n",
       "204  ('s. In dem Departement, wo ich wohne und in d...   \n",
       "205  ('t. Ich wuste, das er besucht zu werden uerdi...   \n",
       "206  ('n. Sie hatten in ihrem Hause ein Paar rothe ...   \n",
       "207  ('e. Nach diesem Kaufe nahmen wir uon dem gute...   \n",
       "208  ('n. Der Viceconsul, rein Drogman und ein fran...   \n",
       "209  ('n. Unsere Esel Fielen nieder, sanken in den ...   \n",
       "210  ('tu Wir hatten Maulefel, womit man gewohnlich...   \n",
       "211  ('. Ich trug kein Bedenken, mich ihnen anzuuer...   \n",
       "212  ('e. Damit man nun nicht an meiner Furchtlosig...   \n",
       "213  ('). Bei meiner Rukkunft nach Abukir fand ich ...   \n",
       "214  ('-- Plinius berichtet nach dem Xenophon, die ...   \n",
       "215  ('g. Ehe wir noch an dieseru Ore anlangten, sa...   \n",
       "216  ('ort. Wir kamen auf einen\\' bedekten Sand, de...   \n",
       "217  ('n. Ob fie gleich in starkem Galop auf uns zu...   \n",
       "218  ('li Wenn man den Arabern glaubt, die der Mein...   \n",
       "219  ('t, Ich hatte einen uon den Landleuten, die i...   \n",
       "220  ('91 Ich uerlies endlich diesen. heltischer Au...   \n",
       "\n",
       "                            id_annotation  page_annotation  \\\n",
       "200  a406cecb-48dc-4b27-9e2e-e831301a59bc            149.0   \n",
       "201  53e38871-8353-4ea1-acc5-e60964d4b02d            151.0   \n",
       "202  32cc068f-6a60-4040-aa4a-0575f48b5c52            155.0   \n",
       "203  638cd5aa-72b7-46a0-bbf1-82ec0f884747            186.0   \n",
       "204  8438c431-385f-40f0-b167-51527c2c8e7e            221.0   \n",
       "205  41bd83f1-06ec-4186-af2e-63dea256dfc8            267.0   \n",
       "206  e5ebef45-e36c-4742-9976-702dfad43fc5            270.0   \n",
       "207  a02a872b-8602-4ff4-93bd-f539ff93ada6            276.0   \n",
       "208  a5b12bfb-3a78-46ac-8d62-73d5bf4425c9            277.0   \n",
       "209  ceed7937-1824-4222-ba6c-686b2b4d7738            278.0   \n",
       "210  94d76c3d-1115-4a4e-91b5-501f6e88de65            386.0   \n",
       "211  acc36476-9315-4751-9646-bba3a2231e07            386.0   \n",
       "212  b9449bfd-c3bb-4b97-9c45-305b10b7aeca            389.0   \n",
       "213  995c9029-3950-44cb-a7c7-e6f91a96ecf7            391.0   \n",
       "214  fe020016-1d51-4a1f-bbc1-d4a65973bf67            402.0   \n",
       "215  4795c52d-1f6e-4de6-b87f-a5ae17735dad            419.0   \n",
       "216  92f4ee0e-d411-4c55-bda6-02b5f8aefce6            433.0   \n",
       "217  0c529bb3-6ce7-4a2f-8741-1aaa4f2205d4            434.0   \n",
       "218  9a71ef03-d718-402b-b7f9-14844f486a22            452.0   \n",
       "219  e6e36f7b-3376-4624-a48b-ff2d88ba6167            460.0   \n",
       "220  39769078-50ac-4faf-b32a-e74fd7cc46b0            462.0   \n",
       "\n",
       "           file_annotation  \n",
       "200  Z166069305_merged.txt  \n",
       "201  Z166069305_merged.txt  \n",
       "202  Z166069305_merged.txt  \n",
       "203  Z166069305_merged.txt  \n",
       "204  Z166069305_merged.txt  \n",
       "205  Z166069305_merged.txt  \n",
       "206  Z166069305_merged.txt  \n",
       "207  Z166069305_merged.txt  \n",
       "208  Z166069305_merged.txt  \n",
       "209  Z166069305_merged.txt  \n",
       "210  Z166069305_merged.txt  \n",
       "211  Z166069305_merged.txt  \n",
       "212  Z166069305_merged.txt  \n",
       "213  Z166069305_merged.txt  \n",
       "214  Z166069305_merged.txt  \n",
       "215  Z166069305_merged.txt  \n",
       "216  Z166069305_merged.txt  \n",
       "217  Z166069305_merged.txt  \n",
       "218  Z166069305_merged.txt  \n",
       "219  Z166069305_merged.txt  \n",
       "220  Z166069305_merged.txt  "
      ]
     },
     "execution_count": 10,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# Filter rows where 'found_in_text_vector' is False --> False Negatives\n",
    "missed = matches_df[matches_df['found_in_text_vector'] == False]\n",
    "missed_fil = missed['id_annotation'].drop_duplicates(keep='first')\n",
    "missed_pages = missed['page_annotation'].drop_duplicates(keep='first')\n",
    "\n",
    "# Filter out pages that are in unique pages found\n",
    "missed_pages_unique = missed_pages[~missed_pages.isin(unique_foundPages_list)]\n",
    "retrieved_pages_otherVec = missed_pages[missed_pages.isin(unique_foundPages_list)]\n",
    "\n",
    "print(f\"False Negatives: Missed {len(missed_fil)} mentions on {len(missed_pages_unique)} pages, of which {len(retrieved_pages_otherVec)} pages were retrieved with another vector.\")\n",
    "print(f\"({(len(missed_pages_unique))/len(unique_pages_list)*100:.2f}%).\")\n",
    "\n",
    "missed[['sentence_annotation', 'id_annotation', 'page_annotation', 'file_annotation']]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "id": "e7753ea4",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Retrieved 173 vectors on 173 pages of which 11 pages do contain annotations (correct pages, but other vector retrieved).\n",
      "and of which 162 pages do not contain annotations (= False Positives)\n",
      "(405.00)\n",
      "and of which 0 pages were retrieved with other vectors (= True Negatives).\n"
     ]
    },
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>text_vector_x</th>\n",
       "      <th>rerank</th>\n",
       "      <th>id_text_vector</th>\n",
       "      <th>page</th>\n",
       "      <th>page_annotation</th>\n",
       "      <th>file_annotation</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>16</th>\n",
       "      <td>Unter einer Regierung, die nur die Absicht bat...</td>\n",
       "      <td>17.0</td>\n",
       "      <td>9ee8949a-e0cc-4334-bc36-b71becd2d5c7</td>\n",
       "      <td>400.0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>23</th>\n",
       "      <td>feiner Neise 1. th.).</td>\n",
       "      <td>24.0</td>\n",
       "      <td>39e2e422-b7c3-40c1-90ee-12718c603261</td>\n",
       "      <td>393.0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>27</th>\n",
       "      <td>**) Ursprung der Gefese 2. Bd.</td>\n",
       "      <td>28.0</td>\n",
       "      <td>4ff5ac89-e2f3-468f-bad6-712ecce32e54</td>\n",
       "      <td>170.0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>28</th>\n",
       "      <td>Von frih morgens an, bis auf den Abend, hat ma...</td>\n",
       "      <td>29.0</td>\n",
       "      <td>d4357d62-9022-4b84-803b-e634b791a923</td>\n",
       "      <td>182.0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>29</th>\n",
       "      <td>Das Wasser, das * Strix passerina, Lin, Chevec...</td>\n",
       "      <td>30.0</td>\n",
       "      <td>7aaae2e6-1e90-46a2-9f05-fe28c7b2842b</td>\n",
       "      <td>236.0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>195</th>\n",
       "      <td>fchichte uberhaupt, und jene des. Mungo insbes...</td>\n",
       "      <td>196.0</td>\n",
       "      <td>f8995776-d337-413e-bc6b-d54a1fb5ff86</td>\n",
       "      <td>223.0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>196</th>\n",
       "      <td>Ob sie gleich gesehen hatten, was seit Morgens...</td>\n",
       "      <td>197.0</td>\n",
       "      <td>3315a574-24e7-4a73-b660-bd151a27956b</td>\n",
       "      <td>437.0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>197</th>\n",
       "      <td>Die fehr oftern Uncinigkeiten zwischen den Beh...</td>\n",
       "      <td>198.0</td>\n",
       "      <td>bd45fa07-bd6a-46f3-9ba9-516d48d55fb5</td>\n",
       "      <td>161.0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>198</th>\n",
       "      <td>Es ist bemerkenswerth, das man diesen unruhige...</td>\n",
       "      <td>199.0</td>\n",
       "      <td>736f2f9e-85b2-470d-a94e-f34f64db4189</td>\n",
       "      <td>89.0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>199</th>\n",
       "      <td>M. 24 und 26. Wit find Flein auf Erden und Flu...</td>\n",
       "      <td>200.0</td>\n",
       "      <td>ebb43751-cbfe-40d5-9056-95e68b9102a6</td>\n",
       "      <td>126.0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>173 rows × 6 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "                                         text_vector_x  rerank  \\\n",
       "16   Unter einer Regierung, die nur die Absicht bat...    17.0   \n",
       "23                               feiner Neise 1. th.).    24.0   \n",
       "27                      **) Ursprung der Gefese 2. Bd.    28.0   \n",
       "28   Von frih morgens an, bis auf den Abend, hat ma...    29.0   \n",
       "29   Das Wasser, das * Strix passerina, Lin, Chevec...    30.0   \n",
       "..                                                 ...     ...   \n",
       "195  fchichte uberhaupt, und jene des. Mungo insbes...   196.0   \n",
       "196  Ob sie gleich gesehen hatten, was seit Morgens...   197.0   \n",
       "197  Die fehr oftern Uncinigkeiten zwischen den Beh...   198.0   \n",
       "198  Es ist bemerkenswerth, das man diesen unruhige...   199.0   \n",
       "199  M. 24 und 26. Wit find Flein auf Erden und Flu...   200.0   \n",
       "\n",
       "                           id_text_vector   page  page_annotation  \\\n",
       "16   9ee8949a-e0cc-4334-bc36-b71becd2d5c7  400.0              NaN   \n",
       "23   39e2e422-b7c3-40c1-90ee-12718c603261  393.0              NaN   \n",
       "27   4ff5ac89-e2f3-468f-bad6-712ecce32e54  170.0              NaN   \n",
       "28   d4357d62-9022-4b84-803b-e634b791a923  182.0              NaN   \n",
       "29   7aaae2e6-1e90-46a2-9f05-fe28c7b2842b  236.0              NaN   \n",
       "..                                    ...    ...              ...   \n",
       "195  f8995776-d337-413e-bc6b-d54a1fb5ff86  223.0              NaN   \n",
       "196  3315a574-24e7-4a73-b660-bd151a27956b  437.0              NaN   \n",
       "197  bd45fa07-bd6a-46f3-9ba9-516d48d55fb5  161.0              NaN   \n",
       "198  736f2f9e-85b2-470d-a94e-f34f64db4189   89.0              NaN   \n",
       "199  ebb43751-cbfe-40d5-9056-95e68b9102a6  126.0              NaN   \n",
       "\n",
       "    file_annotation  \n",
       "16              NaN  \n",
       "23              NaN  \n",
       "27              NaN  \n",
       "28              NaN  \n",
       "29              NaN  \n",
       "..              ...  \n",
       "195             NaN  \n",
       "196             NaN  \n",
       "197             NaN  \n",
       "198             NaN  \n",
       "199             NaN  \n",
       "\n",
       "[173 rows x 6 columns]"
      ]
     },
     "execution_count": 11,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# Filter rows where 'found_in_text_vector' is NaN --> False Positives\n",
    "FP = matches_df[matches_df['found_in_text_vector'].isna()]\n",
    "fP_pages = FP['page'].drop_duplicates(keep='first')\n",
    "\n",
    "# Extract the \"page\" value from each dictionary of unique pages found\n",
    "unique_FPPages_list = fP_pages.to_list()\n",
    "\n",
    "# Filter out pages that are in unique pages found\n",
    "ret_pages_Annot = fP_pages[fP_pages.isin(unique_pages_list)]\n",
    "ret_pages_noAnnot = fP_pages[~fP_pages.isin(unique_pages_list)]\n",
    "retrieved_otherVec = fP_pages[fP_pages.isin(unique_foundPages_list)]\n",
    "\n",
    "print(f\"Retrieved {len(FP)} vectors on {len(unique_FPPages_list)} pages of which {len(ret_pages_Annot)} pages do contain annotations (correct pages, but other vector retrieved).\")\n",
    "print(f\"and of which {len(ret_pages_noAnnot)} pages do not contain annotations (= False Positives)\")\n",
    "print(f\"({len(ret_pages_noAnnot)/len(unique_pages_list)*100:.2f})\")\n",
    "print(f\"and of which {len(retrieved_otherVec)} pages were retrieved with other vectors (= True Negatives).\")\n",
    "FP[['text_vector_x', 'rerank', 'id_text_vector', 'page', 'page_annotation', 'file_annotation']]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "2bf572ee",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "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.9.12"
  },
  "toc": {
   "base_numbering": 1,
   "nav_menu": {},
   "number_sections": true,
   "sideBar": true,
   "skip_h1_title": false,
   "title_cell": "Table of Contents",
   "title_sidebar": "Contents",
   "toc_cell": false,
   "toc_position": {},
   "toc_section_display": true,
   "toc_window_display": false
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}