-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathindex.html
2650 lines (2444 loc) · 95.9 KB
/
index.html
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
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>From LOD to LOUD: making data usable</title>
<meta name="description" content="Workshop at SWIB18">
<meta name="author" content="Adrian Pohl">
<meta name="author" content="Pascal Christoph">
<meta name="author" content="Fabian Steeg">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no, minimal-ui">
<script type="application/ld+json">
{
"@context": "http://schema.org",
"id" : "https://hbz.github.io/swib18-workshop/",
"type": "PresentationDigitalDocument",
"name" : "From LOD to LOUD: making data usable",
"creator" : [{
"id": "http://lobid.org/team/ap#!",
"type": "Person",
"name": "Adrian Pohl"
},
{
"id": "http://lobid.org/team/pc#!",
"type": "Person",
"name": "Pascal Christoph"
},
{
"id": "http://lobid.org/team/fs#!",
"type": "Person",
"name": "Fabian Steeg"
}],
"description": "These are the accompanying slides for the SWIB18 workshop \"From LOD to LOUD: making data usable\".",
"about" : [ "lobid", "libraries", "linked open data", "APIs", "JSON-LD" ],
"datePublished" : "2018-11-26",
"inLanguage" : "en",
"audience": [ "librarians", "developers" ],
"license": "https://creativecommons.org/licenses/by/4.0/"
}
</script>
<link rel="stylesheet" href="css/reveal.css">
<link rel="stylesheet" href="css/theme/hbz.css" id="theme">
<!-- Code syntax highlighting -->
<link rel="stylesheet" href="lib/css/zenburn.css">
<!-- Printing and PDF exports -->
<script>
var link = document.createElement( 'link' );
link.rel = 'stylesheet';
link.type = 'text/css';
link.href = window.location.search.match( /print-pdf/gi ) ? 'css/print/pdf.css' : 'css/print/paper.css';
document.getElementsByTagName( 'head' )[0].appendChild( link );
</script>
<!--[if lt IE 9]>
<script src="lib/js/html5shiv.js"></script>
<![endif]-->
<style>
pre { white-space: pre-wrap; }
#footer-left {
position: absolute;
bottom: 1%;
left: 0.5%;
color: lightgray;
font-family: sans-serif;
}
</style>
</head>
<div id="footer-left"></div>
<body>
<div class="reveal">
<!-- Any section element inside of this container is displayed as a slide -->
<div class="slides">
<section data-state="adrian">
<h2>From LOD to LOUD: <br/>making data usable</h2>
<h4>Workshop at SWIB18</h4>
<p>
<small>
<a href="http://fsteeg.com/">Fabian Steeg</a> /
<a href="https://twitter.com/fsteeg">@fsteeg</a> &
<a href="http://www.uebertext.org/">Adrian Pohl</a> /
<a href="https://twitter.com/acka47">@acka47</a> &
<a href="http://www.dr0i.de/">Pascal Christoph</a> /
<a href="https://twitter.com/dr0ide">@dr0ide</a> <br/>
<a href="http://lobid.org/team">Linked Open Data, Hochschulbibliothekszentrum NRW (hbz)</a> </small> <br/>
<a href="https://lobid.org"><img src="img/lobid.png" style="border: none; padding: 5px; background-color: white" width="125px" /></a><br/>
<small>Bonn, 2018-11-26</small>
</p>
<p>
This presentation: <br /> <a
href="http://hbz.github.io/swib18-workshop">http://hbz.github.io/swib18-workshop</a>
<br/>
<a rel="license" href="http://creativecommons.org/licenses/by/4.0/"><img alt="Creative Commons License" style="border-width:0" src="img/cc-by.png" title="Licensed under a Creative Commons Attribution 4.0 International License"></a>
</p>
</section>
<section data-state="adrian">
<h2>Overview</h2>
<table>
<tr><th width="25%"/><th width="50%"/><th width="25%"/></tr>
<tr><td><b>Part I</b></td><td>Convert RDF data into usable JSON-LD</td><td>13:15-15:00</td></tr>
<tr><td><b>Part II</b></td><td>Index and access the data with Elasticsearch</td><td>15:00-16:30</td></tr>
<tr><td><b><i>Break</i></b></td><td><i>Cake</i></td><td><i>15:30-16:00</i></td></tr>
<tr><td><b>Part III</b></td><td>Use the data to build a web application</td><td>16:30-17:30</td></tr>
<tr><td><b>Part IV</b></td><td>Use the data in existing tools: Kibana, OpenRefine</td><td>17:30-18:45</td></tr>
</table>
</section>
<section data-state="adrian">
<h1>Our background & experience</h1>
</section>
<section data-state="adrian">
<img src="img/hbz.png" style="border: none; box-shadow: none;background-color: white; height: 100px; padding:10px" />
<p><span class="fragment">Hochschulbibliothekszentrum des Landes Nordrhein-Westfalen, est. 1973</span></p>
<p><span class="fragment">= Academic library center of North Rhine-Westphalia</span></p>
<p><span class="fragment">Software services for libraries in NRW and beyond</span></p>
<p><span class="fragment">E.g. union catalog, discovery portal DigiBib, ILL, digitization & digital preservation, consortial acquisition</span></p>
<p><span class="fragment">SWIB co-organizer</span></p>
<p><span class="fragment"><a href="https://www.hbz-nrw.de/service/mediathek/flyer/hbz-product-scope/at_download/file">hbz flyer in English (PDF)</a></span></p>
</section>
<section data-state="adrian">
<img src="img/lobid.png" style="border: none; box-shadow: none;background-color: white; height: 100px; padding:10px" />
<p><span class="fragment">lobid: hbz's LOD service, providing bibliographic data, authorities & organizations</span></p>
<p><span class="fragment">Started 2010 with open data publication, triple store & Perl transformation script</span></p>
<p><span class="fragment">Original team: Adrian, Pascal, Felix. Fabian joined in 2012.</span></p>
<p><span class="fragment">2013: First API release based on JSON-LD & Elasticsearch</span></p>
<p><span class="fragment">2017–2018: LOUD with lobid API 2.0</span></p>
<span class="fragment"><h4><a href="http://lobid.org/team">http://lobid.org/team</a> | <a href="http://blog.lobid.org">http://blog.lobid.org</a></h4></span>
</section>
<section data-state="adrian">
<h1>Your background & experience</h1>
<span class="fragment"><p>RDF?</p></span>
<span class="fragment"><p>Bulk data processing?</p></span>
<span class="fragment"><p>Command line?</p></span>
<span class="fragment"><p>Software development?</p></span>
</section>
<section data-state="adrian">
<h2>LOUD</h2>
<a href="https://twitter.com/azaroth42/status/768140561794502656"><img src="img/loud-tweet.png" style="border: none; box-shadow: none;background-color: white; width: 700px; padding:10px" /></a>
<span class="fragment"><p>Term coined by Robert Sanderson in 2016 (see also his <a href="https://de.slideshare.net/azaroth42/community-challenges-for-practical-linked-open-data-linked-pasts-keynote">Linked Pasts Keynote</a>)</p></span>
</section>
<section data-state="adrian">
<h2>Linked Open Usable Data (LOUD)</h2>
<span class="fragment"><p>Core idea: to make your data useful you have to know and cater to your audience</p></span>
<span class="fragment"><p>Primary audience of LOD: people developing (1st and 2nd party) or using (3rd party) <i>software</i> to access the data</p></span>
<span class="fragment"><p>LOUD: oriented towards the needs and conventions for developing software</p></span>
</section>
<section data-state="adrian">
<a href="https://www.slideshare.net/azaroth42/europeanatech-keynote-shout-it-out-loud/22"><img src="img/sanderson-2018-loud-22.png" width=800 /></a>
<p><font size="3">Source: <a href="https://www.slideshare.net/azaroth42/europeanatech-keynote-shout-it-out-loud">Rob Sanderson, "Shout it Out: LOUD"</a>, CC-BY (<a href="https://youtu.be/r4afi8mGVAY?t=1112">video</a>)</font></p>
</section>
<section data-state="adrian">
<a href="https://www.slideshare.net/azaroth42/europeanatech-keynote-shout-it-out-loud/22"><img src="img/sanderson-2018-loud-32.png" width=800 /></a>
<p><font size="3">Source: <a href="https://www.slideshare.net/azaroth42/europeanatech-keynote-shout-it-out-loud">Rob Sanderson, "Shout it Out: LOUD"</a>, CC-BY (<a href="https://youtu.be/r4afi8mGVAY?t=1910">video</a>)</font></p>
</section>
<section data-state="adrian">
<h2>Design for JSON-LD <br/><i>from RDF</i>, consistently</h2>
<span class="fragment"><p>(Our background & this workshop: we start with RDF data)</p></span>
</section>
<section data-state="fabian">
<h2>Part I:<br><small>Convert RDF data into usable JSON-LD</small></h2>
<table>
<tr><th width="38%"/><th width="39%"/><th width="25%"/></tr>
<tr><td><b>Usable data & APIs</b></td><td>Application Programming Interfaces: why, how</td><td>13:00-13:15</td></tr>
<tr><td><b>JSON APIs</b></td><td>Using the GitHub API, processing JSON</td><td>13:15-14:00</td></tr>
<tr><td><b>From RDF to JSON</b></td><td>JSON-LD processing with jsonld.js via jsonld-cli</td><td>14:00-15:00</td></tr>
</table>
</section>
<section data-state="fabian">
<p>Part Ia.</p>
<blockquote><h2>Usable data & APIs</h2></blockquote>
<blockquote><h2>APIs: why, how</h2></blockquote>
</section>
<section data-state="fabian">
<blockquote><p>Usable data [& APIs]</p></blockquote>
<span class="fragment"><h1>Data is used with software</h1></span>
<span class="fragment"><p>Build new software with the data</p></span>
<span class="fragment"><p>Use existing software with the data</p></span>
</section>
<section data-state="fabian">
<h1>Libraries are Software</h1>
<blockquote>Our collections and services are delivered primarily via software. [...] The choices we make in the development,
selection, and implementation of this software [...] define the limits of our content and services. We can only be as good as our software.</blockquote>
<blockquote> — Cody Hanson, <a href="http://codyhanson.com/writing/software.html">Libraries are Software</a></blockquote>
</section>
<section data-state="fabian">
<blockquote><p>[Usable data &] APIs</p></blockquote>
<span class="fragment"><h1>Software <br/>requires APIs</h1></span>
<span class="fragment"><h4>APIs make software development manageable <br/>(for 1st and 2nd party software)</h4></span>
<span class="fragment"><h4>APIs enable usage and integration of 3rd party software</h4></span>
</section>
<section data-state="fabian">
<h3>e.g. lobid sources, formats, applications</h3>
<img src="img/data.png" style="border: none; box-shadow: none;" /> <span
class="fragment"><h4>APIs decouple applications from
specific data sources, formats, and systems. They enable modular, sustainable applications.</h4></span>
</section>
<section data-state="fabian">
<blockquote><h1>API: why?</h1></blockquote>
<span class="fragment"><blockquote><p><a href='https://www.slideshare.net/azaroth42/europeanatech-keynote-shout-it-out-loud/22'>★ </a>Right abstraction for the audience</p></blockquote></span>
<span class="fragment"><blockquote><p>Data is used with software</p></blockquote></span>
<span class="fragment"><blockquote><p>Software requires APIs</p></blockquote></span>
</section>
<section data-state="fabian">
<blockquote><h1>API: why?</h1></blockquote>
<span class="fragment"><h1>Usable data <br/>is data with APIs</h1></span>
</section>
<section data-state="fabian">
<blockquote><h1>API: how?</h1></blockquote>
<span class="fragment"><blockquote><h2><a href='https://www.slideshare.net/azaroth42/europeanatech-keynote-shout-it-out-loud/32'>3. </a>Don't break the web</h2></blockquote></span>
</section>
<section data-state="fabian">
<blockquote><h1>API: how?</h1></blockquote>
<span class="fragment"><h1>JSON over HTTP</h1></span>
<span class="fragment"><h3><a href="https://twobithistory.org/2017/09/21/the-rise-and-rise-of-json.html">standard web API format since years</a></h3></span>
<span class="fragment"><h4>e.g. <a href='https://api.github.com/'> https://api.github.com/</a></h4></span>
</section>
<section data-state="fabian">
<h2>GET https://api.github.com</h2>
<pre><code class="json" data-trim>
{
"current_user_url": "https://api.github.com/user",
"authorizations_url": "https://api.github.com/authorizations",
"emails_url": "https://api.github.com/user/emails",
"emojis_url": "https://api.github.com/emojis",
"events_url": "https://api.github.com/events",
"feeds_url": "https://api.github.com/feeds",
"followers_url": "https://api.github.com/user/followers",
"gists_url": "https://api.github.com/gists{/gist_id}",
"hub_url": "https://api.github.com/hub",
...
}
</code></pre>
</section>
<section data-state="fabian">
<p>Part Ib.</p>
<blockquote><h2>JSON APIs</h2></blockquote>
<blockquote><h2>Using the GitHub API, processing JSON</h2></blockquote>
</section>
<section data-state="pascal">
<h1>Setup</h1>
<span class="fragment"><p><a href='https://github.com/hbz/swib18-workshop#setup'>https://github.com/hbz/swib18-workshop#setup</a></p></span>
<span class="fragment"><p>($ git pull origin master)</p></span>
</section>
<section data-state="fabian">
<h1>cURL</h1>
<p><span class="fragment">Command line tool for transferring data with URLs</span></p>
<p><span class="fragment"><a href="https://curl.haxx.se/download.html" target="_blank">https://curl.haxx.se/download.html</a></span></p>
<span class="fragment">
<pre><code class="bash">$ curl --help</code></pre>
<p><font size="5">('$' <i>means you should type this in your terminal application</i>)</font></p>
</span>
</section>
<section data-state="fabian">
<h2>Exercise 1a: cURL</h2>
<table style="border: 1px solid white; table-layout:fixed; width: 100%">
<col width="10%" />
<col width="90%" />
<tbody>
<tr>
<td>cURL</td>
<td>
<pre><code class="bash" data-trim>
$ curl https://api.github.com
</code></pre>
</td>
</tr>
<tr>
<td>Paste</td>
<td>
<pre><code class="bash" data-trim>
# Copy above, paste in terminal
$ curl https://api.github.com
</code></pre>
</td>
</tr>
<tr>
<td>History</td>
<td>
<pre><code class="bash" data-trim>
$ ↑ # access the history
$ curl https://api.github.com
</code></pre>
</td>
</tr>
</tbody>
</table>
<p><font size="5"><i>(You can copy and paste in the terminal with Shift+Ctrl+C and Shift+Ctrl+V)</i></font></p>
</section>
<section data-state="fabian">
<h2>Exercise 1b: cURL</h2>
<table style="border: 1px solid white; table-layout:fixed; width: 100%">
<col width="10%" />
<col width="90%" />
<tbody>
<tr>
<td>Profile</td>
<td>
<pre><code class="bash" data-trim>
$ curl https://api.github.com/<???> # user or org
</code></pre>
</td>
</tr>
<tr>
<td>Repo</td>
<td>
<pre><code class="bash" data-trim>
$ curl https://api.github.com/<???>
</code></pre>
</td>
</tr>
</tbody>
</table>
<p><font size="5">('<???>' <i>means you should insert your solution here</i>)</font></p>
<p>We have a repo for this workshop called 'swib18-workshop' under the 'hbz' organization</p>
</section>
<section data-state="fabian">
<h2>Exercise 1c: cURL<br/> Solution</h2>
<table style="border: 1px solid white; table-layout:fixed; width: 100%">
<col width="10%" />
<col width="90%" />
<tbody>
<tr>
<td>Profile</td>
<td>
<pre><code class="bash" data-trim>
$ curl https://api.github.com/users/hbz
</code></pre>
</td>
</tr>
<tr>
<td>Repo</td>
<td>
<pre><code class="bash" data-trim>
$ curl https://api.github.com/repos/hbz/swib18-workshop
</code></pre>
</td>
</tr>
</tbody>
</table>
</code></pre>
<p><font size="5">('$' <i>means you should type this in your terminal application</i>)</font></p>
</section>
<section data-state="fabian">
<h2>Response</h2>
<pre><code class="json" data-trim>
$ curl https://api.github.com/repos/hbz/swib18-workshop
{
"id": 150073510,
"node_id": "MDEwOlJlcG9zaXRvcnkxNTAwNzM1MTA=",
"name": "swib18-workshop",
"full_name": "hbz/swib18-workshop",
"private": false,
"owner": {
"login": "hbz",
"id": 6557108,
"node_id": "MDEyOk9yZ2FuaXphdGlvbjY1NTcxMDg=",
"avatar_url": "https://avatars3.githubusercontent.com/u/6557108?v=4",
"gravatar_id": "",
</code></pre>
<p>Output is quite long, we often want specific values</p>
</section>
<section data-state="fabian">
<h2>JavaScript Object Notation (JSON)</h2>
<span class="fragment"><pre><code class="javascript" data-trim>
var options = {
url: 'https://api.github.com/repos/hbz/swib18-workshop',
headers: { 'User-Agent': 'hbz' }
};
request(options, function (error, response, body) {
var doc = JSON.parse(body);
console.log('repo license:', doc.license.name) // <-- use JSON
});
</code></pre></span>
<span class="fragment"><pre><code class="nohighlight" data-trim>
> license.name: Creative Commons Attribution 4.0 International
</code></pre></span>
</section>
<section data-state="fabian">
<h1>jq</h1>
<p><span class="fragment">A lightweight and flexible command-line JSON processor</span></p>
<p><span class="fragment"><a href="https://stedolan.github.io/jq/" target="_blank">https://stedolan.github.io/jq/</a></span></p>
<p><span class="fragment"><a href="https://jqplay.org/">https://jqplay.org/</a></span></p>
<span class="fragment">
<pre><code class="bash">$ jq --help</code></pre>
<p><font size="5">('$' <i>means you should type this in your terminal application</i>)</font></p>
</span>
</section>
<section data-state="fabian">
<h2>Exercise 2a: JSON with jq</h2>
<pre><code class="bash" data-trim>
$ curl https://api.github.com/repos/hbz/swib18-workshop \
| jq .name # filter: .name
</code></pre>
<p><font size="5">('$' <i>means you should type this in your terminal application</i>)</font></p>
</section>
<section data-state="fabian">
<h2>Exercise 2b: JSON with jq</h2>
<table style="border: 1px solid white; table-layout:fixed; width: 100%">
<col width="10%" />
<col width="90%" />
<tbody>
<tr>
<td>Issues</td>
<td>
<pre><code class="bash" data-trim>
$ curl https://api.github.com/repos/hbz/swib18-workshop | jq <???> # get the number of open issues
</code></pre>
</td>
</tr>
<tr>
<td>License</td>
<td>
<pre><code class="bash" data-trim>
$ curl https://api.github.com/repos/hbz/swib18-workshop | jq <???> # get the repo's license name
</code></pre>
</td>
</tr>
</tbody>
</table>
<p><font size="5">('<???>' <i>means you should insert your solution here</i>)</font></p>
</section>
<section data-state="fabian">
<h2>Exercise 2c: JSON with jq</h2>
<table style="border: 1px solid white; table-layout:fixed; width: 100%">
<col width="10%" />
<col width="90%" />
<tbody>
<tr>
<td>Issues</td>
<td>
<pre><code class="bash" data-trim>
$ curl https://api.github.com/repos/hbz/swib18-workshop | jq .open_issues_count
</code></pre>
</td>
</tr>
<tr>
<td>License</td>
<td>
<pre><code class="bash" data-trim>
$ curl https://api.github.com/repos/hbz/swib18-workshop | jq .license.name
</code></pre>
</td>
</tr>
</tbody>
</table>
<p><font size="5">('$' <i>means you should type this in your terminal application</i>)</font></p>
</section>
<section data-state="fabian">
<h1>So JSON is great.</h1>
<span class="fragment"><h1>But what if we have <a href="http://id.loc.gov/download/">RDF</a> data?</h1></span>
</section>
<section data-state="fabian">
<p>Part Ic.</p>
<blockquote><h2>From RDF to JSON</h2></blockquote>
<blockquote><h2>JSON-LD processing with jsonld.js via jsonld-cli</h2></blockquote>
</section>
<section data-state="adrian">
<h2>Bibframe datasets (N-Triples)</h2>
<a href="http://id.loc.gov/download/"><img src="img/loc-downloads.png" style="border: none; box-shadow: none;" /></a>
</section>
<section data-state="adrian">
<a href="https://listserv.loc.gov/cgi-bin/wa?A2=BIBFRAME;3141fdaf.1806"><img src="img/bibframe-bulk-email.png" style="border: none; box-shadow: none;" /></a>
</section>
<section data-state="adrian">
<h2>Example work</h2>
<a href="http://rdf-translator.appspot.com/convert/nt/nt/html/https%3A%2F%2Fraw.githubusercontent.com%2Fhbz%2Fswib18-workshop%2Fmaster%2Fdata%2Floc.nt"><img src="img/nt.png" style="border: none; box-shadow: none;" /></a>
<small>Source file: <a href="https://github.com/hbz/swib18-workshop/blob/master/data/loc.nt">https://github.com/hbz/swib18-workshop/blob/master/data/loc.nt</a></small>
</section>
<section data-state="fabian">
<h1>JSON-LD</h1>
<span class="fragment"><p>"designed to be usable directly as JSON, with no knowledge of RDF" — it's real JSON!</p></span>
<span class="fragment"><p>"also designed to be usable as RDF"</p></span>
<span class="fragment"><p><a href="https://www.w3.org/TR/json-ld/">https://www.w3.org/TR/json-ld/</a></p></span>
</section>
<section data-state="fabian">
<h1><blockquote><a href='https://www.slideshare.net/azaroth42/europeanatech-keynote-shout-it-out-loud/32'>5. </a>Design for JSON-LD, consistently</blockquote></h1>
</section>
<section data-state="fabian">
<h1>Great, so let's make JSON-LD from RDF</h1>
</section>
<section data-state="fabian">
<h1>jsonld-cli</h1>
<p><span class="fragment">JSON-LD command line interface tool</span></p>
<p><span class="fragment"><a href="https://github.com/hbz/jsonld-cli" target="_blank">https://github.com/hbz/jsonld-cli</a></span></p>
<p><span class="fragment">Our fork of https://github.com/digitalbazaar/jsonld-cli, added import from N-Quads</p>
<span class="fragment">
<pre><code class="bash">$ jsonld --help</code></pre>
<p><font size="5">('$' <i>means you should type this in your terminal application</i>)</font></p>
</span>
</section>
<section data-state="fabian">
<h2>Exercise 3:<br/>N-Triples to JSON-LD</h2>
<table style="border: 1px solid white; table-layout:fixed; width: 100%">
<col width="20%" />
<col width="80%" />
<tbody>
<tr>
<td>Location</td>
<td>
<pre><code class="bash" data-trim>
$ cd ~/git/swib18-workshop/data
</code></pre>
</td>
</tr>
<tr>
<td>Import</td>
<td>
<pre><code class="bash" data-trim>
$ jsonld import loc.nt
</code></pre>
</td>
</tr>
<tr>
<td>Write</td>
<td>
<pre><code class="bash" data-trim>
$ jsonld import loc.nt > loc.json
</code></pre>
</td>
</tr>
</tbody>
</table>
<p><font size="5">('$' <i>means you should type this in your terminal application</i>)</font></p>
</section>
<section data-state="fabian">
<h2>Result</h2>
<pre><code class="json" data-trim>
{
"@id": "http://id.loc.gov/resources/works/c000101650",
"http://id.loc.gov/ontologies/bibframe/subject": [{
"@id": "http://id.loc.gov/resources/works/101650#Topic650-20"
}, ...]
}, {
"@id": "http://id.loc.gov/resources/works/101650#Topic650-20",
"@type": [
"http://id.loc.gov/ontologies/bibframe/Topic",
"http://www.loc.gov/mads/rdf/v1#ComplexSubject"
],
"http://www.w3.org/2000/01/rdf-schema#label": [{
"@value": "Climatic changes--Europe."
}],...
}
</code></pre>
<p><a href='http://hbz.github.io/swib18-workshop/data/index.html#jsonld-output'>Serialized RDF as JSON-LD</a> | <a href='https://www.w3.org/TR/json-ld11-api/#serialize-rdf-as-json-ld-algorithm'>Specification</a></p>
</section>
<section data-state="fabian">
<h2>Exercise 3a:<br/><small>Use serialized RDF to access subjects</small></h2>
<table style="border: 1px solid white; table-layout:fixed; width: 100%">
<col width="15%" />
<col width="85%" />
<tbody>
<tr>
<td>Identify field</td>
<td>
<pre><code class="bash" data-trim>
$ cat loc.json | less
</code></pre>
</td>
</tr>
<tr>
<td>Access field</td>
<td>
<pre><code class="bash" data-trim>
# like .license.name, but for subject labels?
$ cat loc.json | jq <???>
</code></pre>
</td>
</tr>
</tbody>
</table>
<span class="fragment"><p>`http://www.w3.org/2000/01/rdf-schema#label`.`@value`?</p></span>
<span class="fragment"><p>Can't work: we have just a flat array of objects, which label?</p></span>
<span class="fragment"><p>Problem: only <i>technically</i> JSON, but not <i>usable</i></p></span>
</section>
<section data-state="fabian">
<blockquote><p>So JSON is great?</p></blockquote>
<span class="fragment"><h1>Worst of both worlds</h1></span>
<span class="fragment"><p>Unwieldy URIs as keys from RDF</p></span>
<span class="fragment"><p>Syntactic overhead from JSON</p></span>
<span class="fragment"><p>Bad readability & usability</p></span>
</section>
<section data-state="fabian">
<h2>Result</h2>
<pre><code class="json" data-trim>
{
"@id": "http://id.loc.gov/resources/works/c000101650",
"http://id.loc.gov/ontologies/bibframe/subject": [{
"@id": "http://id.loc.gov/resources/works/101650#Topic650-20"
}, ...]
}, {
"@id": "http://id.loc.gov/resources/works/101650#Topic650-20",
"@type": [
"http://id.loc.gov/ontologies/bibframe/Topic",
"http://www.loc.gov/mads/rdf/v1#ComplexSubject"
],
"http://www.w3.org/2000/01/rdf-schema#label": [{
"@value": "Climatic changes--Europe."
}],...
}
</code></pre>
<p><a href='http://hbz.github.io/swib18-workshop/data/index.html#jsonld-output'>Serialized RDF as JSON-LD</a> | <a href='https://www.w3.org/TR/json-ld11-api/#serialize-rdf-as-json-ld-algorithm'>Specification</a></p>
</section>
<section data-state="fabian">
<h2>Data processing vs. API access</h2>
<table style="border: 1px solid white; table-layout:fixed; width: 100%">
<col width="17%" />
<col width="83%" />
<tbody>
<tr>
<td>Data processing</td>
<td>
<pre><code class="javascript" data-trim>
for o in doc :
if o["@type"] contains "http://id.loc.gov/ontologies/bibframe/Topic" :
subjectId = o["http://id.loc.gov/ontologies/bibframe/subject"][0]["@id"] // + error handling
for o in doc :
if o["@id"] == subjectId :
subjectLabel = o["http://www.w3.org/2000/01/rdf-schema#label"]["@value"] // + error handling
</code></pre>
</td>
</tr>
<tr>
<td>API access</td>
<td>
<pre><code class="javascript" data-trim>
doc.license.name // doc.subject.label?
</code></pre>
</td>
</tr>
</tbody>
</table>
</section>
<section data-state="fabian">
<h1>Developer empathy</h1>
<span class="fragment"><blockquote>
When it comes to APIs, developers are your users. The same principles of user-centred-design apply
to the development and publication of APIs (simplicity, obviousness, fit-for-purpose etc).
<small><br/><a href='https://apiguide.readthedocs.io/en/latest/principles/empathy.html'>API Design Guide, Digital Transformation Agency, Australia</a></small></blockquote>
</span>
</section>
<section data-state="fabian">
<h1>Non-developer empathy</h1>
<span class="fragment"><p>Default RDF -> JSON-LD <i>requires</i> programming with loops & conditionals to access a single nested field, the subject label</p></span>
<span class="fragment"><p>Should be as simple as <i>doc.license.name</i></p></span>
<span class="fragment"><p>Not providing an API actually <i>excludes</i> non-developers by putting up barriers for usage with CLI or GUI tools</p></span>
</section>
<section data-state="fabian">
<blockquote><h1><a href='https://www.slideshare.net/azaroth42/europeanatech-keynote-shout-it-out-loud/22'>★ </a>Few barriers to entry</h1></blockquote>
</section>
<section data-state="fabian">
<h1><blockquote>Design for JSON-LD from RDF, consistently</blockquote></h1>
</section>
<section data-state="fabian">
<h1>Framing</h1>
<span class="fragment"><p>Frame the way we look at our graph from the perspective of one entity type (to make it a tree, or a document)</p></span>
<span class="fragment"><p>Look at my data from a "Work" perspective, and embed other entities under their works</p></span>
</section>
<section data-state="fabian">
<h2>Exercise 4:<br/>Framing</h2>
<table style="border: 1px solid white; table-layout:fixed; width: 100%">
<col width="10%" />
<col width="90%" />
<tbody>
<tr>
<td>frame .json</td>
<td>
<pre><code class="javascript" data-trim>
{
"@type": "http://id.loc.gov/ontologies/bibframe/Work",
"@embed": "@always"
}
</code></pre>
</td>
</tr>
<tr>
<td>Frame</td>
<td>
<pre><code class="bash" data-trim>
$ jsonld frame -f frame.json loc.json
</code></pre>
</td>
</tr>
<tr>
<td>Write</td>
<td>
<pre><code class="bash" data-trim>
$ jsonld frame -f frame.json loc.json > loc-framed.json
</code></pre>
</td>
</tr>
</tbody>
</table>
<p><font size="5">('$' <i>means you should type this in your terminal application</i>)</font></p>
</section>
<section data-state="fabian">
<h2>Result</h2>
<pre><code class="json" data-trim>
{
"@id": "http://id.loc.gov/resources/works/c000101650",
"http://id.loc.gov/ontologies/bibframe/subject": [{
"@id":"http://id.loc.gov/resources/works/101650#Topic650-20",
"@type": [
"http://id.loc.gov/ontologies/bibframe/Topic",
"http://www.loc.gov/mads/rdf/v1#ComplexSubject"
],
...
"http://www.w3.org/2000/01/rdf-schema#label": "Climatic changes--Europe."
}, {...}],
}
</code></pre>
<p><a href='http://hbz.github.io/swib18-workshop/data/index.html#jsonld-framed'>Framed JSON-LD</a> | <a href='https://www.w3.org/TR/json-ld11/#framed-document-form'>Specification</a></p>
</section>
<section data-state="fabian">
<h2>Exercise 4a:<br/><small>Use framed JSON-LD to access subjects</small></h2>
<table style="border: 1px solid white; table-layout:fixed; width: 100%">
<col width="13%" />
<col width="87%" />
<tbody>
<tr>
<td>Identify field</td>
<td>
<pre><code class="bash" data-trim>
$ cat loc-framed.json | less
</code></pre>
</td>
</tr>
<tr>
<td>Access field</td>
<td>
<pre><code class="bash" data-trim>
# like .license.name, but for subject labels?
$ cat loc-framed.json | jq <???>
</code></pre>
</td>
</tr>
</tbody>
</table>
<span class="fragment"><p>`http://id.loc.gov/ontologies/bibframe/subject`<br/>.`http://www.w3.org/2000/01/rdf-schema#label`?</p></span>
<span class="fragment"><p>Could work conceptually, but not very handy</p></span>
</section>
<section data-state="fabian">
<blockquote><h1><a href='https://www.slideshare.net/azaroth42/europeanatech-keynote-shout-it-out-loud/32'>2. </a>As simple as possible?</h1></blockquote>
</section>
<section data-state="fabian">
<h1>JSON-LD Context</h1>
<span class="fragment"><p>Mapping of JSON keys to URIs: <br/><code>"@context":{"name":"http://schema.org/name"}</code></p></span>
<span class="fragment"><p>With this context, we can <a href='https://www.w3.org/TR/json-ld11-api/#compaction'>compact</a> (replace URIs with short keys) or
<a href='https://www.w3.org/TR/json-ld11-api/#expansion'>expand</a> (replace short keys with URIs) our JSON-LD</p></span>
<span class="fragment"><p>http://schema.org/name ⇄ name</p></span>
<span class="fragment"><p>`http://id.loc.gov/ontologies/bibframe/subject`<br/>.`http://www.w3.org/2000/01/rdf-schema#label`?</p></span>
</section>
<section data-state="adrian">
<h1>How do we get the context?</h1>
<span class="fragment"><p><a href="https://twitter.com/lobidOrg/status/1044866797067997184">Does LOC or somebody else already provide one?</a> – No.</p></span>
<span class="fragment"><p><a href="https://github.com/hbz/swib18-workshop/issues/2#issuecomment-424710995">Here: context generated from ontologies</a> with (much) manual post-processing</p></span>
<span class="fragment"><p>Alternatives: upfront design or generate from data</p></span>
<span class="fragment"><p>To be discussed in JSON-LD break-out session</p></span>
</section>
<section data-state="fabian">
<h1>Context: more than simple mappings</h1>
<span class="fragment"><p><blockquote><a href='https://www.slideshare.net/azaroth42/europeanatech-keynote-shout-it-out-loud/22'>★</a> Few exceptions, many consistent patterns</blockquote></p></span>
</section>
<section data-state="fabian">
<h1>Consistency</h1>
<span class="fragment"><p>e.g. the <i>contribution</i> field should always be an array, even if a particular record has only one contribution | <a href='https://www.w3.org/TR/json-ld11/#sets'>spec</a></p></span>
<span class="fragment"><p>Other fields, which occur only once for every record can use the default non-array single values</p></span>
<span class="fragment"><p>To have all fields always be arrays: compacting option <a href='https://www.w3.org/TR/json-ld11-api/#dom-jsonldoptions-compactarrays'>compactArrays:false</a></p></span>
<span class="fragment"><p><small>(Consistent field types also required for Elasticsearch indexing)</small></p></span>
</section>
<section data-state="fabian">
<h1>Describing values</h1>
<span class="fragment"><p>e.g. field 'contribution' should always be a JSON array</p></span>
<span class="fragment"><pre><code class="javascript" data-trim>
"contribution": {
"@id": "http://id.loc.gov/ontologies/bibframe/contribution",
"@container": "@set"
}
</pre></code></span>
<span class="fragment"><p><a href="https://www.w3.org/TR/json-ld11/#describing-values">See context specification for details</a></p></span>
</section>
<section data-state="fabian">
<h2>Exercise 5:<br/>Compact</h2>
<table style="border: 1px solid white; table-layout:fixed; width: 100%">
<col width="15%" />
<col width="85%" />
<tbody>
<tr>
<td>Compact</td>
<td>
<pre><code class="bash" data-trim>
$ jsonld compact -c context.json loc-framed.json
</code></pre>
</td>
</tr>
<tr>
<td>Write</td>
<td>
<pre><code class="bash" data-trim>
$ jsonld compact -c context.json loc-framed.json > loc-compact.json
</code></pre>
</td>
</tr>
</tbody>
</table>
<p><font size="5">('$' <i>means you should type this in your terminal application</i>)</font></p>
</section>
<section data-state="fabian">
<h2>Result</h2>
<pre><code class="json" data-trim>
{
"@id": "http://id.loc.gov/resources/works/c000101650",
"subject": [
{
"id": "http://id.loc.gov/resources/works/101650#Topic650-20",
"type": [
"Topic",
"ComplexSubject"
],
"label": "Climatic changes--Europe."
}
], ...
}
</code></pre>
<p><a href='http://hbz.github.io/swib18-workshop/data/index.html#jsonld-compact'>Compacted JSON-LD</a> | <a href='https://www.w3.org/TR/json-ld11/#compacted-document-form'>Specification</a></p>
</section>
<section data-state="fabian">
<h2>Exercise 5a:<br/><small>Use compact JSON-LD to access subjects</small></h2>
<table style="border: 1px solid white; table-layout:fixed; width: 100%">
<col width="13%" />
<col width="87%" />
<tbody>
<tr>
<td>Identify field</td>
<td>
<pre><code class="bash" data-trim>
$ cat loc-compact.json | less
</code></pre>
</td>
</tr>
<tr>
<td>Full Title</td>
<td>
<pre><code class="bash" data-trim>
$ cat loc-compact.json | jq .label
</code></pre>
</td>
</tr>
<tr>
<td>Subject</td>
<td>
<pre><code class="bash" data-trim>
# like .license.name, but for subject labels?
$ cat loc-compact.json | jq <???>
</code></pre>
</td>
</tr>
</tbody>
</table>
<p><font size="5">('$' <i>means you should type this in your terminal application</i>)</font></p>
</section>
<section data-state="fabian">
<h2>Exercise 5a:<br/><small>Solution</small></h2>
<table style="border: 1px solid white; table-layout:fixed; width: 100%">
<col width="13%" />
<col width="87%" />
<tbody>
<tr>
<td>like .license .name?</td>
<td>
<pre><code class="nohighlight" data-trim>
$ cat loc-compact.json | jq .subject.label
jq: error: Cannot index array with string "label"
</code></pre>
</td>
</tr>
<tr>
<td>Access one</td>
<td>
<pre><code class="bash" data-trim>
$ cat loc-compact.json | jq .subject[0].label
</code></pre>
</td>
</tr>
<tr>
<td>Access all</td>
<td>
<pre><code class="bash" data-trim>
$ cat loc-compact.json | jq .subject[].label
</code></pre>
</td>
</tr>
</tbody>
</table>
<p><font size="5">('$' <i>means you should type this in your terminal application</i>)</font></p>
</section>
<section data-state="fabian">
<h1>Missing values in context</h1>
<span class="fragment"><p>Un-mapped URI in the data</p></span>
<span class="fragment"><p>Will still be URI after compaction</p></span>
<span class="fragment"><p>Iterate: compact, check data, fix context, compact again</p></span>
</section>
<section data-state="fabian">
<h2>Exercise 5b: Fix context</h2>
<table style="border: 1px solid white; table-layout:fixed; width: 100%">
<col width="20%" />
<col width="88%" />
<tbody>
<tr>
<td>Check paths</td>
<td>
<pre><code class="bash" data-trim>
$ cat loc-compact.json | jq -c 'path(..)'
</code></pre>
</td>
</tr>
<tr>
<td>Find URIs</td>
<td>
<pre><code class="bash" data-trim>