File size: 90,070 Bytes
9754890
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [],
   "source": [
    "import pandas as pd\n",
    "import torch\n",
    "from transformers import AutoTokenizer, AutoModel\n",
    "import re"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [],
   "source": [
    "# Target列を分割する関数\n",
    "def split_target(target):\n",
    "    # 指定された区切り文字で分割\n",
    "    split_words = re.split(r'[,\\n、・及びおよび又はまたは]+', target)\n",
    "    # 空白文字を除外してリストとして返す\n",
    "    return [word.strip() for word in split_words if word.strip()]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [],
   "source": [
    "basedf = pd.read_csv('../ClinicalTrialCSV/JRCT20241202Cancer.csv', index_col=0)\n",
    "basedf = basedf.dropna(subset=['試験等のフェーズ'])\n",
    "# Target列を分割してTargetWord列を追加\n",
    "basedf['TargetWord'] = basedf['Target'].apply(split_target)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "application/vnd.jupyter.widget-view+json": {
       "model_id": "9671f824f52348f8a161a130e7437adb",
       "version_major": 2,
       "version_minor": 0
      },
      "text/plain": [
       "tokenizer_config.json:   0%|          | 0.00/418 [00:00<?, ?B/s]"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "application/vnd.jupyter.widget-view+json": {
       "model_id": "6da34a9d4894446292efdc8b26959431",
       "version_major": 2,
       "version_minor": 0
      },
      "text/plain": [
       "sentencepiece.bpe.model:   0%|          | 0.00/5.07M [00:00<?, ?B/s]"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "application/vnd.jupyter.widget-view+json": {
       "model_id": "497e9ea0ccdb4efcb40f33fc7f48f7e9",
       "version_major": 2,
       "version_minor": 0
      },
      "text/plain": [
       "tokenizer.json:   0%|          | 0.00/17.1M [00:00<?, ?B/s]"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "application/vnd.jupyter.widget-view+json": {
       "model_id": "9f5ddefc537d40cfa4c1cc74431c0558",
       "version_major": 2,
       "version_minor": 0
      },
      "text/plain": [
       "special_tokens_map.json:   0%|          | 0.00/280 [00:00<?, ?B/s]"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "application/vnd.jupyter.widget-view+json": {
       "model_id": "fe3dcf900fe5496eb5fb5773535e122c",
       "version_major": 2,
       "version_minor": 0
      },
      "text/plain": [
       "config.json:   0%|          | 0.00/690 [00:00<?, ?B/s]"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "application/vnd.jupyter.widget-view+json": {
       "model_id": "046a5fa146b943c7914a9d9be475fe9b",
       "version_major": 2,
       "version_minor": 0
      },
      "text/plain": [
       "model.safetensors:   0%|          | 0.00/2.24G [00:00<?, ?B/s]"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "# モデルとトークナイザーのロード\n",
    "model_name = \"intfloat/multilingual-e5-large\"\n",
    "tokenizer = AutoTokenizer.from_pretrained(model_name)\n",
    "model = AutoModel.from_pretrained(model_name)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [],
   "source": [
    "# テキストをベクトル化する関数\n",
    "def encode_text(texts):\n",
    "    inputs = tokenizer(texts, padding=True, truncation=True, return_tensors=\"pt\")\n",
    "    with torch.no_grad():\n",
    "        outputs = model(**inputs)\n",
    "    return outputs.last_hidden_state.mean(dim=1)  # 平均プーリングでベクトル化"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 66,
   "metadata": {},
   "outputs": [],
   "source": [
    "# クエリ\n",
    "query = \"乳がん\"\n",
    "#query = \"神経膠腫\"\n",
    "threshold = 0.91\n",
    "#threshold = 0.875\n",
    "# クエリをベクトル化\n",
    "query_vec = encode_text([query])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 67,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "torch.Size([1, 1024])"
      ]
     },
     "execution_count": 67,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "query_vec.shape"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 68,
   "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>JRCT ID</th>\n",
       "      <th>NCT No</th>\n",
       "      <th>JapicCTI No</th>\n",
       "      <th>Title</th>\n",
       "      <th>Target</th>\n",
       "      <th>研究・治験の目的</th>\n",
       "      <th>試験等のフェーズ</th>\n",
       "      <th>試験の種類</th>\n",
       "      <th>無作為化</th>\n",
       "      <th>盲検化</th>\n",
       "      <th>...</th>\n",
       "      <th>purpose</th>\n",
       "      <th>Inclusion Criteria</th>\n",
       "      <th>Exclusion Criteria</th>\n",
       "      <th>Age Minimum</th>\n",
       "      <th>Age Maximum</th>\n",
       "      <th>Gender</th>\n",
       "      <th>Discontinuation Criteria</th>\n",
       "      <th>Keyword</th>\n",
       "      <th>Intervention(s)</th>\n",
       "      <th>TargetWord</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>12</th>\n",
       "      <td>jRCT2041240130</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>中等度-高度PONV発症リスクを有する肺切除術予定患者の周術期管理におけるGranisetr...</td>\n",
       "      <td>肺がん</td>\n",
       "      <td>全身麻酔を要する肺切除術周術期における標準制吐療法であるグラニセトロン(Granisetro...</td>\n",
       "      <td>2</td>\n",
       "      <td>NaN</td>\n",
       "      <td>無作為化比較</td>\n",
       "      <td>非盲検</td>\n",
       "      <td>...</td>\n",
       "      <td>treatment purpose</td>\n",
       "      <td>(1) Patients scheduled to undergo anatomical l...</td>\n",
       "      <td>(1) Patients with a history of allergy to the ...</td>\n",
       "      <td>18age old over</td>\n",
       "      <td>No limit</td>\n",
       "      <td>Both</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>Treatment group\\r\\nAdminister GRA 1mg intraven...</td>\n",
       "      <td>[肺がん]</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>59</th>\n",
       "      <td>jRCT2031240404</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>転移性HR+/HER2-乳がん及びその他の進行性固形がん患者を対象にCDK4阻害剤BGB-4...</td>\n",
       "      <td>・進行性固形腫瘍・進行性乳がん・転移性乳がん・ホルモン受容体陽性乳がん・ホルモン受容体陽性乳...</td>\n",
       "      <td>サイクリン依存性キナーゼ 4 (CDK4) 阻害剤である BGB-43395 が、ホルモン受...</td>\n",
       "      <td>1</td>\n",
       "      <td>NaN</td>\n",
       "      <td>非無作為化比較</td>\n",
       "      <td>非盲検</td>\n",
       "      <td>...</td>\n",
       "      <td>treatment purpose</td>\n",
       "      <td>-Phase 1a (Dose Escalation) and 1b (Dose Expan...</td>\n",
       "      <td>-Prior therapy selectively targeting CDK4 (pri...</td>\n",
       "      <td>18age old over</td>\n",
       "      <td>No limit</td>\n",
       "      <td>Both</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>-Drug: BGB-43395\\r\\nPlanned doses administered...</td>\n",
       "      <td>[進行性固形腫瘍, 進行性乳がん, 転移性乳がん, ホルモン受容体陽性乳がん, ホルモン受容...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>201</th>\n",
       "      <td>jRCT2052240059</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>遺伝子HSD17B4高メチル化を有するHER2陽性ER陰性乳癌における非手術療法の有用性を評...</td>\n",
       "      <td>乳がん</td>\n",
       "      <td>HSD17B4高メチル化(HSD17B4 hypermethylation:HH)を有するH...</td>\n",
       "      <td>2</td>\n",
       "      <td>NaN</td>\n",
       "      <td>単一群</td>\n",
       "      <td>非盲検</td>\n",
       "      <td>...</td>\n",
       "      <td>diagnostic purpose</td>\n",
       "      <td>1. Histologically confirmed invasive breast ca...</td>\n",
       "      <td>1. History of other malignancy within the last...</td>\n",
       "      <td>20age old over</td>\n",
       "      <td>No limit</td>\n",
       "      <td>Female</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>Omitting breast surgery after preoperative che...</td>\n",
       "      <td>[乳がん]</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>234</th>\n",
       "      <td>jRCT2031240065</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>DNAミスマッチ修復機構欠損を有する進行性・転移性子宮体がん患者を対象に、一次治療として化学...</td>\n",
       "      <td>子宮体がん</td>\n",
       "      <td>dMMR/MSI-Hを有する再発又は進行子宮体癌患者を対象にdostarlimabの有効性及...</td>\n",
       "      <td>3</td>\n",
       "      <td>NaN</td>\n",
       "      <td>無作為化比較</td>\n",
       "      <td>非盲検</td>\n",
       "      <td>...</td>\n",
       "      <td>treatment purpose</td>\n",
       "      <td>1. Female patient is at least 18 years of age,...</td>\n",
       "      <td>1. Patient has received neoadjuvant/adjuvant s...</td>\n",
       "      <td>18age old over</td>\n",
       "      <td>No limit</td>\n",
       "      <td>Female</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>Patients will be randomized 1:1 to receive eit...</td>\n",
       "      <td>[子宮体がん]</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>257</th>\n",
       "      <td>jRCT2033240023</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>免疫チェックポイント阻害剤に対してacquired resistanceとなったがん患者を対...</td>\n",
       "      <td>肺がん、食道がん、胃癌等の固形がん</td>\n",
       "      <td>免疫チェックポイント阻害剤に対してacquired resistanceとなったがん患者(非...</td>\n",
       "      <td>1-2</td>\n",
       "      <td>NaN</td>\n",
       "      <td>単一群</td>\n",
       "      <td>非盲検</td>\n",
       "      <td>...</td>\n",
       "      <td>treatment purpose</td>\n",
       "      <td>1. Japanese patients aged 20 years or older at...</td>\n",
       "      <td>1. Patients with a history of severe drug hype...</td>\n",
       "      <td>20age old over</td>\n",
       "      <td>No limit</td>\n",
       "      <td>Both</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>Intramuscular injection of the investigational...</td>\n",
       "      <td>[肺がん, 食道がん, 胃癌等の固形がん]</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>271</th>\n",
       "      <td>jRCT2031230750</td>\n",
       "      <td>NCT06188559</td>\n",
       "      <td>NaN</td>\n",
       "      <td>治療歴のある HER2 陽性又は HER2 低発現の切除不能又は転移性乳癌の被験者を対象に,...</td>\n",
       "      <td>HER2 陽性又は HER2 低発現の切除不能又は転移性乳癌</td>\n",
       "      <td>治療</td>\n",
       "      <td>2</td>\n",
       "      <td>NaN</td>\n",
       "      <td>無作為化比較</td>\n",
       "      <td>非盲検</td>\n",
       "      <td>...</td>\n",
       "      <td>treatment purpose</td>\n",
       "      <td>(1) Male or female, aged &gt;=18 years at the tim...</td>\n",
       "      <td>(1) Presence of brain or subdural metastases, ...</td>\n",
       "      <td>18age old over</td>\n",
       "      <td>No limit</td>\n",
       "      <td>Both</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>Generic Name:NA\\r\\nStudy Treatment in dose opt...</td>\n",
       "      <td>[HER2 陽性, HER2 低発現の切除不能, 転移性乳癌]</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>279</th>\n",
       "      <td>jRCT2031230723</td>\n",
       "      <td>NCT06112379</td>\n",
       "      <td>NaN</td>\n",
       "      <td>未治療のトリプルネガティブ又はホルモン受容体低発現/HER2陰性乳癌の成人患者を対象として、...</td>\n",
       "      <td>乳癌</td>\n",
       "      <td>未治療のトリプルネガティブ又はホルモン受容体低発現/HER2陰性乳癌の成人患者を対象として、...</td>\n",
       "      <td>3</td>\n",
       "      <td>NaN</td>\n",
       "      <td>無作為化比較</td>\n",
       "      <td>非盲検</td>\n",
       "      <td>...</td>\n",
       "      <td>treatment purpose</td>\n",
       "      <td>1. Participant must be &gt;= 18 years at the time...</td>\n",
       "      <td>1. As judged by the investigator, any evidence...</td>\n",
       "      <td>18age old over</td>\n",
       "      <td>No limit</td>\n",
       "      <td>Both</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>- Experimental arm: Dato-DXd plus durvalumab n...</td>\n",
       "      <td>[乳癌]</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>311</th>\n",
       "      <td>jRCT2061230102</td>\n",
       "      <td>NCT06103864</td>\n",
       "      <td>NaN</td>\n",
       "      <td>Programmed death-ligand(PD-L1)陽性の局所再発手術不能又は転移性...</td>\n",
       "      <td>乳癌</td>\n",
       "      <td>PD-L1陽性の局所再発手術不能または転移性TNBC患者を対象に、デュルバルマブ併用または非...</td>\n",
       "      <td>3</td>\n",
       "      <td>NaN</td>\n",
       "      <td>無作為化比較</td>\n",
       "      <td>非盲検</td>\n",
       "      <td>...</td>\n",
       "      <td>treatment purpose</td>\n",
       "      <td>Histologically or cytologically documented loc...</td>\n",
       "      <td>As judged by investigator, severe or uncontrol...</td>\n",
       "      <td>18age old over</td>\n",
       "      <td>No limit</td>\n",
       "      <td>Both</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>Arm 1: Dato-DXd + durvalumab\\r\\nArm 2: Investi...</td>\n",
       "      <td>[乳癌]</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>396</th>\n",
       "      <td>jRCT2061230074</td>\n",
       "      <td>NCT05952557</td>\n",
       "      <td>NaN</td>\n",
       "      <td>根治的局所治療(化学療法の併用または非併用)を受けて疾患の兆候のない、再発リスクが中間~高リ...</td>\n",
       "      <td>乳がん、早期乳がん</td>\n",
       "      <td>Treatment</td>\n",
       "      <td>3</td>\n",
       "      <td>NaN</td>\n",
       "      <td>無作為化比較</td>\n",
       "      <td>非盲検</td>\n",
       "      <td>...</td>\n",
       "      <td>treatment purpose</td>\n",
       "      <td>- Women and Men; 18 years or more at the time ...</td>\n",
       "      <td>- Inoperable locally advanced or metastatic br...</td>\n",
       "      <td>18age old over</td>\n",
       "      <td>No limit</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>arm A: continue with SoC ET as directed by inv...</td>\n",
       "      <td>[乳がん, 早期乳がん]</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>467</th>\n",
       "      <td>jRCT2031230249</td>\n",
       "      <td>NCT05753501</td>\n",
       "      <td>NaN</td>\n",
       "      <td>[M23-647]B細胞性悪性腫瘍患者を対象としたBTK 分解誘導化合物ABBV-101 の...</td>\n",
       "      <td>血液がん</td>\n",
       "      <td>・ABBV-101 の安全性を明らかにし,忍容性を確認する\\r\\n・ABBV-101 の経口...</td>\n",
       "      <td>1</td>\n",
       "      <td>NaN</td>\n",
       "      <td>単一群</td>\n",
       "      <td>非盲検</td>\n",
       "      <td>...</td>\n",
       "      <td>treatment purpose</td>\n",
       "      <td>-For Dose Escalation (Part 1) only: Participan...</td>\n",
       "      <td>-Previously treated with a Bruton's tyrosine k...</td>\n",
       "      <td>18age old over</td>\n",
       "      <td>No limit</td>\n",
       "      <td>Both</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>Drug: ABBV-101\\r\\nOral: Tablet</td>\n",
       "      <td>[血液がん]</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>509</th>\n",
       "      <td>jRCT2031230109</td>\n",
       "      <td>NCT05514054</td>\n",
       "      <td>NaN</td>\n",
       "      <td>EMBER-4:2~5年間の術後内分泌療法による前治療歴を有する再発高リスクのER+、HER...</td>\n",
       "      <td>乳癌</td>\n",
       "      <td>早期乳癌患者を対象としたimlunestrantと標準的な内分泌療法の比較試験</td>\n",
       "      <td>3</td>\n",
       "      <td>NaN</td>\n",
       "      <td>無作為化比較</td>\n",
       "      <td>非盲検</td>\n",
       "      <td>...</td>\n",
       "      <td>treatment purpose</td>\n",
       "      <td>-Have a diagnosis of ER+, HER2- early-stage, r...</td>\n",
       "      <td>-Have any evidence of metastatic disease (incl...</td>\n",
       "      <td>18age old over</td>\n",
       "      <td>No limit</td>\n",
       "      <td>Both</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>-Drug: Imlunestrant\\r\\n  Administered orally.\\...</td>\n",
       "      <td>[乳癌]</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>514</th>\n",
       "      <td>jRCT2031230090</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>MELK阻害剤OTS167POにおける転移性・進行性乳がん患者を対象とした安全性、忍容性およ...</td>\n",
       "      <td>再発・難治性の局所進行性・転移性乳がん及びトリプルネガティブ乳がん</td>\n",
       "      <td>再発・難治性の局所進行性または転移性乳がん患者に対して、OTS167を経口カプセルで投与する...</td>\n",
       "      <td>1</td>\n",
       "      <td>NaN</td>\n",
       "      <td>単一群</td>\n",
       "      <td>非盲検</td>\n",
       "      <td>...</td>\n",
       "      <td>treatment purpose</td>\n",
       "      <td>Dose Escalation and Dose Expansion Cohorts\\r\\n...</td>\n",
       "      <td>Dose Escalation and Expansion Cohorts\\r\\n1.\\tW...</td>\n",
       "      <td>18age old over</td>\n",
       "      <td>No limit</td>\n",
       "      <td>Female</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>This is a Phase I dose escalation/expansion mu...</td>\n",
       "      <td>[再発, 難治性の局所進行性, 転移性乳がん, トリプルネガティブ乳がん]</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>515</th>\n",
       "      <td>jRCT2031230096</td>\n",
       "      <td>NCT05774951</td>\n",
       "      <td>NaN</td>\n",
       "      <td>根治的局所領域療法(化学療法の併用または非併用)および標準補助内分泌療法(ET)を少なくとも...</td>\n",
       "      <td>乳がん、早期乳がん</td>\n",
       "      <td>Treatment</td>\n",
       "      <td>3</td>\n",
       "      <td>NaN</td>\n",
       "      <td>無作為化比較</td>\n",
       "      <td>非盲検</td>\n",
       "      <td>...</td>\n",
       "      <td>treatment purpose</td>\n",
       "      <td>- Women and Men, greater than or equal to 18 y...</td>\n",
       "      <td>- Inoperable locally advanced or metastatic br...</td>\n",
       "      <td>18age old over</td>\n",
       "      <td>No limit</td>\n",
       "      <td>Both</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>arm A: continue with SoC ET as directed by inv...</td>\n",
       "      <td>[乳がん, 早期乳がん]</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>582</th>\n",
       "      <td>jRCT2051220176</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>切除不能進行再発食道がん及び胃がんに対する免疫チェックポイント阻害剤(ICI)と光線力学的療...</td>\n",
       "      <td>食道がん、胃がん</td>\n",
       "      <td>一次治療として免疫チェックポイント阻害剤(ICI)を含む標準治療を予定される進行・再発食道が...</td>\n",
       "      <td>2</td>\n",
       "      <td>NaN</td>\n",
       "      <td>単一群</td>\n",
       "      <td>非盲検</td>\n",
       "      <td>...</td>\n",
       "      <td>treatment purpose</td>\n",
       "      <td>The patient with unresectable or recurrent eso...</td>\n",
       "      <td>Has been diagnosed with HER2-positive gastric ...</td>\n",
       "      <td>18age old over</td>\n",
       "      <td>No limit</td>\n",
       "      <td>Both</td>\n",
       "      <td>NaN</td>\n",
       "      <td>Esophageal cancer, Gastric cancer</td>\n",
       "      <td>Cohort A: Nivolumab(240mg, every 2 weeks or 36...</td>\n",
       "      <td>[食道がん, 胃がん]</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>610</th>\n",
       "      <td>jRCT2061220087</td>\n",
       "      <td>NCT05629585</td>\n",
       "      <td>NaN</td>\n",
       "      <td>術前薬物療法後の外科的切除時に乳房及び/又は腋窩リンパ節に浸潤性残存病変を有するステージI~...</td>\n",
       "      <td>乳癌</td>\n",
       "      <td>術前薬物療法後の外科的切除時に乳房および/または腋窩リンパ節に浸潤性残存病変を有するI~II...</td>\n",
       "      <td>3</td>\n",
       "      <td>NaN</td>\n",
       "      <td>無作為化比較</td>\n",
       "      <td>非盲検</td>\n",
       "      <td>...</td>\n",
       "      <td>treatment purpose</td>\n",
       "      <td>Participant must be &gt;= 18 years at the time of...</td>\n",
       "      <td>Stage IV (metastatic) TNBC.\\r\\nHistory of prio...</td>\n",
       "      <td>18age old over</td>\n",
       "      <td>130age old under</td>\n",
       "      <td>Both</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>Arm 1: Dato-DXd 6 mg/kg IV Q3W x 8 cycles + Du...</td>\n",
       "      <td>[乳癌]</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>693</th>\n",
       "      <td>jRCT2031220276</td>\n",
       "      <td>NCT05307705</td>\n",
       "      <td>NaN</td>\n",
       "      <td>PIK3CA H1047R変異を有する進行乳がん患者及びその他の固形がん患者を対象としたLO...</td>\n",
       "      <td>乳がん</td>\n",
       "      <td>LOXO-783 の単独投与及び他の抗がん剤との併用投与における 第 2 相試験の推奨用量、...</td>\n",
       "      <td>1</td>\n",
       "      <td>NaN</td>\n",
       "      <td>単一群</td>\n",
       "      <td>非盲検</td>\n",
       "      <td>...</td>\n",
       "      <td>treatment purpose</td>\n",
       "      <td>-Have advanced breast cancer or another solid ...</td>\n",
       "      <td>-Medical Conditions\\r\\n -Colorectal cancer\\r\\n...</td>\n",
       "      <td>18age old over</td>\n",
       "      <td>No limit</td>\n",
       "      <td>Both</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>-Drug: LOXO-783\\r\\n Oral\\r\\n Other Name: LY384...</td>\n",
       "      <td>[乳がん]</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>708</th>\n",
       "      <td>jRCT2031220203</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>初回腫瘍減量手術肉眼的完全切除後の進行卵巣癌を対象にパクリタキセル、カルボプラチン投与後のニ...</td>\n",
       "      <td>卵巣がん</td>\n",
       "      <td>診断時にステージIIIA/B/Cの高悪性度上皮性卵巣癌で、PDS後に残存病変を認めない患者を...</td>\n",
       "      <td>2</td>\n",
       "      <td>NaN</td>\n",
       "      <td>無作為化比較</td>\n",
       "      <td>非盲検</td>\n",
       "      <td>...</td>\n",
       "      <td>treatment purpose</td>\n",
       "      <td>1. Female patient &gt;= 18 years of age.\\r\\n2. Si...</td>\n",
       "      <td>1. Patient with clear cell adenocarcinoma or c...</td>\n",
       "      <td>18age old over</td>\n",
       "      <td>No limit</td>\n",
       "      <td>Female</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>Patients will be included after surgery and wi...</td>\n",
       "      <td>[卵巣がん]</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>753</th>\n",
       "      <td>jRCT2031220034</td>\n",
       "      <td>NCT04862663</td>\n",
       "      <td>NaN</td>\n",
       "      <td>局所進行(切除不能)又は転移性のホルモン受容体陽性/ヒト上皮細胞成長因子受容体2 陰性乳癌を...</td>\n",
       "      <td>局所進行(切除不能)又は転移性乳癌</td>\n",
       "      <td>Treatment</td>\n",
       "      <td>3</td>\n",
       "      <td>NaN</td>\n",
       "      <td>無作為化比較</td>\n",
       "      <td>二重盲検</td>\n",
       "      <td>...</td>\n",
       "      <td>treatment purpose</td>\n",
       "      <td>Key inclusion criteria for both phases:\\n\\r\\n1...</td>\n",
       "      <td>Key exclusion criteria for both phases:\\r\\n1. ...</td>\n",
       "      <td>18age old over</td>\n",
       "      <td>99age old under</td>\n",
       "      <td>Both</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>Capivasertib: PO BD 4 days on /3 days off per ...</td>\n",
       "      <td>[局所進行(切除不能), 転移性乳癌]</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>802</th>\n",
       "      <td>jRCT2031210585</td>\n",
       "      <td>NCT05123482</td>\n",
       "      <td>NaN</td>\n",
       "      <td>進行又は転移性固形がん患者を対象としたAZD8205の単独療法及び他の抗がん剤との併用療法に...</td>\n",
       "      <td>乳癌、胆道癌、卵巣癌、子宮内膜癌</td>\n",
       "      <td>進行又は転移性固形がんに対する治療法候補としての新規化合物AZD8205の研究</td>\n",
       "      <td>1-2</td>\n",
       "      <td>NaN</td>\n",
       "      <td>単一群</td>\n",
       "      <td>非盲検</td>\n",
       "      <td>...</td>\n",
       "      <td>treatment purpose</td>\n",
       "      <td>- Age18 years or more\\n\\r\\n- Relapsed/metastat...</td>\n",
       "      <td>- Treatment with any of the following:\\n\\r\\n1....</td>\n",
       "      <td>18age old over</td>\n",
       "      <td>No limit</td>\n",
       "      <td>Both</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>Sub-study1\\r\\nAZD8205 Monotherapy\\r\\nAZD8205 i...</td>\n",
       "      <td>[乳癌, 胆道癌, 卵巣癌, 子宮内膜癌]</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>865</th>\n",
       "      <td>jRCT2052210099</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>乳がんを有する成人女性及び健康成人女性を対象とした乳房用マイクロ波画像診断装置IGS-000...</td>\n",
       "      <td>乳がん</td>\n",
       "      <td>本治験の目的は,乳がん又はその疑いのある者,並びに乳がん又はその疑いがない者を対象に乳房画像...</td>\n",
       "      <td>2</td>\n",
       "      <td>NaN</td>\n",
       "      <td>単一群</td>\n",
       "      <td>単盲検</td>\n",
       "      <td>...</td>\n",
       "      <td>screening</td>\n",
       "      <td>Breast cancer (including suspected) \\r\\n(1) On...</td>\n",
       "      <td>(1) There is trauma with bleeding on the breas...</td>\n",
       "      <td>20age old over</td>\n",
       "      <td>No limit</td>\n",
       "      <td>Female</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>The test using IGS-0001 will be performed twic...</td>\n",
       "      <td>[乳がん]</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>20 rows × 39 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "            JRCT ID       NCT No JapicCTI No  \\\n",
       "12   jRCT2041240130          NaN         NaN   \n",
       "59   jRCT2031240404          NaN         NaN   \n",
       "201  jRCT2052240059          NaN         NaN   \n",
       "234  jRCT2031240065          NaN         NaN   \n",
       "257  jRCT2033240023          NaN         NaN   \n",
       "271  jRCT2031230750  NCT06188559         NaN   \n",
       "279  jRCT2031230723  NCT06112379         NaN   \n",
       "311  jRCT2061230102  NCT06103864         NaN   \n",
       "396  jRCT2061230074  NCT05952557         NaN   \n",
       "467  jRCT2031230249  NCT05753501         NaN   \n",
       "509  jRCT2031230109  NCT05514054         NaN   \n",
       "514  jRCT2031230090          NaN         NaN   \n",
       "515  jRCT2031230096  NCT05774951         NaN   \n",
       "582  jRCT2051220176          NaN         NaN   \n",
       "610  jRCT2061220087  NCT05629585         NaN   \n",
       "693  jRCT2031220276  NCT05307705         NaN   \n",
       "708  jRCT2031220203          NaN         NaN   \n",
       "753  jRCT2031220034  NCT04862663         NaN   \n",
       "802  jRCT2031210585  NCT05123482         NaN   \n",
       "865  jRCT2052210099          NaN         NaN   \n",
       "\n",
       "                                                 Title  \\\n",
       "12   中等度-高度PONV発症リスクを有する肺切除術予定患者の周術期管理におけるGranisetr...   \n",
       "59   転移性HR+/HER2-乳がん及びその他の進行性固形がん患者を対象にCDK4阻害剤BGB-4...   \n",
       "201  遺伝子HSD17B4高メチル化を有するHER2陽性ER陰性乳癌における非手術療法の有用性を評...   \n",
       "234  DNAミスマッチ修復機構欠損を有する進行性・転移性子宮体がん患者を対象に、一次治療として化学...   \n",
       "257  免疫チェックポイント阻害剤に対してacquired resistanceとなったがん患者を対...   \n",
       "271  治療歴のある HER2 陽性又は HER2 低発現の切除不能又は転移性乳癌の被験者を対象に,...   \n",
       "279  未治療のトリプルネガティブ又はホルモン受容体低発現/HER2陰性乳癌の成人患者を対象として、...   \n",
       "311  Programmed death-ligand(PD-L1)陽性の局所再発手術不能又は転移性...   \n",
       "396  根治的局所治療(化学療法の併用または非併用)を受けて疾患の兆候のない、再発リスクが中間~高リ...   \n",
       "467  [M23-647]B細胞性悪性腫瘍患者を対象としたBTK 分解誘導化合物ABBV-101 の...   \n",
       "509  EMBER-4:2~5年間の術後内分泌療法による前治療歴を有する再発高リスクのER+、HER...   \n",
       "514  MELK阻害剤OTS167POにおける転移性・進行性乳がん患者を対象とした安全性、忍容性およ...   \n",
       "515  根治的局所領域療法(化学療法の併用または非併用)および標準補助内分泌療法(ET)を少なくとも...   \n",
       "582  切除不能進行再発食道がん及び胃がんに対する免疫チェックポイント阻害剤(ICI)と光線力学的療...   \n",
       "610  術前薬物療法後の外科的切除時に乳房及び/又は腋窩リンパ節に浸潤性残存病変を有するステージI~...   \n",
       "693  PIK3CA H1047R変異を有する進行乳がん患者及びその他の固形がん患者を対象としたLO...   \n",
       "708  初回腫瘍減量手術肉眼的完全切除後の進行卵巣癌を対象にパクリタキセル、カルボプラチン投与後のニ...   \n",
       "753  局所進行(切除不能)又は転移性のホルモン受容体陽性/ヒト上皮細胞成長因子受容体2 陰性乳癌を...   \n",
       "802  進行又は転移性固形がん患者を対象としたAZD8205の単独療法及び他の抗がん剤との併用療法に...   \n",
       "865  乳がんを有する成人女性及び健康成人女性を対象とした乳房用マイクロ波画像診断装置IGS-000...   \n",
       "\n",
       "                                                Target  \\\n",
       "12                                                 肺がん   \n",
       "59   ・進行性固形腫瘍・進行性乳がん・転移性乳がん・ホルモン受容体陽性乳がん・ホルモン受容体陽性乳...   \n",
       "201                                                乳がん   \n",
       "234                                              子宮体がん   \n",
       "257                                  肺がん、食道がん、胃癌等の固形がん   \n",
       "271                     HER2 陽性又は HER2 低発現の切除不能又は転移性乳癌   \n",
       "279                                                 乳癌   \n",
       "311                                                 乳癌   \n",
       "396                                          乳がん、早期乳がん   \n",
       "467                                               血液がん   \n",
       "509                                                 乳癌   \n",
       "514                  再発・難治性の局所進行性・転移性乳がん及びトリプルネガティブ乳がん   \n",
       "515                                          乳がん、早期乳がん   \n",
       "582                                           食道がん、胃がん   \n",
       "610                                                 乳癌   \n",
       "693                                                乳がん   \n",
       "708                                               卵巣がん   \n",
       "753                                  局所進行(切除不能)又は転移性乳癌   \n",
       "802                                   乳癌、胆道癌、卵巣癌、子宮内膜癌   \n",
       "865                                                乳がん   \n",
       "\n",
       "                                              研究・治験の目的 試験等のフェーズ 試験の種類  \\\n",
       "12   全身麻酔を要する肺切除術周術期における標準制吐療法であるグラニセトロン(Granisetro...        2   NaN   \n",
       "59   サイクリン依存性キナーゼ 4 (CDK4) 阻害剤である BGB-43395 が、ホルモン受...        1   NaN   \n",
       "201  HSD17B4高メチル化(HSD17B4 hypermethylation:HH)を有するH...        2   NaN   \n",
       "234  dMMR/MSI-Hを有する再発又は進行子宮体癌患者を対象にdostarlimabの有効性及...        3   NaN   \n",
       "257  免疫チェックポイント阻害剤に対してacquired resistanceとなったがん患者(非...      1-2   NaN   \n",
       "271                                                 治療        2   NaN   \n",
       "279  未治療のトリプルネガティブ又はホルモン受容体低発現/HER2陰性乳癌の成人患者を対象として、...        3   NaN   \n",
       "311  PD-L1陽性の局所再発手術不能または転移性TNBC患者を対象に、デュルバルマブ併用または非...        3   NaN   \n",
       "396                                          Treatment        3   NaN   \n",
       "467  ・ABBV-101 の安全性を明らかにし,忍容性を確認する\\r\\n・ABBV-101 の経口...        1   NaN   \n",
       "509            早期乳癌患者を対象としたimlunestrantと標準的な内分泌療法の比較試験        3   NaN   \n",
       "514  再発・難治性の局所進行性または転移性乳がん患者に対して、OTS167を経口カプセルで投与する...        1   NaN   \n",
       "515                                          Treatment        3   NaN   \n",
       "582  一次治療として免疫チェックポイント阻害剤(ICI)を含む標準治療を予定される進行・再発食道が...        2   NaN   \n",
       "610  術前薬物療法後の外科的切除時に乳房および/または腋窩リンパ節に浸潤性残存病変を有するI~II...        3   NaN   \n",
       "693  LOXO-783 の単独投与及び他の抗がん剤との併用投与における 第 2 相試験の推奨用量、...        1   NaN   \n",
       "708  診断時にステージIIIA/B/Cの高悪性度上皮性卵巣癌で、PDS後に残存病変を認めない患者を...        2   NaN   \n",
       "753                                          Treatment        3   NaN   \n",
       "802            進行又は転移性固形がんに対する治療法候補としての新規化合物AZD8205の研究      1-2   NaN   \n",
       "865  本治験の目的は,乳がん又はその疑いのある者,並びに乳がん又はその疑いがない者を対象に乳房画像...        2   NaN   \n",
       "\n",
       "        無作為化   盲検化  ...             purpose  \\\n",
       "12    無作為化比較   非盲検  ...   treatment purpose   \n",
       "59   非無作為化比較   非盲検  ...   treatment purpose   \n",
       "201      単一群   非盲検  ...  diagnostic purpose   \n",
       "234   無作為化比較   非盲検  ...   treatment purpose   \n",
       "257      単一群   非盲検  ...   treatment purpose   \n",
       "271   無作為化比較   非盲検  ...   treatment purpose   \n",
       "279   無作為化比較   非盲検  ...   treatment purpose   \n",
       "311   無作為化比較   非盲検  ...   treatment purpose   \n",
       "396   無作為化比較   非盲検  ...   treatment purpose   \n",
       "467      単一群   非盲検  ...   treatment purpose   \n",
       "509   無作為化比較   非盲検  ...   treatment purpose   \n",
       "514      単一群   非盲検  ...   treatment purpose   \n",
       "515   無作為化比較   非盲検  ...   treatment purpose   \n",
       "582      単一群   非盲検  ...   treatment purpose   \n",
       "610   無作為化比較   非盲検  ...   treatment purpose   \n",
       "693      単一群   非盲検  ...   treatment purpose   \n",
       "708   無作為化比較   非盲検  ...   treatment purpose   \n",
       "753   無作為化比較  二重盲検  ...   treatment purpose   \n",
       "802      単一群   非盲検  ...   treatment purpose   \n",
       "865      単一群   単盲検  ...           screening   \n",
       "\n",
       "                                    Inclusion Criteria  \\\n",
       "12   (1) Patients scheduled to undergo anatomical l...   \n",
       "59   -Phase 1a (Dose Escalation) and 1b (Dose Expan...   \n",
       "201  1. Histologically confirmed invasive breast ca...   \n",
       "234  1. Female patient is at least 18 years of age,...   \n",
       "257  1. Japanese patients aged 20 years or older at...   \n",
       "271  (1) Male or female, aged >=18 years at the tim...   \n",
       "279  1. Participant must be >= 18 years at the time...   \n",
       "311  Histologically or cytologically documented loc...   \n",
       "396  - Women and Men; 18 years or more at the time ...   \n",
       "467  -For Dose Escalation (Part 1) only: Participan...   \n",
       "509  -Have a diagnosis of ER+, HER2- early-stage, r...   \n",
       "514  Dose Escalation and Dose Expansion Cohorts\\r\\n...   \n",
       "515  - Women and Men, greater than or equal to 18 y...   \n",
       "582  The patient with unresectable or recurrent eso...   \n",
       "610  Participant must be >= 18 years at the time of...   \n",
       "693  -Have advanced breast cancer or another solid ...   \n",
       "708  1. Female patient >= 18 years of age.\\r\\n2. Si...   \n",
       "753  Key inclusion criteria for both phases:\\n\\r\\n1...   \n",
       "802  - Age18 years or more\\n\\r\\n- Relapsed/metastat...   \n",
       "865  Breast cancer (including suspected) \\r\\n(1) On...   \n",
       "\n",
       "                                    Exclusion Criteria     Age Minimum  \\\n",
       "12   (1) Patients with a history of allergy to the ...  18age old over   \n",
       "59   -Prior therapy selectively targeting CDK4 (pri...  18age old over   \n",
       "201  1. History of other malignancy within the last...  20age old over   \n",
       "234  1. Patient has received neoadjuvant/adjuvant s...  18age old over   \n",
       "257  1. Patients with a history of severe drug hype...  20age old over   \n",
       "271  (1) Presence of brain or subdural metastases, ...  18age old over   \n",
       "279  1. As judged by the investigator, any evidence...  18age old over   \n",
       "311  As judged by investigator, severe or uncontrol...  18age old over   \n",
       "396  - Inoperable locally advanced or metastatic br...  18age old over   \n",
       "467  -Previously treated with a Bruton's tyrosine k...  18age old over   \n",
       "509  -Have any evidence of metastatic disease (incl...  18age old over   \n",
       "514  Dose Escalation and Expansion Cohorts\\r\\n1.\\tW...  18age old over   \n",
       "515  - Inoperable locally advanced or metastatic br...  18age old over   \n",
       "582  Has been diagnosed with HER2-positive gastric ...  18age old over   \n",
       "610  Stage IV (metastatic) TNBC.\\r\\nHistory of prio...  18age old over   \n",
       "693  -Medical Conditions\\r\\n -Colorectal cancer\\r\\n...  18age old over   \n",
       "708  1. Patient with clear cell adenocarcinoma or c...  18age old over   \n",
       "753  Key exclusion criteria for both phases:\\r\\n1. ...  18age old over   \n",
       "802  - Treatment with any of the following:\\n\\r\\n1....  18age old over   \n",
       "865  (1) There is trauma with bleeding on the breas...  20age old over   \n",
       "\n",
       "          Age Maximum  Gender Discontinuation Criteria  \\\n",
       "12           No limit    Both                      NaN   \n",
       "59           No limit    Both                      NaN   \n",
       "201          No limit  Female                      NaN   \n",
       "234          No limit  Female                      NaN   \n",
       "257          No limit    Both                      NaN   \n",
       "271          No limit    Both                      NaN   \n",
       "279          No limit    Both                      NaN   \n",
       "311          No limit    Both                      NaN   \n",
       "396          No limit     NaN                      NaN   \n",
       "467          No limit    Both                      NaN   \n",
       "509          No limit    Both                      NaN   \n",
       "514          No limit  Female                      NaN   \n",
       "515          No limit    Both                      NaN   \n",
       "582          No limit    Both                      NaN   \n",
       "610  130age old under    Both                      NaN   \n",
       "693          No limit    Both                      NaN   \n",
       "708          No limit  Female                      NaN   \n",
       "753   99age old under    Both                      NaN   \n",
       "802          No limit    Both                      NaN   \n",
       "865          No limit  Female                      NaN   \n",
       "\n",
       "                               Keyword  \\\n",
       "12                                 NaN   \n",
       "59                                 NaN   \n",
       "201                                NaN   \n",
       "234                                NaN   \n",
       "257                                NaN   \n",
       "271                                NaN   \n",
       "279                                NaN   \n",
       "311                                NaN   \n",
       "396                                NaN   \n",
       "467                                NaN   \n",
       "509                                NaN   \n",
       "514                                NaN   \n",
       "515                                NaN   \n",
       "582  Esophageal cancer, Gastric cancer   \n",
       "610                                NaN   \n",
       "693                                NaN   \n",
       "708                                NaN   \n",
       "753                                NaN   \n",
       "802                                NaN   \n",
       "865                                NaN   \n",
       "\n",
       "                                       Intervention(s)  \\\n",
       "12   Treatment group\\r\\nAdminister GRA 1mg intraven...   \n",
       "59   -Drug: BGB-43395\\r\\nPlanned doses administered...   \n",
       "201  Omitting breast surgery after preoperative che...   \n",
       "234  Patients will be randomized 1:1 to receive eit...   \n",
       "257  Intramuscular injection of the investigational...   \n",
       "271  Generic Name:NA\\r\\nStudy Treatment in dose opt...   \n",
       "279  - Experimental arm: Dato-DXd plus durvalumab n...   \n",
       "311  Arm 1: Dato-DXd + durvalumab\\r\\nArm 2: Investi...   \n",
       "396  arm A: continue with SoC ET as directed by inv...   \n",
       "467                     Drug: ABBV-101\\r\\nOral: Tablet   \n",
       "509  -Drug: Imlunestrant\\r\\n  Administered orally.\\...   \n",
       "514  This is a Phase I dose escalation/expansion mu...   \n",
       "515  arm A: continue with SoC ET as directed by inv...   \n",
       "582  Cohort A: Nivolumab(240mg, every 2 weeks or 36...   \n",
       "610  Arm 1: Dato-DXd 6 mg/kg IV Q3W x 8 cycles + Du...   \n",
       "693  -Drug: LOXO-783\\r\\n Oral\\r\\n Other Name: LY384...   \n",
       "708  Patients will be included after surgery and wi...   \n",
       "753  Capivasertib: PO BD 4 days on /3 days off per ...   \n",
       "802  Sub-study1\\r\\nAZD8205 Monotherapy\\r\\nAZD8205 i...   \n",
       "865  The test using IGS-0001 will be performed twic...   \n",
       "\n",
       "                                            TargetWord  \n",
       "12                                               [肺がん]  \n",
       "59   [進行性固形腫瘍, 進行性乳がん, 転移性乳がん, ホルモン受容体陽性乳がん, ホルモン受容...  \n",
       "201                                              [乳がん]  \n",
       "234                                            [子宮体がん]  \n",
       "257                              [肺がん, 食道がん, 胃癌等の固形がん]  \n",
       "271                    [HER2 陽性, HER2 低発現の切除不能, 転移性乳癌]  \n",
       "279                                               [乳癌]  \n",
       "311                                               [乳癌]  \n",
       "396                                       [乳がん, 早期乳がん]  \n",
       "467                                             [血液がん]  \n",
       "509                                               [乳癌]  \n",
       "514              [再発, 難治性の局所進行性, 転移性乳がん, トリプルネガティブ乳がん]  \n",
       "515                                       [乳がん, 早期乳がん]  \n",
       "582                                        [食道がん, 胃がん]  \n",
       "610                                               [乳癌]  \n",
       "693                                              [乳がん]  \n",
       "708                                             [卵巣がん]  \n",
       "753                                [局所進行(切除不能), 転移性乳癌]  \n",
       "802                              [乳癌, 胆道癌, 卵巣癌, 子宮内膜癌]  \n",
       "865                                              [乳がん]  \n",
       "\n",
       "[20 rows x 39 columns]"
      ]
     },
     "execution_count": 68,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# ターゲットリスト全体を処理\n",
    "matched_indices = []\n",
    "target_vecs_list = []\n",
    "cosine_scores_list = []\n",
    "for idx, target_words in enumerate(basedf['TargetWord']):\n",
    "    # ターゲット内の各単語をベクトル化\n",
    "    target_vecs = encode_text(target_words)\n",
    "    # コサイン類似度を計算\n",
    "    cosine_scores = torch.nn.functional.cosine_similarity(query_vec, target_vecs)\n",
    "    target_vecs_list.append(target_vecs)\n",
    "    cosine_scores_list.append(cosine_scores)\n",
    "    # 閾値を超えるか確認\n",
    "    if (cosine_scores >= threshold).any():  # いずれかが閾値を超えている場合\n",
    "        matched_indices.append(idx)\n",
    "\n",
    "# 抽出\n",
    "matched_df = basedf.iloc[matched_indices]\n",
    "matched_df"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 69,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[tensor([0.8485]),\n",
       " tensor([0.8322, 0.8710]),\n",
       " tensor([0.8630]),\n",
       " tensor([0.8748, 0.8663]),\n",
       " tensor([0.9373]),\n",
       " tensor([0.8615, 0.8576]),\n",
       " tensor([0.8443]),\n",
       " tensor([0.8511]),\n",
       " tensor([0.8320, 0.8452]),\n",
       " tensor([0.8485]),\n",
       " tensor([0.8681]),\n",
       " tensor([0.8585]),\n",
       " tensor([0.8489]),\n",
       " tensor([0.8535]),\n",
       " tensor([0.9058]),\n",
       " tensor([0.8473, 0.9020]),\n",
       " tensor([0.8587]),\n",
       " tensor([0.8621]),\n",
       " tensor([0.8526]),\n",
       " tensor([0.8363]),\n",
       " tensor([0.8573]),\n",
       " tensor([0.7646, 0.7990]),\n",
       " tensor([0.9068, 0.8733, 0.8775]),\n",
       " tensor([0.8584]),\n",
       " tensor([0.8584]),\n",
       " tensor([0.8624]),\n",
       " tensor([0.8456]),\n",
       " tensor([0.8959]),\n",
       " tensor([0.8844]),\n",
       " tensor([0.8842, 0.9356, 0.9305, 0.9065, 0.8970]),\n",
       " tensor([0.8691, 0.8630, 0.8718]),\n",
       " tensor([0.8758]),\n",
       " tensor([0.8630]),\n",
       " tensor([0.8611]),\n",
       " tensor([0.8630]),\n",
       " tensor([0.8963]),\n",
       " tensor([0.8601]),\n",
       " tensor([0.8040, 0.8439]),\n",
       " tensor([0.8789, 0.8568]),\n",
       " tensor([0.8110, 0.8643, 0.8400, 0.9012]),\n",
       " tensor([0.8604]),\n",
       " tensor([0.8752, 0.8826, 0.8916, 0.8565]),\n",
       " tensor([0.9091, 0.8941, 0.8630]),\n",
       " tensor([0.8391, 0.8505]),\n",
       " tensor([0.8625]),\n",
       " tensor([0.8507]),\n",
       " tensor([0.8583, 0.8685]),\n",
       " tensor([0.8758]),\n",
       " tensor([0.8597]),\n",
       " tensor([0.8707]),\n",
       " tensor([0.8908]),\n",
       " tensor([0.8480]),\n",
       " tensor([0.8567]),\n",
       " tensor([0.8752, 0.8763, 0.8826]),\n",
       " tensor([0.8630]),\n",
       " tensor([0.8497]),\n",
       " tensor([0.8395, 0.8532, 0.7941, 0.8583]),\n",
       " tensor([0.8630]),\n",
       " tensor([0.8254, 0.8873]),\n",
       " tensor([0.8758]),\n",
       " tensor([0.8806]),\n",
       " tensor([0.8152, 0.8277, 0.8346, 0.8746]),\n",
       " tensor([0.8478]),\n",
       " tensor([0.8758]),\n",
       " tensor([0.8781]),\n",
       " tensor([0.8615]),\n",
       " tensor([0.8446, 0.8641]),\n",
       " tensor([0.8733]),\n",
       " tensor([0.8507]),\n",
       " tensor([0.8584]),\n",
       " tensor([0.8630]),\n",
       " tensor([0.8545]),\n",
       " tensor([0.8819]),\n",
       " tensor([0.8969, 0.8613, 0.8482, 0.8693, 0.8598]),\n",
       " tensor([0.8688]),\n",
       " tensor([0.8625]),\n",
       " tensor([0.8455, 0.8619]),\n",
       " tensor([0.8788]),\n",
       " tensor([0.8540]),\n",
       " tensor([0.8625]),\n",
       " tensor([0.8630]),\n",
       " tensor([0.8664]),\n",
       " tensor([0.8630]),\n",
       " tensor([0.8459, 0.8211, 0.8484]),\n",
       " tensor([0.8508, 0.8430, 0.8313, 0.8702]),\n",
       " tensor([0.8469]),\n",
       " tensor([0.9016]),\n",
       " tensor([0.8630]),\n",
       " tensor([0.8379]),\n",
       " tensor([0.8558, 0.8561, 0.8513]),\n",
       " tensor([0.8582, 0.8528]),\n",
       " tensor([0.8582]),\n",
       " tensor([0.8536]),\n",
       " tensor([0.8804, 0.8691, 0.8711]),\n",
       " tensor([0.8377, 0.8560, 0.8276]),\n",
       " tensor([0.8604]),\n",
       " tensor([0.8301, 0.8577]),\n",
       " tensor([0.8410]),\n",
       " tensor([0.8664]),\n",
       " tensor([0.8473, 0.8524, 0.8974]),\n",
       " tensor([0.8473, 0.8524, 0.8974]),\n",
       " tensor([1.]),\n",
       " tensor([0.8547]),\n",
       " tensor([0.8540]),\n",
       " tensor([0.8630]),\n",
       " tensor([0.8615, 0.8576, 0.8696]),\n",
       " tensor([0.9083, 0.8155, 0.8555, 0.8375, 0.8585]),\n",
       " tensor([0.8624, 0.8528]),\n",
       " tensor([0.8630]),\n",
       " tensor([0.8584]),\n",
       " tensor([0.8347]),\n",
       " tensor([0.8630]),\n",
       " tensor([0.8526]),\n",
       " tensor([0.9058]),\n",
       " tensor([0.8624]),\n",
       " tensor([0.8597]),\n",
       " tensor([0.8752, 0.8763, 0.8826]),\n",
       " tensor([0.8305, 0.8894]),\n",
       " tensor([0.9246]),\n",
       " tensor([0.8630]),\n",
       " tensor([0.8611]),\n",
       " tensor([0.9068, 0.8908]),\n",
       " tensor([0.8708]),\n",
       " tensor([0.8587]),\n",
       " tensor([0.8347]),\n",
       " tensor([0.8959]),\n",
       " tensor([0.8711]),\n",
       " tensor([0.8711]),\n",
       " tensor([0.8388, 0.8499]),\n",
       " tensor([0.9373, 0.9130, 0.8716]),\n",
       " tensor([0.8913, 0.8613, 0.8677, 0.8699, 0.8787, 0.8538, 0.8325]),\n",
       " tensor([0.8540]),\n",
       " tensor([0.8514]),\n",
       " tensor([0.8388, 0.8499]),\n",
       " tensor([0.8457, 0.8334, 0.9242]),\n",
       " tensor([0.8758]),\n",
       " tensor([0.8959]),\n",
       " tensor([0.8841]),\n",
       " tensor([0.9522]),\n",
       " tensor([0.8630]),\n",
       " tensor([0.8584]),\n",
       " tensor([0.8604]),\n",
       " tensor([0.8525]),\n",
       " tensor([0.8535]),\n",
       " tensor([0.8662]),\n",
       " tensor([0.8639]),\n",
       " tensor([0.8466, 0.8730]),\n",
       " tensor([0.8337, 0.9098]),\n",
       " tensor([0.8670]),\n",
       " tensor([0.8577]),\n",
       " tensor([0.8863, 0.8752]),\n",
       " tensor([0.8630]),\n",
       " tensor([0.8315, 0.8696]),\n",
       " tensor([0.8362, 0.9098]),\n",
       " tensor([0.8380]),\n",
       " tensor([0.8540]),\n",
       " tensor([0.9522]),\n",
       " tensor([0.8908]),\n",
       " tensor([0.8305, 0.8000, 0.8520]),\n",
       " tensor([0.8540]),\n",
       " tensor([0.8673]),\n",
       " tensor([0.8593]),\n",
       " tensor([0.8604]),\n",
       " tensor([0.8203, 0.8343, 0.7933]),\n",
       " tensor([0.8391, 0.8621]),\n",
       " tensor([0.8368, 0.8635]),\n",
       " tensor([0.8365, 0.8518, 0.8365, 0.8411]),\n",
       " tensor([0.8391, 0.8505]),\n",
       " tensor([0.8540]),\n",
       " tensor([0.8536, 0.8536]),\n",
       " tensor([0.8248, 0.7948, 0.8418, 0.8342, 0.8219]),\n",
       " tensor([0.8521]),\n",
       " tensor([0.8106, 0.8684]),\n",
       " tensor([0.8510]),\n",
       " tensor([0.8446]),\n",
       " tensor([0.8541, 0.8603]),\n",
       " tensor([0.8789, 0.8576, 0.8710]),\n",
       " tensor([0.8631]),\n",
       " tensor([0.8510]),\n",
       " tensor([0.8523]),\n",
       " tensor([0.8423]),\n",
       " tensor([0.8908]),\n",
       " tensor([0.8540]),\n",
       " tensor([0.8376, 0.8768]),\n",
       " tensor([0.8051, 0.8686]),\n",
       " tensor([0.8630]),\n",
       " tensor([0.8630, 0.8839]),\n",
       " tensor([0.8604]),\n",
       " tensor([0.8051]),\n",
       " tensor([0.8688]),\n",
       " tensor([0.8562]),\n",
       " tensor([0.8562, 0.8553, 0.8430, 0.8563]),\n",
       " tensor([0.8586]),\n",
       " tensor([0.8458, 0.8616]),\n",
       " tensor([0.8375, 0.8453]),\n",
       " tensor([0.8540]),\n",
       " tensor([0.8603, 0.8568, 0.8696]),\n",
       " tensor([0.8450]),\n",
       " tensor([0.8371, 0.8642, 0.8535]),\n",
       " tensor([0.8417, 0.8689]),\n",
       " tensor([0.9093]),\n",
       " tensor([0.8728]),\n",
       " tensor([0.9990, 0.9460]),\n",
       " tensor([0.8443, 0.8873]),\n",
       " tensor([0.8759]),\n",
       " tensor([0.8752]),\n",
       " tensor([0.8440]),\n",
       " tensor([0.7623, 0.8737, 0.8236, 0.8576, 0.8696, 0.8687]),\n",
       " tensor([0.8630]),\n",
       " tensor([0.8314, 0.8953]),\n",
       " tensor([0.8388, 0.8499]),\n",
       " tensor([0.8360, 0.8724]),\n",
       " tensor([0.8303, 0.8760, 0.8303, 0.8781, 0.8303, 0.8612]),\n",
       " tensor([0.8384, 0.8511]),\n",
       " tensor([0.8391, 0.8590]),\n",
       " tensor([0.8247, 0.8847, 0.8139, 0.8356]),\n",
       " tensor([0.8628]),\n",
       " tensor([0.8732, 0.8518, 0.7789]),\n",
       " tensor([0.8204, 0.8629]),\n",
       " tensor([0.8384, 0.7728, 0.8089, 0.8722]),\n",
       " tensor([0.8061, 0.8273]),\n",
       " tensor([0.8435]),\n",
       " tensor([0.8344, 0.8426, 0.8477]),\n",
       " tensor([0.8838, 0.8694]),\n",
       " tensor([0.8535]),\n",
       " tensor([0.8411]),\n",
       " tensor([0.8804]),\n",
       " tensor([0.8485]),\n",
       " tensor([0.8155, 0.8625]),\n",
       " tensor([0.8511, 0.8162, 0.8280, 0.8599, 0.8879]),\n",
       " tensor([0.8422, 0.7904, 0.8108, 0.8225]),\n",
       " tensor([0.8901]),\n",
       " tensor([0.8508]),\n",
       " tensor([0.8806, 0.8688]),\n",
       " tensor([0.8786]),\n",
       " tensor([0.9182]),\n",
       " tensor([0.8405]),\n",
       " tensor([0.8563]),\n",
       " tensor([0.8630]),\n",
       " tensor([0.8495]),\n",
       " tensor([0.8110, 0.8427, 0.8705]),\n",
       " tensor([0.8525]),\n",
       " tensor([0.8106, 0.8752]),\n",
       " tensor([0.8688]),\n",
       " tensor([0.8604]),\n",
       " tensor([0.8540]),\n",
       " tensor([0.8540]),\n",
       " tensor([0.8809]),\n",
       " tensor([0.8789, 0.8576, 0.8790, 0.8781]),\n",
       " tensor([0.8525]),\n",
       " tensor([0.8846]),\n",
       " tensor([0.9068]),\n",
       " tensor([0.8602, 0.8571, 0.8578, 0.8484]),\n",
       " tensor([0.8347]),\n",
       " tensor([0.8501, 0.9079]),\n",
       " tensor([0.9522]),\n",
       " tensor([0.8107, 0.8577]),\n",
       " tensor([0.8938, 0.8839, 0.8568]),\n",
       " tensor([0.8391, 0.8348, 0.9305, 0.9071]),\n",
       " tensor([0.9990, 0.9460]),\n",
       " tensor([0.8587, 0.8379, 0.8649]),\n",
       " tensor([0.8540]),\n",
       " tensor([0.8604]),\n",
       " tensor([0.8264, 0.8635, 0.8576]),\n",
       " tensor([0.8264]),\n",
       " tensor([0.9071]),\n",
       " tensor([0.8395]),\n",
       " tensor([0.8179, 0.8403]),\n",
       " tensor([0.8630]),\n",
       " tensor([0.8540]),\n",
       " tensor([0.8409, 0.8956]),\n",
       " tensor([0.8602, 0.8630, 0.8836]),\n",
       " tensor([0.8908]),\n",
       " tensor([0.9068]),\n",
       " tensor([0.8309, 0.8598]),\n",
       " tensor([0.8576, 0.8500]),\n",
       " tensor([0.8625]),\n",
       " tensor([0.8804]),\n",
       " tensor([0.8359, 0.8612, 0.8127]),\n",
       " tensor([0.8163, 0.8752]),\n",
       " tensor([0.8806]),\n",
       " tensor([0.9118, 0.9205]),\n",
       " tensor([0.8786]),\n",
       " tensor([0.8577]),\n",
       " tensor([0.8506]),\n",
       " tensor([0.8201, 0.8684]),\n",
       " tensor([0.8499]),\n",
       " tensor([0.8391, 0.8505]),\n",
       " tensor([0.8604]),\n",
       " tensor([0.8535]),\n",
       " tensor([0.9522]),\n",
       " tensor([0.8773]),\n",
       " tensor([0.8280]),\n",
       " tensor([0.8488]),\n",
       " tensor([0.8540]),\n",
       " tensor([0.8459]),\n",
       " tensor([0.8514, 0.8533]),\n",
       " tensor([0.8249, 0.8579]),\n",
       " tensor([0.8510]),\n",
       " tensor([0.8597, 0.8345, 0.9077, 0.8147, 0.8507]),\n",
       " tensor([0.8188, 0.8284]),\n",
       " tensor([0.8393]),\n",
       " tensor([0.8322, 0.8710]),\n",
       " tensor([0.8630]),\n",
       " tensor([0.8823]),\n",
       " tensor([0.8659]),\n",
       " tensor([0.8630]),\n",
       " tensor([0.8630]),\n",
       " tensor([0.8907, 0.8770, 0.8625, 0.9053, 0.8711, 0.8543, 0.8684]),\n",
       " tensor([0.8658]),\n",
       " tensor([0.8503, 0.8373]),\n",
       " tensor([0.8517]),\n",
       " tensor([0.8630]),\n",
       " tensor([0.8540]),\n",
       " tensor([0.8365, 0.7996, 0.8437, 0.8365, 0.7996, 0.8523]),\n",
       " tensor([0.8804]),\n",
       " tensor([0.8908]),\n",
       " tensor([0.8604]),\n",
       " tensor([0.8649, 0.8198, 0.8309]),\n",
       " tensor([0.8733]),\n",
       " tensor([1.]),\n",
       " tensor([0.8749]),\n",
       " tensor([0.8733, 0.8395, 0.8583]),\n",
       " tensor([0.8806]),\n",
       " tensor([0.9128]),\n",
       " tensor([0.8630]),\n",
       " tensor([0.8540]),\n",
       " tensor([0.8552]),\n",
       " tensor([0.8908]),\n",
       " tensor([0.8577]),\n",
       " tensor([0.8604]),\n",
       " tensor([0.8463, 0.8154, 0.8398, 0.8542, 0.8673, 0.8961]),\n",
       " tensor([0.8551, 0.9088]),\n",
       " tensor([0.8841]),\n",
       " tensor([0.8358]),\n",
       " tensor([0.8806]),\n",
       " tensor([0.8789, 0.8576]),\n",
       " tensor([0.8630]),\n",
       " tensor([0.8232, 0.9240]),\n",
       " tensor([0.8584]),\n",
       " tensor([0.8242]),\n",
       " tensor([0.8471]),\n",
       " tensor([0.8499]),\n",
       " tensor([0.8526]),\n",
       " tensor([0.8513, 0.8181, 0.8358, 0.8695]),\n",
       " tensor([0.8433]),\n",
       " tensor([0.8630]),\n",
       " tensor([0.8789, 0.8576]),\n",
       " tensor([0.8405]),\n",
       " tensor([0.8584]),\n",
       " tensor([0.8580]),\n",
       " tensor([0.8496]),\n",
       " tensor([0.8540]),\n",
       " tensor([0.8434, 0.8146, 0.8664]),\n",
       " tensor([0.8375, 0.8562]),\n",
       " tensor([0.8319, 0.8758]),\n",
       " tensor([0.8725, 0.8489, 0.8651]),\n",
       " tensor([0.9505, 0.8707, 0.9088, 0.8914]),\n",
       " tensor([0.8604]),\n",
       " tensor([0.8315, 0.8696]),\n",
       " tensor([0.8535]),\n",
       " tensor([0.8290, 0.8370]),\n",
       " tensor([0.8908]),\n",
       " tensor([0.8182, 0.8864, 0.8526]),\n",
       " tensor([0.8841]),\n",
       " tensor([0.8685]),\n",
       " tensor([0.8106, 0.8752]),\n",
       " tensor([0.8770]),\n",
       " tensor([0.8430, 0.8630, 0.8430, 0.8706, 0.8430, 0.8658]),\n",
       " tensor([0.8265]),\n",
       " tensor([0.8526]),\n",
       " tensor([0.8559]),\n",
       " tensor([0.8161, 0.8664]),\n",
       " tensor([0.8586]),\n",
       " tensor([1.]),\n",
       " tensor([0.8256, 0.8344]),\n",
       " tensor([0.8712, 0.8568]),\n",
       " tensor([0.8467]),\n",
       " tensor([0.8604]),\n",
       " tensor([0.8669, 0.8661]),\n",
       " tensor([0.8630, 0.8427, 0.8530, 0.8497, 0.8509, 0.8302]),\n",
       " tensor([0.8336, 0.8468, 0.8465]),\n",
       " tensor([0.8380, 0.8434, 0.8507]),\n",
       " tensor([0.8220, 0.8638]),\n",
       " tensor([0.8623]),\n",
       " tensor([0.8540]),\n",
       " tensor([0.8758]),\n",
       " tensor([0.8375, 0.8453]),\n",
       " tensor([0.8776]),\n",
       " tensor([0.8584]),\n",
       " tensor([0.8583, 0.8142]),\n",
       " tensor([0.7930, 0.7781, 0.8385]),\n",
       " tensor([0.8479]),\n",
       " tensor([0.8923, 0.8914, 0.7692, 0.8157]),\n",
       " tensor([0.8373, 0.8890]),\n",
       " tensor([0.8785]),\n",
       " tensor([0.8584]),\n",
       " tensor([0.8405]),\n",
       " tensor([0.8159, 0.8669]),\n",
       " tensor([0.8381, 0.8489]),\n",
       " tensor([0.8450]),\n",
       " tensor([0.8347]),\n",
       " tensor([0.8554]),\n",
       " tensor([0.8535, 0.8582]),\n",
       " tensor([0.8536]),\n",
       " tensor([0.8561]),\n",
       " tensor([0.8540]),\n",
       " tensor([0.8914]),\n",
       " tensor([0.8101, 0.8767, 0.8590, 0.8398]),\n",
       " tensor([0.8797]),\n",
       " tensor([0.8584]),\n",
       " tensor([0.8615, 0.8568, 0.8696]),\n",
       " tensor([0.8419]),\n",
       " tensor([0.8385]),\n",
       " tensor([0.8662]),\n",
       " tensor([0.8648])]"
      ]
     },
     "execution_count": 69,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "cosine_scores_list"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 70,
   "metadata": {},
   "outputs": [],
   "source": [
    "# 全データのターゲット列をベクトル化\n",
    "target_list = basedf['Target'].tolist()\n",
    "\n",
    "target_vecs = encode_text(target_list)\n",
    "    # コサイン類似度を計算\n",
    "cosine_scores = torch.nn.functional.cosine_similarity(query_vec, target_vecs)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 71,
   "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>JRCT ID</th>\n",
       "      <th>NCT No</th>\n",
       "      <th>JapicCTI No</th>\n",
       "      <th>Title</th>\n",
       "      <th>Target</th>\n",
       "      <th>研究・治験の目的</th>\n",
       "      <th>試験等のフェーズ</th>\n",
       "      <th>試験の種類</th>\n",
       "      <th>無作為化</th>\n",
       "      <th>盲検化</th>\n",
       "      <th>...</th>\n",
       "      <th>purpose</th>\n",
       "      <th>Inclusion Criteria</th>\n",
       "      <th>Exclusion Criteria</th>\n",
       "      <th>Age Minimum</th>\n",
       "      <th>Age Maximum</th>\n",
       "      <th>Gender</th>\n",
       "      <th>Discontinuation Criteria</th>\n",
       "      <th>Keyword</th>\n",
       "      <th>Intervention(s)</th>\n",
       "      <th>TargetWord</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>12</th>\n",
       "      <td>jRCT2041240130</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>中等度-高度PONV発症リスクを有する肺切除術予定患者の周術期管理におけるGranisetr...</td>\n",
       "      <td>肺がん</td>\n",
       "      <td>全身麻酔を要する肺切除術周術期における標準制吐療法であるグラニセトロン(Granisetro...</td>\n",
       "      <td>2</td>\n",
       "      <td>NaN</td>\n",
       "      <td>無作為化比較</td>\n",
       "      <td>非盲検</td>\n",
       "      <td>...</td>\n",
       "      <td>treatment purpose</td>\n",
       "      <td>(1) Patients scheduled to undergo anatomical l...</td>\n",
       "      <td>(1) Patients with a history of allergy to the ...</td>\n",
       "      <td>18age old over</td>\n",
       "      <td>No limit</td>\n",
       "      <td>Both</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>Treatment group\\r\\nAdminister GRA 1mg intraven...</td>\n",
       "      <td>[肺がん]</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>201</th>\n",
       "      <td>jRCT2052240059</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>遺伝子HSD17B4高メチル化を有するHER2陽性ER陰性乳癌における非手術療法の有用性を評...</td>\n",
       "      <td>乳がん</td>\n",
       "      <td>HSD17B4高メチル化(HSD17B4 hypermethylation:HH)を有するH...</td>\n",
       "      <td>2</td>\n",
       "      <td>NaN</td>\n",
       "      <td>単一群</td>\n",
       "      <td>非盲検</td>\n",
       "      <td>...</td>\n",
       "      <td>diagnostic purpose</td>\n",
       "      <td>1. Histologically confirmed invasive breast ca...</td>\n",
       "      <td>1. History of other malignancy within the last...</td>\n",
       "      <td>20age old over</td>\n",
       "      <td>No limit</td>\n",
       "      <td>Female</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>Omitting breast surgery after preoperative che...</td>\n",
       "      <td>[乳がん]</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>279</th>\n",
       "      <td>jRCT2031230723</td>\n",
       "      <td>NCT06112379</td>\n",
       "      <td>NaN</td>\n",
       "      <td>未治療のトリプルネガティブ又はホルモン受容体低発現/HER2陰性乳癌の成人患者を対象として、...</td>\n",
       "      <td>乳癌</td>\n",
       "      <td>未治療のトリプルネガティブ又はホルモン受容体低発現/HER2陰性乳癌の成人患者を対象として、...</td>\n",
       "      <td>3</td>\n",
       "      <td>NaN</td>\n",
       "      <td>無作為化比較</td>\n",
       "      <td>非盲検</td>\n",
       "      <td>...</td>\n",
       "      <td>treatment purpose</td>\n",
       "      <td>1. Participant must be &gt;= 18 years at the time...</td>\n",
       "      <td>1. As judged by the investigator, any evidence...</td>\n",
       "      <td>18age old over</td>\n",
       "      <td>No limit</td>\n",
       "      <td>Both</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>- Experimental arm: Dato-DXd plus durvalumab n...</td>\n",
       "      <td>[乳癌]</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>311</th>\n",
       "      <td>jRCT2061230102</td>\n",
       "      <td>NCT06103864</td>\n",
       "      <td>NaN</td>\n",
       "      <td>Programmed death-ligand(PD-L1)陽性の局所再発手術不能又は転移性...</td>\n",
       "      <td>乳癌</td>\n",
       "      <td>PD-L1陽性の局所再発手術不能または転移性TNBC患者を対象に、デュルバルマブ併用または非...</td>\n",
       "      <td>3</td>\n",
       "      <td>NaN</td>\n",
       "      <td>無作為化比較</td>\n",
       "      <td>非盲検</td>\n",
       "      <td>...</td>\n",
       "      <td>treatment purpose</td>\n",
       "      <td>Histologically or cytologically documented loc...</td>\n",
       "      <td>As judged by investigator, severe or uncontrol...</td>\n",
       "      <td>18age old over</td>\n",
       "      <td>No limit</td>\n",
       "      <td>Both</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>Arm 1: Dato-DXd + durvalumab\\r\\nArm 2: Investi...</td>\n",
       "      <td>[乳癌]</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>396</th>\n",
       "      <td>jRCT2061230074</td>\n",
       "      <td>NCT05952557</td>\n",
       "      <td>NaN</td>\n",
       "      <td>根治的局所治療(化学療法の併用または非併用)を受けて疾患の兆候のない、再発リスクが中間~高リ...</td>\n",
       "      <td>乳がん、早期乳がん</td>\n",
       "      <td>Treatment</td>\n",
       "      <td>3</td>\n",
       "      <td>NaN</td>\n",
       "      <td>無作為化比較</td>\n",
       "      <td>非盲検</td>\n",
       "      <td>...</td>\n",
       "      <td>treatment purpose</td>\n",
       "      <td>- Women and Men; 18 years or more at the time ...</td>\n",
       "      <td>- Inoperable locally advanced or metastatic br...</td>\n",
       "      <td>18age old over</td>\n",
       "      <td>No limit</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>arm A: continue with SoC ET as directed by inv...</td>\n",
       "      <td>[乳がん, 早期乳がん]</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>509</th>\n",
       "      <td>jRCT2031230109</td>\n",
       "      <td>NCT05514054</td>\n",
       "      <td>NaN</td>\n",
       "      <td>EMBER-4:2~5年間の術後内分泌療法による前治療歴を有する再発高リスクのER+、HER...</td>\n",
       "      <td>乳癌</td>\n",
       "      <td>早期乳癌患者を対象としたimlunestrantと標準的な内分泌療法の比較試験</td>\n",
       "      <td>3</td>\n",
       "      <td>NaN</td>\n",
       "      <td>無作為化比較</td>\n",
       "      <td>非盲検</td>\n",
       "      <td>...</td>\n",
       "      <td>treatment purpose</td>\n",
       "      <td>-Have a diagnosis of ER+, HER2- early-stage, r...</td>\n",
       "      <td>-Have any evidence of metastatic disease (incl...</td>\n",
       "      <td>18age old over</td>\n",
       "      <td>No limit</td>\n",
       "      <td>Both</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>-Drug: Imlunestrant\\r\\n  Administered orally.\\...</td>\n",
       "      <td>[乳癌]</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>515</th>\n",
       "      <td>jRCT2031230096</td>\n",
       "      <td>NCT05774951</td>\n",
       "      <td>NaN</td>\n",
       "      <td>根治的局所領域療法(化学療法の併用または非併用)および標準補助内分泌療法(ET)を少なくとも...</td>\n",
       "      <td>乳がん、早期乳がん</td>\n",
       "      <td>Treatment</td>\n",
       "      <td>3</td>\n",
       "      <td>NaN</td>\n",
       "      <td>無作為化比較</td>\n",
       "      <td>非盲検</td>\n",
       "      <td>...</td>\n",
       "      <td>treatment purpose</td>\n",
       "      <td>- Women and Men, greater than or equal to 18 y...</td>\n",
       "      <td>- Inoperable locally advanced or metastatic br...</td>\n",
       "      <td>18age old over</td>\n",
       "      <td>No limit</td>\n",
       "      <td>Both</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>arm A: continue with SoC ET as directed by inv...</td>\n",
       "      <td>[乳がん, 早期乳がん]</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>610</th>\n",
       "      <td>jRCT2061220087</td>\n",
       "      <td>NCT05629585</td>\n",
       "      <td>NaN</td>\n",
       "      <td>術前薬物療法後の外科的切除時に乳房及び/又は腋窩リンパ節に浸潤性残存病変を有するステージI~...</td>\n",
       "      <td>乳癌</td>\n",
       "      <td>術前薬物療法後の外科的切除時に乳房および/または腋窩リンパ節に浸潤性残存病変を有するI~II...</td>\n",
       "      <td>3</td>\n",
       "      <td>NaN</td>\n",
       "      <td>無作為化比較</td>\n",
       "      <td>非盲検</td>\n",
       "      <td>...</td>\n",
       "      <td>treatment purpose</td>\n",
       "      <td>Participant must be &gt;= 18 years at the time of...</td>\n",
       "      <td>Stage IV (metastatic) TNBC.\\r\\nHistory of prio...</td>\n",
       "      <td>18age old over</td>\n",
       "      <td>130age old under</td>\n",
       "      <td>Both</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>Arm 1: Dato-DXd 6 mg/kg IV Q3W x 8 cycles + Du...</td>\n",
       "      <td>[乳癌]</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>693</th>\n",
       "      <td>jRCT2031220276</td>\n",
       "      <td>NCT05307705</td>\n",
       "      <td>NaN</td>\n",
       "      <td>PIK3CA H1047R変異を有する進行乳がん患者及びその他の固形がん患者を対象としたLO...</td>\n",
       "      <td>乳がん</td>\n",
       "      <td>LOXO-783 の単独投与及び他の抗がん剤との併用投与における 第 2 相試験の推奨用量、...</td>\n",
       "      <td>1</td>\n",
       "      <td>NaN</td>\n",
       "      <td>単一群</td>\n",
       "      <td>非盲検</td>\n",
       "      <td>...</td>\n",
       "      <td>treatment purpose</td>\n",
       "      <td>-Have advanced breast cancer or another solid ...</td>\n",
       "      <td>-Medical Conditions\\r\\n -Colorectal cancer\\r\\n...</td>\n",
       "      <td>18age old over</td>\n",
       "      <td>No limit</td>\n",
       "      <td>Both</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>-Drug: LOXO-783\\r\\n Oral\\r\\n Other Name: LY384...</td>\n",
       "      <td>[乳がん]</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>865</th>\n",
       "      <td>jRCT2052210099</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>乳がんを有する成人女性及び健康成人女性を対象とした乳房用マイクロ波画像診断装置IGS-000...</td>\n",
       "      <td>乳がん</td>\n",
       "      <td>本治験の目的は,乳がん又はその疑いのある者,並びに乳がん又はその疑いがない者を対象に乳房画像...</td>\n",
       "      <td>2</td>\n",
       "      <td>NaN</td>\n",
       "      <td>単一群</td>\n",
       "      <td>単盲検</td>\n",
       "      <td>...</td>\n",
       "      <td>screening</td>\n",
       "      <td>Breast cancer (including suspected) \\r\\n(1) On...</td>\n",
       "      <td>(1) There is trauma with bleeding on the breas...</td>\n",
       "      <td>20age old over</td>\n",
       "      <td>No limit</td>\n",
       "      <td>Female</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>The test using IGS-0001 will be performed twic...</td>\n",
       "      <td>[乳がん]</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>10 rows × 39 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "            JRCT ID       NCT No JapicCTI No  \\\n",
       "12   jRCT2041240130          NaN         NaN   \n",
       "201  jRCT2052240059          NaN         NaN   \n",
       "279  jRCT2031230723  NCT06112379         NaN   \n",
       "311  jRCT2061230102  NCT06103864         NaN   \n",
       "396  jRCT2061230074  NCT05952557         NaN   \n",
       "509  jRCT2031230109  NCT05514054         NaN   \n",
       "515  jRCT2031230096  NCT05774951         NaN   \n",
       "610  jRCT2061220087  NCT05629585         NaN   \n",
       "693  jRCT2031220276  NCT05307705         NaN   \n",
       "865  jRCT2052210099          NaN         NaN   \n",
       "\n",
       "                                                 Title     Target  \\\n",
       "12   中等度-高度PONV発症リスクを有する肺切除術予定患者の周術期管理におけるGranisetr...        肺がん   \n",
       "201  遺伝子HSD17B4高メチル化を有するHER2陽性ER陰性乳癌における非手術療法の有用性を評...        乳がん   \n",
       "279  未治療のトリプルネガティブ又はホルモン受容体低発現/HER2陰性乳癌の成人患者を対象として、...         乳癌   \n",
       "311  Programmed death-ligand(PD-L1)陽性の局所再発手術不能又は転移性...         乳癌   \n",
       "396  根治的局所治療(化学療法の併用または非併用)を受けて疾患の兆候のない、再発リスクが中間~高リ...  乳がん、早期乳がん   \n",
       "509  EMBER-4:2~5年間の術後内分泌療法による前治療歴を有する再発高リスクのER+、HER...         乳癌   \n",
       "515  根治的局所領域療法(化学療法の併用または非併用)および標準補助内分泌療法(ET)を少なくとも...  乳がん、早期乳がん   \n",
       "610  術前薬物療法後の外科的切除時に乳房及び/又は腋窩リンパ節に浸潤性残存病変を有するステージI~...         乳癌   \n",
       "693  PIK3CA H1047R変異を有する進行乳がん患者及びその他の固形がん患者を対象としたLO...        乳がん   \n",
       "865  乳がんを有する成人女性及び健康成人女性を対象とした乳房用マイクロ波画像診断装置IGS-000...        乳がん   \n",
       "\n",
       "                                              研究・治験の目的 試験等のフェーズ 試験の種類    無作為化  \\\n",
       "12   全身麻酔を要する肺切除術周術期における標準制吐療法であるグラニセトロン(Granisetro...        2   NaN  無作為化比較   \n",
       "201  HSD17B4高メチル化(HSD17B4 hypermethylation:HH)を有するH...        2   NaN     単一群   \n",
       "279  未治療のトリプルネガティブ又はホルモン受容体低発現/HER2陰性乳癌の成人患者を対象として、...        3   NaN  無作為化比較   \n",
       "311  PD-L1陽性の局所再発手術不能または転移性TNBC患者を対象に、デュルバルマブ併用または非...        3   NaN  無作為化比較   \n",
       "396                                          Treatment        3   NaN  無作為化比較   \n",
       "509            早期乳癌患者を対象としたimlunestrantと標準的な内分泌療法の比較試験        3   NaN  無作為化比較   \n",
       "515                                          Treatment        3   NaN  無作為化比較   \n",
       "610  術前薬物療法後の外科的切除時に乳房および/または腋窩リンパ節に浸潤性残存病変を有するI~II...        3   NaN  無作為化比較   \n",
       "693  LOXO-783 の単独投与及び他の抗がん剤との併用投与における 第 2 相試験の推奨用量、...        1   NaN     単一群   \n",
       "865  本治験の目的は,乳がん又はその疑いのある者,並びに乳がん又はその疑いがない者を対象に乳房画像...        2   NaN     単一群   \n",
       "\n",
       "     盲検化  ...             purpose  \\\n",
       "12   非盲検  ...   treatment purpose   \n",
       "201  非盲検  ...  diagnostic purpose   \n",
       "279  非盲検  ...   treatment purpose   \n",
       "311  非盲検  ...   treatment purpose   \n",
       "396  非盲検  ...   treatment purpose   \n",
       "509  非盲検  ...   treatment purpose   \n",
       "515  非盲検  ...   treatment purpose   \n",
       "610  非盲検  ...   treatment purpose   \n",
       "693  非盲検  ...   treatment purpose   \n",
       "865  単盲検  ...           screening   \n",
       "\n",
       "                                    Inclusion Criteria  \\\n",
       "12   (1) Patients scheduled to undergo anatomical l...   \n",
       "201  1. Histologically confirmed invasive breast ca...   \n",
       "279  1. Participant must be >= 18 years at the time...   \n",
       "311  Histologically or cytologically documented loc...   \n",
       "396  - Women and Men; 18 years or more at the time ...   \n",
       "509  -Have a diagnosis of ER+, HER2- early-stage, r...   \n",
       "515  - Women and Men, greater than or equal to 18 y...   \n",
       "610  Participant must be >= 18 years at the time of...   \n",
       "693  -Have advanced breast cancer or another solid ...   \n",
       "865  Breast cancer (including suspected) \\r\\n(1) On...   \n",
       "\n",
       "                                    Exclusion Criteria     Age Minimum  \\\n",
       "12   (1) Patients with a history of allergy to the ...  18age old over   \n",
       "201  1. History of other malignancy within the last...  20age old over   \n",
       "279  1. As judged by the investigator, any evidence...  18age old over   \n",
       "311  As judged by investigator, severe or uncontrol...  18age old over   \n",
       "396  - Inoperable locally advanced or metastatic br...  18age old over   \n",
       "509  -Have any evidence of metastatic disease (incl...  18age old over   \n",
       "515  - Inoperable locally advanced or metastatic br...  18age old over   \n",
       "610  Stage IV (metastatic) TNBC.\\r\\nHistory of prio...  18age old over   \n",
       "693  -Medical Conditions\\r\\n -Colorectal cancer\\r\\n...  18age old over   \n",
       "865  (1) There is trauma with bleeding on the breas...  20age old over   \n",
       "\n",
       "          Age Maximum  Gender Discontinuation Criteria Keyword  \\\n",
       "12           No limit    Both                      NaN     NaN   \n",
       "201          No limit  Female                      NaN     NaN   \n",
       "279          No limit    Both                      NaN     NaN   \n",
       "311          No limit    Both                      NaN     NaN   \n",
       "396          No limit     NaN                      NaN     NaN   \n",
       "509          No limit    Both                      NaN     NaN   \n",
       "515          No limit    Both                      NaN     NaN   \n",
       "610  130age old under    Both                      NaN     NaN   \n",
       "693          No limit    Both                      NaN     NaN   \n",
       "865          No limit  Female                      NaN     NaN   \n",
       "\n",
       "                                       Intervention(s)    TargetWord  \n",
       "12   Treatment group\\r\\nAdminister GRA 1mg intraven...         [肺がん]  \n",
       "201  Omitting breast surgery after preoperative che...         [乳がん]  \n",
       "279  - Experimental arm: Dato-DXd plus durvalumab n...          [乳癌]  \n",
       "311  Arm 1: Dato-DXd + durvalumab\\r\\nArm 2: Investi...          [乳癌]  \n",
       "396  arm A: continue with SoC ET as directed by inv...  [乳がん, 早期乳がん]  \n",
       "509  -Drug: Imlunestrant\\r\\n  Administered orally.\\...          [乳癌]  \n",
       "515  arm A: continue with SoC ET as directed by inv...  [乳がん, 早期乳がん]  \n",
       "610  Arm 1: Dato-DXd 6 mg/kg IV Q3W x 8 cycles + Du...          [乳癌]  \n",
       "693  -Drug: LOXO-783\\r\\n Oral\\r\\n Other Name: LY384...         [乳がん]  \n",
       "865  The test using IGS-0001 will be performed twic...         [乳がん]  \n",
       "\n",
       "[10 rows x 39 columns]"
      ]
     },
     "execution_count": 71,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "matched_indices_d = (cosine_scores >= threshold).nonzero().tolist()\n",
    "# 入れ子リストをフラットなリストに変換\n",
    "flat_indices_d = [idx[0] for idx in matched_indices_d]\n",
    "\n",
    "# 抽出\n",
    "matched_df_d = basedf.iloc[flat_indices_d]\n",
    "matched_df_d\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": []
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "\n",
    "\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": []
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "\n"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "gradio",
   "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.3"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}