Register
Login
Resources
Docs Blog Datasets Glossary Case Studies Tutorials & Webinars
Product
Data Engine LLMs Platform Enterprise
Pricing Explore
Connect to our Discord channel

cluster.html 39 KB

You have to be logged in to leave a comment. Sign In
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
  1. <!DOCTYPE html>
  2. <html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en"><head>
  3. <meta charset="utf-8">
  4. <meta name="generator" content="quarto-1.3.450">
  5. <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes">
  6. <title>Book Data Tools – cluster</title>
  7. <style>
  8. code{white-space: pre-wrap;}
  9. span.smallcaps{font-variant: small-caps;}
  10. div.columns{display: flex; gap: min(4vw, 1.5em);}
  11. div.column{flex: auto; overflow-x: auto;}
  12. div.hanging-indent{margin-left: 1.5em; text-indent: -1.5em;}
  13. ul.task-list{list-style: none;}
  14. ul.task-list li input[type="checkbox"] {
  15. width: 0.8em;
  16. margin: 0 0.8em 0.2em -1em; /* quarto-specific, see https://github.com/quarto-dev/quarto-cli/issues/4556 */
  17. vertical-align: middle;
  18. }
  19. </style>
  20. <script src="../site_libs/quarto-nav/quarto-nav.js"></script>
  21. <script src="../site_libs/quarto-nav/headroom.min.js"></script>
  22. <script src="../site_libs/clipboard/clipboard.min.js"></script>
  23. <script src="../site_libs/quarto-search/autocomplete.umd.js"></script>
  24. <script src="../site_libs/quarto-search/fuse.min.js"></script>
  25. <script src="../site_libs/quarto-search/quarto-search.js"></script>
  26. <meta name="quarto:offset" content="../">
  27. <script src="../site_libs/quarto-html/quarto.js"></script>
  28. <script src="../site_libs/quarto-html/popper.min.js"></script>
  29. <script src="../site_libs/quarto-html/tippy.umd.min.js"></script>
  30. <script src="../site_libs/quarto-html/anchor.min.js"></script>
  31. <link href="../site_libs/quarto-html/tippy.css" rel="stylesheet">
  32. <link href="../site_libs/quarto-html/quarto-syntax-highlighting.css" rel="stylesheet" class="quarto-color-scheme" id="quarto-text-highlighting-styles">
  33. <link href="../site_libs/quarto-html/quarto-syntax-highlighting-dark.css" rel="prefetch" class="quarto-color-scheme quarto-color-alternate" id="quarto-text-highlighting-styles">
  34. <script src="../site_libs/bootstrap/bootstrap.min.js"></script>
  35. <link href="../site_libs/bootstrap/bootstrap-icons.css" rel="stylesheet">
  36. <link href="../site_libs/bootstrap/bootstrap.min.css" rel="stylesheet" class="quarto-color-scheme" id="quarto-bootstrap" data-mode="light">
  37. <link href="../site_libs/bootstrap/bootstrap-dark.min.css" rel="prefetch" class="quarto-color-scheme quarto-color-alternate" id="quarto-bootstrap" data-mode="dark">
  38. <script id="quarto-search-options" type="application/json">{
  39. "location": "sidebar",
  40. "copy-button": false,
  41. "collapse-after": 3,
  42. "panel-placement": "start",
  43. "type": "textbox",
  44. "limit": 20,
  45. "language": {
  46. "search-no-results-text": "No results",
  47. "search-matching-documents-text": "matching documents",
  48. "search-copy-link-title": "Copy link to search",
  49. "search-hide-matches-text": "Hide additional matches",
  50. "search-more-match-text": "more match in this document",
  51. "search-more-matches-text": "more matches in this document",
  52. "search-clear-button-title": "Clear",
  53. "search-detached-cancel-button-title": "Cancel",
  54. "search-submit-button-title": "Submit",
  55. "search-label": "Search"
  56. }
  57. }</script>
  58. <link rel="stylesheet" href="../tweaks.css">
  59. </head>
  60. <body class="nav-sidebar floating">
  61. <div id="quarto-search-results"></div>
  62. <header id="quarto-header" class="headroom fixed-top">
  63. <nav class="quarto-secondary-nav">
  64. <div class="container-fluid d-flex">
  65. <button type="button" class="quarto-btn-toggle btn" data-bs-toggle="collapse" data-bs-target="#quarto-sidebar,#quarto-sidebar-glass" aria-controls="quarto-sidebar" aria-expanded="false" aria-label="Toggle sidebar navigation" onclick="if (window.quartoToggleHeadroom) { window.quartoToggleHeadroom(); }">
  66. <i class="bi bi-layout-text-sidebar-reverse"></i>
  67. </button>
  68. <nav class="quarto-page-breadcrumbs" aria-label="breadcrumb"><ol class="breadcrumb"><li class="breadcrumb-item"><a href="../data/index.html">Data Organization</a></li><li class="breadcrumb-item"><a href="../data/cluster.html">Book Clusters</a></li></ol></nav>
  69. <a class="flex-grow-1" role="button" data-bs-toggle="collapse" data-bs-target="#quarto-sidebar,#quarto-sidebar-glass" aria-controls="quarto-sidebar" aria-expanded="false" aria-label="Toggle sidebar navigation" onclick="if (window.quartoToggleHeadroom) { window.quartoToggleHeadroom(); }">
  70. </a>
  71. <button type="button" class="btn quarto-search-button" aria-label="" onclick="window.quartoOpenSearch();">
  72. <i class="bi bi-search"></i>
  73. </button>
  74. </div>
  75. </nav>
  76. </header>
  77. <!-- content -->
  78. <div id="quarto-content" class="quarto-container page-columns page-rows-contents page-layout-article">
  79. <!-- sidebar -->
  80. <nav id="quarto-sidebar" class="sidebar collapse collapse-horizontal sidebar-navigation floating overflow-auto">
  81. <div class="pt-lg-2 mt-2 text-left sidebar-header">
  82. <div class="sidebar-title mb-0 py-0">
  83. <a href="../">Book Data Tools</a>
  84. <div class="sidebar-tools-main">
  85. <a href="" class="quarto-color-scheme-toggle quarto-navigation-tool px-1" onclick="window.quartoToggleColorScheme(); return false;" title="Toggle dark mode"><i class="bi"></i></a>
  86. </div>
  87. </div>
  88. </div>
  89. <div class="mt-2 flex-shrink-0 align-items-center">
  90. <div class="sidebar-search">
  91. <div id="quarto-search" class="" title="Search"></div>
  92. </div>
  93. </div>
  94. <div class="sidebar-menu-container">
  95. <ul class="list-unstyled mt-1">
  96. <li class="sidebar-item">
  97. <div class="sidebar-item-container">
  98. <a href="../index.html" class="sidebar-item-text sidebar-link">
  99. <span class="menu-text">Overview</span></a>
  100. </div>
  101. </li>
  102. <li class="sidebar-item sidebar-item-section">
  103. <div class="sidebar-item-container">
  104. <a href="../using/index.html" class="sidebar-item-text sidebar-link">
  105. <span class="menu-text">Importing</span></a>
  106. <a class="sidebar-item-toggle text-start" data-bs-toggle="collapse" data-bs-target="#quarto-sidebar-section-1" aria-expanded="true" aria-label="Toggle section">
  107. <i class="bi bi-chevron-right ms-2"></i>
  108. </a>
  109. </div>
  110. <ul id="quarto-sidebar-section-1" class="collapse list-unstyled sidebar-section depth1 show">
  111. <li class="sidebar-item">
  112. <div class="sidebar-item-container">
  113. <a href="../using/setup.html" class="sidebar-item-text sidebar-link">
  114. <span class="menu-text">Environment Setup</span></a>
  115. </div>
  116. </li>
  117. <li class="sidebar-item">
  118. <div class="sidebar-item-container">
  119. <a href="../using/storage.html" class="sidebar-item-text sidebar-link">
  120. <span class="menu-text">Data Storage</span></a>
  121. </div>
  122. </li>
  123. <li class="sidebar-item">
  124. <div class="sidebar-item-container">
  125. <a href="../using/sources.html" class="sidebar-item-text sidebar-link">
  126. <span class="menu-text">Source Data</span></a>
  127. </div>
  128. </li>
  129. <li class="sidebar-item">
  130. <div class="sidebar-item-container">
  131. <a href="../using/running.html" class="sidebar-item-text sidebar-link">
  132. <span class="menu-text">Running the Tools</span></a>
  133. </div>
  134. </li>
  135. </ul>
  136. </li>
  137. <li class="sidebar-item sidebar-item-section">
  138. <div class="sidebar-item-container">
  139. <a href="../data/index.html" class="sidebar-item-text sidebar-link">
  140. <span class="menu-text">Data Organization</span></a>
  141. <a class="sidebar-item-toggle text-start" data-bs-toggle="collapse" data-bs-target="#quarto-sidebar-section-2" aria-expanded="true" aria-label="Toggle section">
  142. <i class="bi bi-chevron-right ms-2"></i>
  143. </a>
  144. </div>
  145. <ul id="quarto-sidebar-section-2" class="collapse list-unstyled sidebar-section depth1 show">
  146. <li class="sidebar-item">
  147. <div class="sidebar-item-container">
  148. <a href="../data/ids.html" class="sidebar-item-text sidebar-link">
  149. <span class="menu-text">Common Identifiers</span></a>
  150. </div>
  151. </li>
  152. <li class="sidebar-item">
  153. <div class="sidebar-item-container">
  154. <a href="../data/loc.html" class="sidebar-item-text sidebar-link">
  155. <span class="menu-text">Library of Congress</span></a>
  156. </div>
  157. </li>
  158. <li class="sidebar-item">
  159. <div class="sidebar-item-container">
  160. <a href="../data/openlib.html" class="sidebar-item-text sidebar-link">
  161. <span class="menu-text">OpenLibrary</span></a>
  162. </div>
  163. </li>
  164. <li class="sidebar-item">
  165. <div class="sidebar-item-container">
  166. <a href="../data/viaf.html" class="sidebar-item-text sidebar-link">
  167. <span class="menu-text">VIAF</span></a>
  168. </div>
  169. </li>
  170. <li class="sidebar-item">
  171. <div class="sidebar-item-container">
  172. <a href="../data/bx.html" class="sidebar-item-text sidebar-link">
  173. <span class="menu-text">BookCrossing</span></a>
  174. </div>
  175. </li>
  176. <li class="sidebar-item">
  177. <div class="sidebar-item-container">
  178. <a href="../data/amazon.html" class="sidebar-item-text sidebar-link">
  179. <span class="menu-text">Amazon Ratings</span></a>
  180. </div>
  181. </li>
  182. <li class="sidebar-item">
  183. <div class="sidebar-item-container">
  184. <a href="../data/goodreads.html" class="sidebar-item-text sidebar-link">
  185. <span class="menu-text">GoodReads</span></a>
  186. </div>
  187. </li>
  188. <li class="sidebar-item">
  189. <div class="sidebar-item-container">
  190. <a href="../data/cluster.html" class="sidebar-item-text sidebar-link active">
  191. <span class="menu-text">Book Clusters</span></a>
  192. </div>
  193. </li>
  194. <li class="sidebar-item">
  195. <div class="sidebar-item-container">
  196. <a href="../data/gender.html" class="sidebar-item-text sidebar-link">
  197. <span class="menu-text">Book Author Gender</span></a>
  198. </div>
  199. </li>
  200. </ul>
  201. </li>
  202. <li class="sidebar-item sidebar-item-section">
  203. <div class="sidebar-item-container">
  204. <a href="../implementation/index.html" class="sidebar-item-text sidebar-link">
  205. <span class="menu-text">Implementation</span></a>
  206. <a class="sidebar-item-toggle text-start" data-bs-toggle="collapse" data-bs-target="#quarto-sidebar-section-3" aria-expanded="true" aria-label="Toggle section">
  207. <i class="bi bi-chevron-right ms-2"></i>
  208. </a>
  209. </div>
  210. <ul id="quarto-sidebar-section-3" class="collapse list-unstyled sidebar-section depth1 show">
  211. <li class="sidebar-item">
  212. <div class="sidebar-item-container">
  213. <a href="../implementation/pipeline.html" class="sidebar-item-text sidebar-link">
  214. <span class="menu-text">Pipeline Specification</span></a>
  215. </div>
  216. </li>
  217. <li class="sidebar-item">
  218. <div class="sidebar-item-container">
  219. <a href="../implementation/layout.html" class="sidebar-item-text sidebar-link">
  220. <span class="menu-text">Code Layout</span></a>
  221. </div>
  222. </li>
  223. <li class="sidebar-item">
  224. <div class="sidebar-item-container">
  225. <a href="../implementation/dataset.html" class="sidebar-item-text sidebar-link">
  226. <span class="menu-text">Design for Datasets</span></a>
  227. </div>
  228. </li>
  229. </ul>
  230. </li>
  231. <li class="sidebar-item">
  232. <div class="sidebar-item-container">
  233. <a href="../history.html" class="sidebar-item-text sidebar-link">
  234. <span class="menu-text">History</span></a>
  235. </div>
  236. </li>
  237. <li class="sidebar-item">
  238. <div class="sidebar-item-container">
  239. <a href="../papers.html" class="sidebar-item-text sidebar-link">
  240. <span class="menu-text">Papers Using BookData</span></a>
  241. </div>
  242. </li>
  243. <li class="sidebar-item sidebar-item-section">
  244. <div class="sidebar-item-container">
  245. <a href="../reports/index.html" class="sidebar-item-text sidebar-link">
  246. <span class="menu-text">Reports and Audits</span></a>
  247. <a class="sidebar-item-toggle text-start" data-bs-toggle="collapse" data-bs-target="#quarto-sidebar-section-4" aria-expanded="true" aria-label="Toggle section">
  248. <i class="bi bi-chevron-right ms-2"></i>
  249. </a>
  250. </div>
  251. <ul id="quarto-sidebar-section-4" class="collapse list-unstyled sidebar-section depth1 show">
  252. <li class="sidebar-item">
  253. <div class="sidebar-item-container">
  254. <a href="../reports/LinkageStats.html" class="sidebar-item-text sidebar-link">
  255. <span class="menu-text">Book Data Linkage Statistics</span></a>
  256. </div>
  257. </li>
  258. <li class="sidebar-item">
  259. <div class="sidebar-item-container">
  260. <a href="../reports/audit-cluster-stats.html" class="sidebar-item-text sidebar-link">
  261. <span class="menu-text">ISBN Cluster Changes</span></a>
  262. </div>
  263. </li>
  264. <li class="sidebar-item">
  265. <div class="sidebar-item-container">
  266. <a href="../reports/audit-gender-changes.html" class="sidebar-item-text sidebar-link">
  267. <span class="menu-text">Cluster Gender Changes</span></a>
  268. </div>
  269. </li>
  270. </ul>
  271. </li>
  272. <li class="sidebar-item">
  273. <div class="sidebar-item-container">
  274. <a href="../apidocs/bookdata/" class="sidebar-item-text sidebar-link"><i class="bi bi-gear-wide" role="img">
  275. </i>
  276. <span class="menu-text">Rust API docs</span></a>
  277. </div>
  278. </li>
  279. <li class="sidebar-item">
  280. <div class="sidebar-item-container">
  281. <a href="https://github.com/PIReTship/bookdata-tools" class="sidebar-item-text sidebar-link"><i class="bi bi-github" role="img">
  282. </i>
  283. <span class="menu-text">GitHub repository</span></a>
  284. </div>
  285. </li>
  286. </ul>
  287. </div>
  288. </nav>
  289. <div id="quarto-sidebar-glass" data-bs-toggle="collapse" data-bs-target="#quarto-sidebar,#quarto-sidebar-glass"></div>
  290. <!-- margin-sidebar -->
  291. <div id="quarto-margin-sidebar" class="sidebar margin-sidebar">
  292. <nav id="TOC" role="doc-toc" class="toc-active">
  293. <h2 id="toc-title">On this page</h2>
  294. <ul>
  295. <li><a href="#sec-cluster" id="toc-sec-cluster" class="nav-link active" data-scroll-target="#sec-cluster">Book Clusters</a>
  296. <ul class="collapse">
  297. <li><a href="#clustering-algorithm" id="toc-clustering-algorithm" class="nav-link" data-scroll-target="#clustering-algorithm">Clustering Algorithm</a></li>
  298. <li><a href="#known-problems" id="toc-known-problems" class="nav-link" data-scroll-target="#known-problems">Known Problems</a></li>
  299. <li><a href="#cluster-link-tables" id="toc-cluster-link-tables" class="nav-link" data-scroll-target="#cluster-link-tables">Cluster Link Tables</a>
  300. <ul class="collapse">
  301. <li><a href="#graph-tables" id="toc-graph-tables" class="nav-link" data-scroll-target="#graph-tables">Graph Tables</a></li>
  302. </ul></li>
  303. <li><a href="#cluster-information-tables" id="toc-cluster-information-tables" class="nav-link" data-scroll-target="#cluster-information-tables">Cluster Information Tables</a></li>
  304. </ul></li>
  305. </ul>
  306. <div class="toc-actions"><div><i class="bi bi-github"></i></div><div class="action-links"><p><a href="https://github.com/PIReTship/bookdata-tools/edit/main/docs/data/cluster.qmd" class="toc-action">Edit this page</a></p><p><a href="https://github.com/PIReTship/bookdata-tools/issues/new" class="toc-action">Report an issue</a></p></div></div></nav>
  307. </div>
  308. <!-- main -->
  309. <main class="content" id="quarto-document-content">
  310. <section id="sec-cluster" class="level1">
  311. <h1>Book Clusters</h1>
  312. <p>For recommendation and analysis, we often want to look at <em>works</em> instead of individual books or editions of those books. The same material by the same author(s) may be reprinted in many different editions, with different ISBNs, and sometimes separate ratings from the same user.</p>
  313. <p>There are a variety of ways to deal with this. GoodReads and OpenLibrary both have the concept of a ‘work’ to group together related editions (the Library of Congress also has such a concept internally in its BIBFRAME schema, but that data is not currently available for integration).</p>
  314. <p>Other services, such as <a href="https://blog.librarything.com/thingology/2006/06/introducing-thingisbn/">ThingISBN</a> and OCLC’s <a href="https://www.worldcat.org/affiliate/webservices/xisbn/app.jsp">xISBN</a> both link together ISBNs: given a query ISBN, they will return a list of ISBNs believed to be for the same book.</p>
  315. <p>Using the book data sources here, we have implemented comparable functionality in a manner that anyone can reproduce from public data. We call the resulting equivalence sets ‘book clusters’.</p>
  316. <section id="clustering-algorithm" class="level2">
  317. <h2 class="anchored" data-anchor-id="clustering-algorithm">Clustering Algorithm</h2>
  318. <p>Our clustering algorithm begins by forming an undirected graph of record identifiers. We extract records from the following:</p>
  319. <ul>
  320. <li>Library of Congress book records, with edges from records to ISBNs recorded for that record.</li>
  321. <li>OpenLibrary editions, with edges from editions to ISBNs recorded for that edition.</li>
  322. <li>OpenLibrary works, with edges from works to editions.</li>
  323. <li>GoodReads books, with edges from books to ISBNs recorded for that book.</li>
  324. <li>GoodReads works, with edges from works to books.</li>
  325. </ul>
  326. <p>We then compute the connected components on this graph, and treat each connected component as a single ‘book’ (what we call a <em>book cluster</em>).</p>
  327. <p>The idea is that if two ISBNs appear together on a book record, that is evidence they are for the same book; likewise, if two book records have the same ISBN, it is evidence they record the same book. Pooling this evidence across all data sources maximizes the ability to detect book clusters.</p>
  328. <p>The <code>isbn_cluster</code> table maps each ISBN to its associated cluster. Individual data sources may also have an <code>isbn_cluster</code> table (e.g.&nbsp;<code>gr.isbn_cluster</code>); that is the result of clustering ISBNs using only the book records from that data source. However, all clustered results such as rating tables are based on the all-source book clusters.</p>
  329. </section>
  330. <section id="known-problems" class="level2">
  331. <h2 class="anchored" data-anchor-id="known-problems">Known Problems</h2>
  332. <p>There are a few known problems with the ISBN clustering:</p>
  333. <ul>
  334. <li><p>Publishers occasionally reuse ISBNs. They aren’t supposed to do this, but they do. This results in unrelated books having the same ISBN. This will cause a problem for any ISBN-based linking between books and ratings, not just the book clustering. We don’t yet have a good way to identify these ISBNs.</p></li>
  335. <li><p>Some book sets have ISBNs, which cause them link together books that should not be clustered. The Library of Congress identifies many of these ISBNs as set ISBNs, and we are examining the prospect of using this to exclude them from informing clustering decisions.</p></li>
  336. </ul>
  337. <p>If you only need e.g.&nbsp;the GoodReads data, we recommend that you <em>not</em> cluster it for the purpose of ratings, and only use clusters to link to out-of-GR book or author data. We are open to adding additional tables that facilitate linking GoodReads works directly to other tables.</p>
  338. </section>
  339. <section id="cluster-link-tables" class="level2">
  340. <h2 class="anchored" data-anchor-id="cluster-link-tables">Cluster Link Tables</h2>
  341. <div id="file:book-links/isbn-clusters.parquet" class="parquet file-block" data-file="book-links/isbn-clusters.parquet">
  342. <div class="file-header">
  343. <code>book-links/isbn-clusters.parquet</code>
  344. </div>
  345. <p>This file maps ISBN IDs to book clusters, enabling the various other book identifiers from other data sources to be mapped to clusters, since everything resolves to ISBN IDs.</p>
  346. <details class="file-details"><summary>File details</summary>
  347. <table class="file-schema table">
  348. <caption>Schema for <code>book-links/isbn-clusters.parquet</code>.</caption>
  349. <colgroup>
  350. <col style="width: 60%">
  351. <col style="width: 40%">
  352. </colgroup>
  353. <thead>
  354. <tr class="header">
  355. <th style="text-align: left;"><div>
  356. Field
  357. </div></th>
  358. <th style="text-align: right;"><div>
  359. Type
  360. </div></th>
  361. </tr>
  362. </thead>
  363. <tbody>
  364. <tr class="odd">
  365. <td style="text-align: left;"><div>
  366. isbn
  367. </div></td>
  368. <td style="text-align: right;"><div>
  369. Utf8
  370. </div></td>
  371. </tr>
  372. <tr class="even">
  373. <td style="text-align: left;"><div>
  374. isbn_id
  375. </div></td>
  376. <td style="text-align: right;"><div>
  377. Int32
  378. </div></td>
  379. </tr>
  380. <tr class="odd">
  381. <td style="text-align: left;"><div>
  382. cluster
  383. </div></td>
  384. <td style="text-align: right;"><div>
  385. Int32
  386. </div></td>
  387. </tr>
  388. </tbody>
  389. </table>
  390. </details>
  391. </div>
  392. <pre><code>{{&lt; schema book-links/isbn-clusters.parquet &gt;}}</code></pre>
  393. <section id="graph-tables" class="level3">
  394. <h3 class="anchored" data-anchor-id="graph-tables">Graph Tables</h3>
  395. <p>We also export the book identifier graph used for clustering to support further analysis.</p>
  396. <div id="file:book-links/cluster-graph-nodes.parquet" class="parquet file-block" data-file="book-links/cluster-graph-nodes.parquet">
  397. <div class="file-header">
  398. <code>book-links/cluster-graph-nodes.parquet</code>
  399. </div>
  400. <p>The table of nodes (with attributes) from the graph used for book clustering.</p>
  401. <details class="file-details"><summary>File details</summary>
  402. <table class="file-schema table">
  403. <caption>Schema for <code>book-links/cluster-graph-nodes.parquet</code>.</caption>
  404. <colgroup>
  405. <col style="width: 60%">
  406. <col style="width: 40%">
  407. </colgroup>
  408. <thead>
  409. <tr class="header">
  410. <th style="text-align: left;"><div>
  411. Field
  412. </div></th>
  413. <th style="text-align: right;"><div>
  414. Type
  415. </div></th>
  416. </tr>
  417. </thead>
  418. <tbody>
  419. <tr class="odd">
  420. <td style="text-align: left;"><div>
  421. book_code
  422. </div></td>
  423. <td style="text-align: right;"><div>
  424. Int32
  425. </div></td>
  426. </tr>
  427. <tr class="even">
  428. <td style="text-align: left;"><div>
  429. cluster
  430. </div></td>
  431. <td style="text-align: right;"><div>
  432. Int32
  433. </div></td>
  434. </tr>
  435. <tr class="odd">
  436. <td style="text-align: left;"><div>
  437. node_type
  438. </div></td>
  439. <td style="text-align: right;"><div>
  440. Utf8
  441. </div></td>
  442. </tr>
  443. <tr class="even">
  444. <td style="text-align: left;"><div>
  445. label
  446. </div></td>
  447. <td style="text-align: right;"><div>
  448. Utf8
  449. </div></td>
  450. </tr>
  451. </tbody>
  452. </table>
  453. </details>
  454. </div>
  455. <pre><code>{{&lt; schema book-links/cluster-graph-nodes.parquet &gt;}}</code></pre>
  456. <div id="file:book-links/cluster-graph-edges.parquet" class="parquet file-block" data-file="book-links/cluster-graph-edges.parquet">
  457. <div class="file-header">
  458. <code>book-links/cluster-graph-edges.parquet</code>
  459. </div>
  460. <p>The table of edges rom the book clustering graph.</p>
  461. <details class="file-details"><summary>File details</summary>
  462. <table class="file-schema table">
  463. <caption>Schema for <code>book-links/cluster-graph-edges.parquet</code>.</caption>
  464. <colgroup>
  465. <col style="width: 60%">
  466. <col style="width: 40%">
  467. </colgroup>
  468. <thead>
  469. <tr class="header">
  470. <th style="text-align: left;"><div>
  471. Field
  472. </div></th>
  473. <th style="text-align: right;"><div>
  474. Type
  475. </div></th>
  476. </tr>
  477. </thead>
  478. <tbody>
  479. <tr class="odd">
  480. <td style="text-align: left;"><div>
  481. src
  482. </div></td>
  483. <td style="text-align: right;"><div>
  484. Int32
  485. </div></td>
  486. </tr>
  487. <tr class="even">
  488. <td style="text-align: left;"><div>
  489. dst
  490. </div></td>
  491. <td style="text-align: right;"><div>
  492. Int32
  493. </div></td>
  494. </tr>
  495. </tbody>
  496. </table>
  497. </details>
  498. </div>
  499. <pre><code>{{&lt; schema book-links/cluster-graph-edges.parquet &gt;}}</code></pre>
  500. <dl>
  501. <dt><code id="file:book-graph.mp-zst">book-links/book-graph.mp.zst</code></dt>
  502. <dd>
  503. This is a serialization of the actual graph itself, using <code>rmp-serde</code> to serialize the Petgraph structure with MsgPack and compressing ith with ZStandard. This is unlikely to be usable outside of the Rust codebase, whereas the node and edge tables could be loaded into something like <code>igraph</code> for further analysis.
  504. </dd>
  505. </dl>
  506. </section>
  507. </section>
  508. <section id="cluster-information-tables" class="level2">
  509. <h2 class="anchored" data-anchor-id="cluster-information-tables">Cluster Information Tables</h2>
  510. <p>With the clusters, we then extract additional information from other tables.</p>
  511. <div id="file:book-links/cluster-first-authors.parquet" class="parquet file-block" data-file="book-links/cluster-first-authors.parquet">
  512. <div class="file-header">
  513. <code>book-links/cluster-first-authors.parquet</code>
  514. </div>
  515. <p>All available first-author records for each cluster, to support linking with VIAF.</p>
  516. <details class="file-details"><summary>File details</summary>
  517. <table class="file-schema table">
  518. <caption>Schema for <code>book-links/cluster-first-authors.parquet</code>.</caption>
  519. <colgroup>
  520. <col style="width: 60%">
  521. <col style="width: 40%">
  522. </colgroup>
  523. <thead>
  524. <tr class="header">
  525. <th style="text-align: left;"><div>
  526. Field
  527. </div></th>
  528. <th style="text-align: right;"><div>
  529. Type
  530. </div></th>
  531. </tr>
  532. </thead>
  533. <tbody>
  534. <tr class="odd">
  535. <td style="text-align: left;"><div>
  536. cluster
  537. </div></td>
  538. <td style="text-align: right;"><div>
  539. Int32
  540. </div></td>
  541. </tr>
  542. <tr class="even">
  543. <td style="text-align: left;"><div>
  544. author_name
  545. </div></td>
  546. <td style="text-align: right;"><div>
  547. Utf8
  548. </div></td>
  549. </tr>
  550. </tbody>
  551. </table>
  552. </details>
  553. </div>
  554. <div id="file:book-links/cluster-hashes.parquet" class="parquet file-block" data-file="book-links/cluster-hashes.parquet">
  555. <div class="file-header">
  556. <code>book-links/cluster-hashes.parquet</code>
  557. </div>
  558. <p>The MD5 checksums of the sorted sequence of ISBNs for each cluster, along with a <code>dcode</code> that is the least-significant bit of the checksum.</p>
  559. <details class="file-details"><summary>File details</summary>
  560. <table class="file-schema table">
  561. <caption>Schema for <code>book-links/cluster-hashes.parquet</code>.</caption>
  562. <colgroup>
  563. <col style="width: 60%">
  564. <col style="width: 40%">
  565. </colgroup>
  566. <thead>
  567. <tr class="header">
  568. <th style="text-align: left;"><div>
  569. Field
  570. </div></th>
  571. <th style="text-align: right;"><div>
  572. Type
  573. </div></th>
  574. </tr>
  575. </thead>
  576. <tbody>
  577. <tr class="odd">
  578. <td style="text-align: left;"><div>
  579. cluster
  580. </div></td>
  581. <td style="text-align: right;"><div>
  582. Int32
  583. </div></td>
  584. </tr>
  585. <tr class="even">
  586. <td style="text-align: left;"><div>
  587. isbn_hash
  588. </div></td>
  589. <td style="text-align: right;"><div>
  590. Utf8
  591. </div></td>
  592. </tr>
  593. <tr class="odd">
  594. <td style="text-align: left;"><div>
  595. isbn_dcode
  596. </div></td>
  597. <td style="text-align: right;"><div>
  598. Int8
  599. </div></td>
  600. </tr>
  601. </tbody>
  602. </table>
  603. </details>
  604. </div>
  605. <div id="file:book-links/cluster-stats.parquet" class="parquet file-block" data-file="book-links/cluster-stats.parquet">
  606. <div class="file-header">
  607. <code>book-links/cluster-stats.parquet</code>
  608. </div>
  609. <p>Statistics for each cluster, useful for auditing and debugging.</p>
  610. <details class="file-details"><summary>File details</summary>
  611. <table class="file-schema table">
  612. <caption>Schema for <code>book-links/cluster-stats.parquet</code>.</caption>
  613. <colgroup>
  614. <col style="width: 60%">
  615. <col style="width: 40%">
  616. </colgroup>
  617. <thead>
  618. <tr class="header">
  619. <th style="text-align: left;"><div>
  620. Field
  621. </div></th>
  622. <th style="text-align: right;"><div>
  623. Type
  624. </div></th>
  625. </tr>
  626. </thead>
  627. <tbody>
  628. <tr class="odd">
  629. <td style="text-align: left;"><div>
  630. cluster
  631. </div></td>
  632. <td style="text-align: right;"><div>
  633. Int32
  634. </div></td>
  635. </tr>
  636. <tr class="even">
  637. <td style="text-align: left;"><div>
  638. n_nodes
  639. </div></td>
  640. <td style="text-align: right;"><div>
  641. UInt32
  642. </div></td>
  643. </tr>
  644. <tr class="odd">
  645. <td style="text-align: left;"><div>
  646. n_isbns
  647. </div></td>
  648. <td style="text-align: right;"><div>
  649. UInt32
  650. </div></td>
  651. </tr>
  652. <tr class="even">
  653. <td style="text-align: left;"><div>
  654. n_loc_recs
  655. </div></td>
  656. <td style="text-align: right;"><div>
  657. UInt32
  658. </div></td>
  659. </tr>
  660. <tr class="odd">
  661. <td style="text-align: left;"><div>
  662. n_ol_editions
  663. </div></td>
  664. <td style="text-align: right;"><div>
  665. UInt32
  666. </div></td>
  667. </tr>
  668. <tr class="even">
  669. <td style="text-align: left;"><div>
  670. n_ol_works
  671. </div></td>
  672. <td style="text-align: right;"><div>
  673. UInt32
  674. </div></td>
  675. </tr>
  676. <tr class="odd">
  677. <td style="text-align: left;"><div>
  678. n_gr_books
  679. </div></td>
  680. <td style="text-align: right;"><div>
  681. UInt32
  682. </div></td>
  683. </tr>
  684. <tr class="even">
  685. <td style="text-align: left;"><div>
  686. n_gr_works
  687. </div></td>
  688. <td style="text-align: right;"><div>
  689. UInt32
  690. </div></td>
  691. </tr>
  692. </tbody>
  693. </table>
  694. </details>
  695. </div>
  696. </section>
  697. </section>
  698. </main> <!-- /main -->
  699. <script id="quarto-html-after-body" type="application/javascript">
  700. window.document.addEventListener("DOMContentLoaded", function (event) {
  701. const toggleBodyColorMode = (bsSheetEl) => {
  702. const mode = bsSheetEl.getAttribute("data-mode");
  703. const bodyEl = window.document.querySelector("body");
  704. if (mode === "dark") {
  705. bodyEl.classList.add("quarto-dark");
  706. bodyEl.classList.remove("quarto-light");
  707. } else {
  708. bodyEl.classList.add("quarto-light");
  709. bodyEl.classList.remove("quarto-dark");
  710. }
  711. }
  712. const toggleBodyColorPrimary = () => {
  713. const bsSheetEl = window.document.querySelector("link#quarto-bootstrap");
  714. if (bsSheetEl) {
  715. toggleBodyColorMode(bsSheetEl);
  716. }
  717. }
  718. toggleBodyColorPrimary();
  719. const disableStylesheet = (stylesheets) => {
  720. for (let i=0; i < stylesheets.length; i++) {
  721. const stylesheet = stylesheets[i];
  722. stylesheet.rel = 'prefetch';
  723. }
  724. }
  725. const enableStylesheet = (stylesheets) => {
  726. for (let i=0; i < stylesheets.length; i++) {
  727. const stylesheet = stylesheets[i];
  728. stylesheet.rel = 'stylesheet';
  729. }
  730. }
  731. const manageTransitions = (selector, allowTransitions) => {
  732. const els = window.document.querySelectorAll(selector);
  733. for (let i=0; i < els.length; i++) {
  734. const el = els[i];
  735. if (allowTransitions) {
  736. el.classList.remove('notransition');
  737. } else {
  738. el.classList.add('notransition');
  739. }
  740. }
  741. }
  742. const toggleColorMode = (alternate) => {
  743. // Switch the stylesheets
  744. const alternateStylesheets = window.document.querySelectorAll('link.quarto-color-scheme.quarto-color-alternate');
  745. manageTransitions('#quarto-margin-sidebar .nav-link', false);
  746. if (alternate) {
  747. enableStylesheet(alternateStylesheets);
  748. for (const sheetNode of alternateStylesheets) {
  749. if (sheetNode.id === "quarto-bootstrap") {
  750. toggleBodyColorMode(sheetNode);
  751. }
  752. }
  753. } else {
  754. disableStylesheet(alternateStylesheets);
  755. toggleBodyColorPrimary();
  756. }
  757. manageTransitions('#quarto-margin-sidebar .nav-link', true);
  758. // Switch the toggles
  759. const toggles = window.document.querySelectorAll('.quarto-color-scheme-toggle');
  760. for (let i=0; i < toggles.length; i++) {
  761. const toggle = toggles[i];
  762. if (toggle) {
  763. if (alternate) {
  764. toggle.classList.add("alternate");
  765. } else {
  766. toggle.classList.remove("alternate");
  767. }
  768. }
  769. }
  770. // Hack to workaround the fact that safari doesn't
  771. // properly recolor the scrollbar when toggling (#1455)
  772. if (navigator.userAgent.indexOf('Safari') > 0 && navigator.userAgent.indexOf('Chrome') == -1) {
  773. manageTransitions("body", false);
  774. window.scrollTo(0, 1);
  775. setTimeout(() => {
  776. window.scrollTo(0, 0);
  777. manageTransitions("body", true);
  778. }, 40);
  779. }
  780. }
  781. const isFileUrl = () => {
  782. return window.location.protocol === 'file:';
  783. }
  784. const hasAlternateSentinel = () => {
  785. let styleSentinel = getColorSchemeSentinel();
  786. if (styleSentinel !== null) {
  787. return styleSentinel === "alternate";
  788. } else {
  789. return false;
  790. }
  791. }
  792. const setStyleSentinel = (alternate) => {
  793. const value = alternate ? "alternate" : "default";
  794. if (!isFileUrl()) {
  795. window.localStorage.setItem("quarto-color-scheme", value);
  796. } else {
  797. localAlternateSentinel = value;
  798. }
  799. }
  800. const getColorSchemeSentinel = () => {
  801. if (!isFileUrl()) {
  802. const storageValue = window.localStorage.getItem("quarto-color-scheme");
  803. return storageValue != null ? storageValue : localAlternateSentinel;
  804. } else {
  805. return localAlternateSentinel;
  806. }
  807. }
  808. let localAlternateSentinel = 'default';
  809. // Dark / light mode switch
  810. window.quartoToggleColorScheme = () => {
  811. // Read the current dark / light value
  812. let toAlternate = !hasAlternateSentinel();
  813. toggleColorMode(toAlternate);
  814. setStyleSentinel(toAlternate);
  815. };
  816. // Ensure there is a toggle, if there isn't float one in the top right
  817. if (window.document.querySelector('.quarto-color-scheme-toggle') === null) {
  818. const a = window.document.createElement('a');
  819. a.classList.add('top-right');
  820. a.classList.add('quarto-color-scheme-toggle');
  821. a.href = "";
  822. a.onclick = function() { try { window.quartoToggleColorScheme(); } catch {} return false; };
  823. const i = window.document.createElement("i");
  824. i.classList.add('bi');
  825. a.appendChild(i);
  826. window.document.body.appendChild(a);
  827. }
  828. // Switch to dark mode if need be
  829. if (hasAlternateSentinel()) {
  830. toggleColorMode(true);
  831. } else {
  832. toggleColorMode(false);
  833. }
  834. const icon = "";
  835. const anchorJS = new window.AnchorJS();
  836. anchorJS.options = {
  837. placement: 'right',
  838. icon: icon
  839. };
  840. anchorJS.add('.anchored');
  841. const isCodeAnnotation = (el) => {
  842. for (const clz of el.classList) {
  843. if (clz.startsWith('code-annotation-')) {
  844. return true;
  845. }
  846. }
  847. return false;
  848. }
  849. const clipboard = new window.ClipboardJS('.code-copy-button', {
  850. text: function(trigger) {
  851. const codeEl = trigger.previousElementSibling.cloneNode(true);
  852. for (const childEl of codeEl.children) {
  853. if (isCodeAnnotation(childEl)) {
  854. childEl.remove();
  855. }
  856. }
  857. return codeEl.innerText;
  858. }
  859. });
  860. clipboard.on('success', function(e) {
  861. // button target
  862. const button = e.trigger;
  863. // don't keep focus
  864. button.blur();
  865. // flash "checked"
  866. button.classList.add('code-copy-button-checked');
  867. var currentTitle = button.getAttribute("title");
  868. button.setAttribute("title", "Copied!");
  869. let tooltip;
  870. if (window.bootstrap) {
  871. button.setAttribute("data-bs-toggle", "tooltip");
  872. button.setAttribute("data-bs-placement", "left");
  873. button.setAttribute("data-bs-title", "Copied!");
  874. tooltip = new bootstrap.Tooltip(button,
  875. { trigger: "manual",
  876. customClass: "code-copy-button-tooltip",
  877. offset: [0, -8]});
  878. tooltip.show();
  879. }
  880. setTimeout(function() {
  881. if (tooltip) {
  882. tooltip.hide();
  883. button.removeAttribute("data-bs-title");
  884. button.removeAttribute("data-bs-toggle");
  885. button.removeAttribute("data-bs-placement");
  886. }
  887. button.setAttribute("title", currentTitle);
  888. button.classList.remove('code-copy-button-checked');
  889. }, 1000);
  890. // clear code selection
  891. e.clearSelection();
  892. });
  893. function tippyHover(el, contentFn) {
  894. const config = {
  895. allowHTML: true,
  896. content: contentFn,
  897. maxWidth: 500,
  898. delay: 100,
  899. arrow: false,
  900. appendTo: function(el) {
  901. return el.parentElement;
  902. },
  903. interactive: true,
  904. interactiveBorder: 10,
  905. theme: 'quarto',
  906. placement: 'bottom-start'
  907. };
  908. window.tippy(el, config);
  909. }
  910. const noterefs = window.document.querySelectorAll('a[role="doc-noteref"]');
  911. for (var i=0; i<noterefs.length; i++) {
  912. const ref = noterefs[i];
  913. tippyHover(ref, function() {
  914. // use id or data attribute instead here
  915. let href = ref.getAttribute('data-footnote-href') || ref.getAttribute('href');
  916. try { href = new URL(href).hash; } catch {}
  917. const id = href.replace(/^#\/?/, "");
  918. const note = window.document.getElementById(id);
  919. return note.innerHTML;
  920. });
  921. }
  922. let selectedAnnoteEl;
  923. const selectorForAnnotation = ( cell, annotation) => {
  924. let cellAttr = 'data-code-cell="' + cell + '"';
  925. let lineAttr = 'data-code-annotation="' + annotation + '"';
  926. const selector = 'span[' + cellAttr + '][' + lineAttr + ']';
  927. return selector;
  928. }
  929. const selectCodeLines = (annoteEl) => {
  930. const doc = window.document;
  931. const targetCell = annoteEl.getAttribute("data-target-cell");
  932. const targetAnnotation = annoteEl.getAttribute("data-target-annotation");
  933. const annoteSpan = window.document.querySelector(selectorForAnnotation(targetCell, targetAnnotation));
  934. const lines = annoteSpan.getAttribute("data-code-lines").split(",");
  935. const lineIds = lines.map((line) => {
  936. return targetCell + "-" + line;
  937. })
  938. let top = null;
  939. let height = null;
  940. let parent = null;
  941. if (lineIds.length > 0) {
  942. //compute the position of the single el (top and bottom and make a div)
  943. const el = window.document.getElementById(lineIds[0]);
  944. top = el.offsetTop;
  945. height = el.offsetHeight;
  946. parent = el.parentElement.parentElement;
  947. if (lineIds.length > 1) {
  948. const lastEl = window.document.getElementById(lineIds[lineIds.length - 1]);
  949. const bottom = lastEl.offsetTop + lastEl.offsetHeight;
  950. height = bottom - top;
  951. }
  952. if (top !== null && height !== null && parent !== null) {
  953. // cook up a div (if necessary) and position it
  954. let div = window.document.getElementById("code-annotation-line-highlight");
  955. if (div === null) {
  956. div = window.document.createElement("div");
  957. div.setAttribute("id", "code-annotation-line-highlight");
  958. div.style.position = 'absolute';
  959. parent.appendChild(div);
  960. }
  961. div.style.top = top - 2 + "px";
  962. div.style.height = height + 4 + "px";
  963. let gutterDiv = window.document.getElementById("code-annotation-line-highlight-gutter");
  964. if (gutterDiv === null) {
  965. gutterDiv = window.document.createElement("div");
  966. gutterDiv.setAttribute("id", "code-annotation-line-highlight-gutter");
  967. gutterDiv.style.position = 'absolute';
  968. const codeCell = window.document.getElementById(targetCell);
  969. const gutter = codeCell.querySelector('.code-annotation-gutter');
  970. gutter.appendChild(gutterDiv);
  971. }
  972. gutterDiv.style.top = top - 2 + "px";
  973. gutterDiv.style.height = height + 4 + "px";
  974. }
  975. selectedAnnoteEl = annoteEl;
  976. }
  977. };
  978. const unselectCodeLines = () => {
  979. const elementsIds = ["code-annotation-line-highlight", "code-annotation-line-highlight-gutter"];
  980. elementsIds.forEach((elId) => {
  981. const div = window.document.getElementById(elId);
  982. if (div) {
  983. div.remove();
  984. }
  985. });
  986. selectedAnnoteEl = undefined;
  987. };
  988. // Attach click handler to the DT
  989. const annoteDls = window.document.querySelectorAll('dt[data-target-cell]');
  990. for (const annoteDlNode of annoteDls) {
  991. annoteDlNode.addEventListener('click', (event) => {
  992. const clickedEl = event.target;
  993. if (clickedEl !== selectedAnnoteEl) {
  994. unselectCodeLines();
  995. const activeEl = window.document.querySelector('dt[data-target-cell].code-annotation-active');
  996. if (activeEl) {
  997. activeEl.classList.remove('code-annotation-active');
  998. }
  999. selectCodeLines(clickedEl);
  1000. clickedEl.classList.add('code-annotation-active');
  1001. } else {
  1002. // Unselect the line
  1003. unselectCodeLines();
  1004. clickedEl.classList.remove('code-annotation-active');
  1005. }
  1006. });
  1007. }
  1008. const findCites = (el) => {
  1009. const parentEl = el.parentElement;
  1010. if (parentEl) {
  1011. const cites = parentEl.dataset.cites;
  1012. if (cites) {
  1013. return {
  1014. el,
  1015. cites: cites.split(' ')
  1016. };
  1017. } else {
  1018. return findCites(el.parentElement)
  1019. }
  1020. } else {
  1021. return undefined;
  1022. }
  1023. };
  1024. var bibliorefs = window.document.querySelectorAll('a[role="doc-biblioref"]');
  1025. for (var i=0; i<bibliorefs.length; i++) {
  1026. const ref = bibliorefs[i];
  1027. const citeInfo = findCites(ref);
  1028. if (citeInfo) {
  1029. tippyHover(citeInfo.el, function() {
  1030. var popup = window.document.createElement('div');
  1031. citeInfo.cites.forEach(function(cite) {
  1032. var citeDiv = window.document.createElement('div');
  1033. citeDiv.classList.add('hanging-indent');
  1034. citeDiv.classList.add('csl-entry');
  1035. var biblioDiv = window.document.getElementById('ref-' + cite);
  1036. if (biblioDiv) {
  1037. citeDiv.innerHTML = biblioDiv.innerHTML;
  1038. }
  1039. popup.appendChild(citeDiv);
  1040. });
  1041. return popup.innerHTML;
  1042. });
  1043. }
  1044. }
  1045. });
  1046. </script>
  1047. </div> <!-- /content -->
  1048. <script data-goatcounter="https://piret-bookdata.goatcounter.com/count" async="" src="//gc.zgo.at/count.js"></script>
  1049. </body></html>
Tip!

Press p or to see the previous file or, n or to see the next file

Comments

Loading...