Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Introduction to Linked Data for Alchemists

Introduction to Linked Data for Alchemists

Talk given at the Elixir-Berlin Meetup

Marcel Otto

March 14, 2019
Tweet

Other Decks in Programming

Transcript

  1. Semantic Web a certain vision for the next web a

    body of standards and technologies an academic research eld
  2. Linked Data principles §3 “When someone looks up a URI,

    provide useful information, using the standards (RDF, SPARQL).”
  3. RDF

  4. Turtle @prefix ex: <http://example.com/> . ex:Berlin ex:name "Berlin" ; ex:capitalOf

    ex:Germany ; ex:population 3575000 ; ex:district ex:Mitte, ex:Kreuzberg ; # ... .
  5. Turtle @prefix : <http://example.com/> . :Berlin :name "Berlin" ; :capitalOf

    :Germany ; :population 3575000 ; :district :Mitte, :Kreuzberg # , ... .
  6. JSON-LD { "@id": "http://example.com/Berlin", "@context": { "name": "http://example.com/name", "capital_of": "http://example.com/capitalOf",

    "population": "http://example.com/population" }, "id": 1, "name": "Berlin", "capital_of": {"id": 2}, "population": 3575000 }
  7. JSON-LD { "@id": "http://example.com/Berlin", "@context": { "name": "http://example.com/name", "capital_of": "http://example.com/capitalOf",

    "population": "http://example.com/population" }, "id": 1, "name": "Berlin", "capital_of": { "@id": "http://example.com/Germany", "id": 2 }, "population": 3575000 }
  8. JSON-LD { "@id": "http://example.com/Berlin", "@context": "http://example.com/context.jsonld", "id": 1, "name": "Berlin",

    "capital_of": { "@id": "http://example.com/Germany", "id": 2 }, "population": 3575000 }
  9. Linked Data principles Rule 4 “Include links to other URIs,

    so that they can discover more things.”
  10. Linking Data wdt:P1376 ... ex:organizer ex:name ex:city ex:Elixir-Berlin-Meetup ex:name wdt:P1448

    "Germany" wdt:P1448 ... wd:Q183 "Hugo Duksis" ... "Berlin" ... wd:Q64 ex:Hugo-Duksis "Elixir Berlin"
  11. SPARQL PREFIX ex: <http://example.com/> SELECT ?capital ?country WHERE { ?x

    ex:cityname ?capital ; ex:isCapitalOf ?y . ?y ex:countryname ?country ; ex:isInContinent ex:Africa . }
  12. Solid “Solid (derived from”social linked data“) is a proposed set

    of conventions and tools for building decentralized social applications based on Linked Data principles.” “The project aims to radically change the way Web applications work today, resulting in true data ownership as well as improved privacy.”
  13. URI namespaces defmodule MyApp.NS do use RDF.Vocabulary.Namespace defvocab EX, base_iri:

    "http://www.example.com/ns/", terms: ~w[Foo bar] end alias MyApp.NS.EX EX.Foo RDFS.subClassOf
  14. RDF descriptions RDF.description(EX.Berlin, [ {EX.name, "Berlin"}, {EX.capitalOf, EX.Germany}, {EX.population, 3575000},

    {EX.district, [EX.Mitte, EX.Kreuzberg]} ] ) EX.Berlin |> EX.name("Berlin") |> EX.capitalOf(EX.Germany) |> EX.population(3575000) |> EX.district(EX.Mitte, EX.Kreuzberg)
  15. RDF graphs graph = RDF.graph [ {EX.ElixirBerlinMeetup, EX.name, "Elixir Berlin"},

    {EX.ElixirBerlinMeetup, EX.organizer, EX.HugoDuksis}, {EX.HugoDuksis, EX.name, "Hugo Duksis"}, ] graph |> RDF.Graph.add({EX.ElixirBerlinMeetup, EX.city, EX.Berlin}) |> RDF.Graph.add(description_of_berlin) |> RDF.Graph.add(another_graph)
  16. RDF serializations RDF.NTriples.write_string(graph) # .ttl is the file extension of

    Turtle files RDF.read_file!("example.ttl") |> RDF.Graph.add(graph) |> RDF.write_file("example.json", format: json_ld)
  17. SPARQL.ex graph |> SPARQL.execute_query(""" SELECT ?organizer WHERE { ?meetup ex:name

    "Elixir Berlin" ; ex:organizer ?organizer . } """) |> SPARQL.Query.Result.get(:organizer)
  18. SPARQL.Client # Places with free wi­fi from Wikidata """ SELECT

    ?item ?itemLabel (SAMPLE(?coord) AS ?coord) WHERE { ?item wdt:P2848 wd:Q1543615 ; # wi­fi gratis wdt:P625 ?coord . SERVICE wikibase:label { bd:serviceParam wikibase:language "[A } GROUP BY ?item ?itemLabel LIMIT 100 """ |> SPARQL.Client.query("https://query.wikidata.org/bigdata/namesp # Result:
  19. Resources Introductions (12min) (20min) (3h 49min; paid content, but IMO

    the best available introduction) Manu Sporny: “What is Linked Data” Markus Lanthaler: “Pragmatic Semantics at Web Scale”, Connected Data London 2018 Brian Sletten: “Resource-Oriented Architectures - Linking Data”, O’Reilly Media, 2015
  20. Resources Interesting stuff (12min) (31min) (42min) Ruben Verborgh: “Querying on

    a decentralized Web”, GraphQL Day 2018 Katariina Kari: “Building, and communicating, a knowledge graph in Zalando”, Connected Data London 2018 Ruben Verborgh: “Solid - taking back the Web through decentralization”, FOSDEM 2019