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

Introduction to the Semantic Web - 010PHP February 2019

Arnout Boks
February 14, 2019

Introduction to the Semantic Web - 010PHP February 2019

Joind.in: https://joind.in/talk/53955

What if we could evolve our web of individual documents and data to a web of interlinked knowledge, a web where machines can automatically combine data from multiple sources and draw conclusions from it? The Semantic Web technologies from W3C enable us to make sense of the data wilderness on the web and unlock the full potential of the data treasures hidden in it.

In this talk, we will see how RDF enables us to formally describe the meaning of data and how such data can be queried with SPARQL. We will look at how OWL lets us make more expressive statements about the world, so that a computer can logically reason about it and infer new information. We will demonstrate these technologies by showing how they can be used to query seemingly incompatible data sets as if they were one and letting a computer draw logical (and perhaps surprising) conclusions for us.

Contains: 'retro' technology, linked data, fundamental properties of the web, and Donald Trump's opinion on PHP frameworks.

Arnout Boks

February 14, 2019
Tweet

More Decks by Arnout Boks

Other Decks in Technology

Transcript

  1. Introduction to the Semantic Web
    @arnoutboks
    Arnout Boks
    #010php
    14-02-2019

    View Slide

  2. @arnoutboks #010php
    What this talk is NOT about…

    View Slide

  3. @arnoutboks #010php
    Finding info on the web
    An example

    View Slide

  4. @arnoutboks #010php
    “Web 1.0”

    View Slide

  5. @arnoutboks #010php
    “Web 1.0”

    View Slide

  6. @arnoutboks #010php
    “Web 1.0”

    View Slide

  7. @arnoutboks #010php
    Web 1.0
    Web of Documents
    for human consumption

    View Slide

  8. @arnoutboks #010php
    “Web 2.0”
    Feed of events
    • iCalendar or vCalendar?
    • Different types of events?

    View Slide

  9. @arnoutboks #010php
    “Web 2.0”
    Weather forecast API
    • XML or JSON?
    • Which fields and properties?
    • Which units?

    View Slide

  10. @arnoutboks #010php
    Web 2.0
    Web of (individual) API’s
    for consumption by
    specialized software

    View Slide

  11. @arnoutboks #010php
    Semantic web
    • Question to agent (e.g. Siri, Google Assistant)
    • Agent searches across different sources
    • Agent combines data
    • Agent answers question

    View Slide

  12. @arnoutboks #010php
    Semantic Web
    (“Web 3.0”?)
    Web of Linked Data
    for consumption by
    intelligent agents/PA’s

    View Slide

  13. @arnoutboks #010php
    Revolutionary?
    Term coined by Tim Berners-Lee in 2001

    View Slide

  14. @arnoutboks #010php
    Revolutionary?
    Based on W3C-standards
    • RDF (1998)
    • RDFS (1998)
    • SPARQL (2008)
    • OWL (2004)
    • …

    View Slide

  15. @arnoutboks #010php
    RDF
    Cornerstone of the Semantic Web
    Resource Description Framework
    Cornerstone of the Semantic Web

    View Slide

  16. @arnoutboks #010php
    Records statements
    about things

    View Slide

  17. @arnoutboks #010php
    RDF allows
    reading, merging, relaying
    and inferring statements
    without fully understanding them

    View Slide

  18. @arnoutboks #010php
    RDF (triples)
    Subject Predicate Object

    View Slide

  19. @arnoutboks #010php
    RDF (triples)
    Subject Predicate Object
    Arnout worksAt Moxio

    View Slide

  20. @arnoutboks #010php
    RDF (triples)
    Subject Predicate Object
    Arnout worksAt Moxio
    Arnout twitterHandle “@arnoutboks”
    Arnout livesIn Delft
    Delft cityIn The Netherlands
    Moxio basedIn Delft

    View Slide

  21. @arnoutboks #010php
    RDF (graph)
    Arnout Moxio
    Delft
    @arnoutboks
    worksAt
    basedIn
    The
    Netherlands
    Subject Predicate Object
    Arnout worksAt Moxio
    Arnout twitterHandle “@arnoutboks”
    Arnout livesIn Delft
    Delft cityIn The Netherlands
    Moxio basedIn Delft

    View Slide

  22. @arnoutboks #010php
    Merging RDF (triples)
    Subject Predicate Object
    Arnout worksAt Moxio
    Arnout twitterHandle “@arnoutboks”
    Arnout livesIn Delft
    Delft cityIn The Netherlands
    Moxio basedIn Delft
    Subject Predicate Object
    The Netherlands hasCapital Amsterdam
    The Netherlands population “17.000.000”

    View Slide

  23. @arnoutboks #010php
    Merging RDF (triples)
    Subject Predicate Object
    Arnout worksAt Moxio
    Arnout twitterHandle “@arnoutboks”
    Arnout livesIn Delft
    Delft cityIn The Netherlands
    Moxio basedIn Delft
    The Netherlands hasCapital Amsterdam
    The Netherlands population “17.000.000”

    View Slide

  24. @arnoutboks #010php
    Merging RDF (graph)
    Arnout Moxio
    Delft
    @arnoutboks
    worksAt
    basedIn
    The
    Netherlands
    Amsterdam
    hasCapital
    17.000.000
    population

    View Slide

  25. @arnoutboks #010php
    Serializing RDF: Turtle
    @prefix : .
    @prefix rdf: ns#> .
    @prefix xsd: .
    @base .
    :Arnout :livesIn :Delft ;
    :worksAt :Moxio ;
    :twitterHandle "@arnoutboks"^^xsd:string .
    :Delft :cityIn :The_Netherlands .
    :Moxio :basedIn :Delft .

    View Slide

  26. @arnoutboks #010php
    Serializing RDF: RDF/XML

    >
    rdf:about="http://www.example.com/#Arnout">
    rdf:datatype="http://www.w3.org/2001/XMLSchema#string">@a
    rnoutboks
    rdf:resource="http://www.example.com/#Moxio"/>
    rdf:resource="http://www.example.com/#Delft"/>



    View Slide

  27. @arnoutboks #010php
    Serializing RDF: JSON-LD
    [ {
    "@id" : "http://www.example.com/#Arnout",
    "http://www.example.com/#livesIn" : [ {
    "@id" : "http://www.example.com/#Delft"
    } ],
    "http://www.example.com/#twitterHandle" : [ {
    "@value" : "@arnoutboks"
    } ],
    "http://www.example.com/#worksAt" : [ {
    "@id" : "http://www.example.com/#Moxio"
    } ]
    }, ... ]

    View Slide

  28. @arnoutboks #010php
    RDF is an abstract
    data model
    with different serialization formats

    View Slide

  29. @arnoutboks #010php
    Identity
    Because there are multiple things named “Amsterdam”

    View Slide

  30. @arnoutboks #010php
    Identity
    Subject Predicate Object
    Amsterdam numberOfGuns “42”
    Amsterdam status Wrecked
    National Maritime Museum (“Scheepvaartmuseum”)

    View Slide

  31. @arnoutboks #010php
    Identity
    Subject Predicate Object
    Amsterdam numberOfGuns “42”
    Amsterdam status Wrecked
    Subject Predicate Object
    The Netherlands hasCapital Amsterdam
    The Netherlands population “17.000.000”
    National Maritime Museum (“Scheepvaartmuseum”)
    Lonely Planet

    View Slide

  32. @arnoutboks #010php
    Identity
    The
    Netherlands Amsterdam
    hasCapital
    17.000.000
    population
    42
    Wrecked

    View Slide

  33. @arnoutboks #010php
    URI’s for namespacing
    National Maritime Museum (“Scheepvaartmuseum”)
    https://www.hetscheepvaartmuseum.nl/ships/Amsterdam
    https://www.hetscheepvaartmuseum.nl/ships/numberOfGuns
    Lonely Planet
    https://www.lonelyplanet.com/Amsterdam
    https://www.lonelyplanet.com/hasCapital

    View Slide

  34. @arnoutboks #010php
    Prefixes & QNames
    lonelyplanet:Amsterdam
    ===
    https://www.lonelyplanet.com/Amsterdam
    QName
    URI
    local name
    local name
    namespace
    prefix

    View Slide

  35. @arnoutboks #010php
    Prefixes & QNames
    National Maritime Museum (“Scheepvaartmuseum”)
    nmm:Amsterdam
    nmm:numberOfGuns
    Lonely Planet
    lonelyplanet:Amsterdam
    lonelyplanet:hasCapital

    View Slide

  36. @arnoutboks #010php
    Three fundamental laws
    of the (Semantic) Web

    View Slide

  37. @arnoutboks #010php
    Different name, different concept?
    lonelyplanet-en:Brussels
    lonelyplanet-nl:Brussel
    lonelyplanet-fr:Bruxelles
    lonelyplanet-zh:布魯塞爾

    View Slide

  38. @arnoutboks #010php
    Different name, different concept?
    mi6:007
    mi6:JamesBond

    View Slide

  39. @arnoutboks #010php
    Nonunique Naming Assumption
    Different names do not
    imply different concepts

    View Slide

  40. @arnoutboks #010php
    Truth & authority
    Subject Predicate Object
    whitehouse:Obama nsa:tapped whitehouse:Trump
    Donald Trump

    View Slide

  41. @arnoutboks #010php
    Truth & authority
    Subject Predicate Object
    php-fig:CakePHP fw:isBetterThan php-fig:Symfony
    Donald Trump

    View Slide

  42. @arnoutboks #010php
    The AAA Slogan
    “[On the web] Anyone can say
    Anything about Any topic”

    View Slide

  43. @arnoutboks #010php
    (this slide intentionally left blank)

    View Slide

  44. @arnoutboks #010php
    Absence of information
    Subject Predicate Object
    whitehouse:Trump fw:knows php-fig:Symfony
    whitehouse:Trump fw:knows php-fig:CakePHP
    whitehouse:Trump fw:knows php-fig:CodeIgniter

    View Slide

  45. @arnoutboks #010php
    Open World Assumption
    We never have all information

    View Slide

  46. @arnoutboks #010php
    SPARQL
    Query language for Semantic Web data

    View Slide

  47. @arnoutboks #010php
    Triple Store
    Database for RDF triples

    View Slide

  48. @arnoutboks #010php
    SPARQL
    SELECT ?employee ?company
    WHERE {
    ?employee :worksAt ?company .
    ?company :basedIn :Delft .
    }

    View Slide

  49. @arnoutboks #010php
    SPARQL
    SELECT ?employee ?company
    WHERE {
    ?employee :worksAt ?company .
    ?company :basedIn :Delft .
    }
    ?employee ?company
    :Arnout :Moxio

    View Slide

  50. @arnoutboks #010php
    SPARQL
    SELECT ?employee ?company ?city
    WHERE {
    ?employee :worksAt ?company .
    ?company :basedIn ?city .
    ?employee :livesIn ?city .
    }
    ?employee ?company ?city
    :Arnout :Moxio :Delft

    View Slide

  51. @arnoutboks #010php
    Online SPARQL endpoints
    http://dbpedia.org/sparql

    View Slide

  52. @arnoutboks #010php
    Online SPARQL endpoints

    View Slide

  53. @arnoutboks #010php
    Online SPARQL endpoints
    PREFIX dbo:
    PREFIX dbr:
    SELECT ?song ?runtime
    WHERE {
    ?song dbo:artist dbr:The_Beatles .
    ?song dbo:runtime ?runtime .
    ?song rdf:type dbo:Song .
    } ORDER BY DESC (?runtime)

    View Slide

  54. @arnoutboks #010php
    Online SPARQL endpoints

    View Slide

  55. @arnoutboks #010php
    Online SPARQL endpoints
    PREFIX dbo:
    PREFIX dbr:
    SELECT ?ancestor
    WHERE {
    dbr:Willem-Alexander_of_the_Netherlands
    dbo:parent+ ?ancestor .
    }

    View Slide

  56. @arnoutboks #010php
    RDF Schema
    Schema language for Semantic Web data

    View Slide

  57. @arnoutboks #010php
    RDF Schema (RDFS)
    Describes the structure of RDF-data… in RDF
    • Classes
    • Properties
    • Domain and range of properties
    • Inheritance of classes
    • ‘Inheritance’ of properties

    View Slide

  58. @arnoutboks #010php
    RDF Schema (RDFS)
    Subject Predicate Object
    :DonaldTrump :isFatherOf :IvankaTrump

    View Slide

  59. @arnoutboks #010php
    RDF Schema (RDFS)
    Subject Predicate Object
    :DonaldTrump :isFatherOf :IvankaTrump
    :isFatherOf rdfs:range :Person
    :isFatherOf rdfs:domain :Father
    :Father rdfs:subclassOf :Parent
    :Parent rdfs:subclassOf :Person
    :isFatherOf rdfs:subpropertyOf :isParentOf

    View Slide

  60. @arnoutboks #010php
    RDF Schema & Inference
    Subject Predicate Object
    :DonaldTrump :isFatherOf :IvankaTrump
    :isFatherOf rdfs:range :Person
    :isFatherOf rdfs:domain :Father
    :Father rdfs:subclassOf :Parent
    :Parent rdfs:subclassOf :Person
    :isFatherOf rdfs:subpropertyOf :isParentOf
    :IvankaTrump rdf:type :Person
    :DonaldTrump rdf:type :Father
    :DonaldTrump rdf:type :Parent
    :DonaldTrump rdf:type :Person
    :DonaldTrump :isParentOf :IvankaTrump

    View Slide

  61. @arnoutboks #010php
    Inference
    Reasoner
    (asserted) triples
    inferred/virtual triples

    View Slide

  62. @arnoutboks #010php
    Inference
    Reasoner
    (asserted) triples
    inferred/virtual triples

    View Slide

  63. @arnoutboks #010php
    SPARQL & Inference
    SELECT ?person
    WHERE { ?person rdf:type :Person . }
    ?person
    :IvankaTrump
    :DonaldTrump

    View Slide

  64. @arnoutboks #010php
    Combining data using inference
    Subject Predicate Object
    a:DonaldTrump rdf:type a:Person
    Datasource A
    Subject Predicate Object
    b:MelaniaTrump rdf:type b:Human
    Datasource B

    View Slide

  65. @arnoutboks #010php
    Combining data using inference
    Subject Predicate Object
    a:DonaldTrump rdf:type a:Person
    Datasource A
    Subject Predicate Object
    b:MelaniaTrump rdf:type b:Human
    Datasource B
    Subject Predicate Object
    a:Person rdfs:subclassOf b:Human
    b:Human rdfs:subclassOf a:Person
    Mapping rules

    View Slide

  66. @arnoutboks #010php
    Combining data using inference
    Subject Predicate Object
    a:DonaldTrump rdf:type a:Person
    b:MelaniaTrump rdf:type b:Human
    a:Person rdfs:subclassOf b:Human
    b:Human rdfs:subclassOf a:Person
    a:DonaldTrump rdf:type b:Human
    b:MelaniaTrump rdf:type a:Person

    View Slide

  67. @arnoutboks #010php
    Query different sources
    as if they were one

    View Slide

  68. @arnoutboks #010php
    RDF Schema vs. JSON/XML Schema
    Subject Predicate Object
    mi6:JamesBond rdf:type mi6:SecretAgent
    mi6:JamesBond nmm:numberOfGuns “1”
    MI6 files

    View Slide

  69. @arnoutboks #010php
    RDF Schema vs. JSON/XML Schema
    Subject Predicate Object
    mi6:JamesBond rdf:type mi6:SecretAgent
    mi6:JamesBond nmm:numberOfGuns “1”
    MI6 files

    View Slide

  70. @arnoutboks #010php
    RDF Schema vs. JSON/XML Schema
    Subject Predicate Object
    mi6:JamesBond rdf:type mi6:SecretAgent
    mi6:JamesBond nmm:numberOfGuns “1”
    MI6 files
    Subject Predicate Object
    nmm:numberOfGuns rdf:domain nmm:Ship
    National Maritime Museum (“Scheepvaartmuseum”)

    View Slide

  71. @arnoutboks #010php
    RDF Schema vs. JSON/XML Schema
    Subject Predicate Object
    mi6:JamesBond rdf:type mi6:SecretAgent
    mi6:JamesBond nmm:numberOfGuns “1”
    nmm:numberOfGuns rdf:domain nmm:Ship
    mi6:JamesBond rdf:type nmm:Ship

    View Slide

  72. @arnoutboks #010php
    RDF Schema vs. JSON/XML Schema

    View Slide

  73. @arnoutboks #010php
    RDF Schema will never
    consider data to be invalid

    View Slide

  74. @arnoutboks #010php
    Web Ontology Language (OWL)
    Even smarter inferencing
    Web Ontology Language (OWL)
    Even smarter inferencing

    View Slide

  75. @arnoutboks #010php
    OWL
    OWL ≈ RDFS++

    View Slide

  76. @arnoutboks #010php
    OWL
    Power comes at a price…

    View Slide

  77. @arnoutboks #010php
    OWL: Inverse properties
    Subject Predicate Object
    :DonaldTrump :isParentOf :IvankaTrump
    :isParentOf owl:inverseOf :isChildOf
    :IvankaTrump :isChildOf :DonaldTrump

    View Slide

  78. @arnoutboks #010php
    OWL: Symmetric properties
    Subject Predicate Object
    :DonaldTrump :isMarriedTo :MelaniaTrump
    :isMarriedTo rdf:type owl:SymmetricProperty
    :MelaniaTrump :isMarriedTo :DonaldTrump

    View Slide

  79. @arnoutboks #010php
    OWL: Equality
    Subject Predicate Object
    :DonaldTrump :isMarriedTo :MelaniaTrump
    :DonaldTrump owl:sameAs :TheDon
    :TheDon :isMarriedTo :MelaniaTrump

    View Slide

  80. @arnoutboks #010php
    OWL: Functional properties
    Subject Predicate Object
    :IvankaTrump :hasFather :DonaldTrump
    :IvankaTrump :hasFather :TheDon
    :hasFather rdf:type owl:FunctionalProperty
    :TheDon owl:sameAs :DonaldTrump

    View Slide

  81. @arnoutboks #010php
    Inconsistency
    Subject Predicate Object
    :IvankaTrump :hasFather :DonaldTrump
    :IvankaTrump :hasFather :TheDon
    :hasFather rdf:type owl:FunctionalProperty
    :TheDon owl:differentFrom :DonaldTrump

    View Slide

  82. @arnoutboks #010php
    Inconsistency

    View Slide

  83. @arnoutboks #010php
    Inconsistency

    View Slide

  84. @arnoutboks #010php
    It’s okay to be inconsistent…
    (remember the AAA slogan)

    View Slide

  85. @arnoutboks #010php
    It’s okay to be inconsistent…
    (remember the AAA slogan)
    …but the reasoner won’t
    help you anymore

    View Slide

  86. @arnoutboks #010php
    Self-test
    Subject Predicate Object
    :George :hasChild :Michelle
    :George :hasChild :James
    How many children does George have?

    View Slide

  87. @arnoutboks #010php
    Reification
    Adding more nuance

    View Slide

  88. @arnoutboks #010php
    Reifying a statement
    Subject Predicate Object
    php-fig:CakePHP fw:isBetterThan php-fig:Symfony

    View Slide

  89. @arnoutboks #010php
    Reifying a statement
    Subject Predicate Object
    php-fig:CakePHP fw:isBetterThan php-fig:Symfony
    Subject Predicate Object
    :Statement1 rdf:subject php-fig:CakePHP
    :Statement1 rdf:predicate fw:isBetterThan
    :Statement1 rdf:object php-fig:Symfony
    Reification

    View Slide

  90. @arnoutboks #010php
    Talking about a statement
    rather than making it

    View Slide

  91. @arnoutboks #010php
    Use cases for reification
    Subject Predicate Object
    :Statement1 rdf:subject php-fig:CakePHP
    :Statement1 rdf:predicate fw:isBetterThan
    :Statement1 rdf:object php-fig:Symfony

    View Slide

  92. @arnoutboks #010php
    Use cases for reification
    Subject Predicate Object
    :Statement1 rdf:subject php-fig:CakePHP
    :Statement1 rdf:predicate fw:isBetterThan
    :Statement1 rdf:object php-fig:Symfony
    whitehouse:Trump :says :Statement1

    View Slide

  93. @arnoutboks #010php
    Use cases for reification
    Subject Predicate Object
    :Statement1 rdf:subject php-fig:CakePHP
    :Statement1 rdf:predicate fw:isBetterThan
    :Statement1 rdf:object php-fig:Symfony
    whitehouse:Trump :says :Statement1
    :Statement1 :reliability "0.1"

    View Slide

  94. @arnoutboks #010php
    Use cases for reification
    Subject Predicate Object
    :Statement1 rdf:subject php-fig:CakePHP
    :Statement1 rdf:predicate fw:isBetterThan
    :Statement1 rdf:object php-fig:Symfony
    whitehouse:Trump :says :Statement1
    :Statement1 :reliability "0.1"
    :Statement1 :validUntil "2010-01-01"

    View Slide

  95. @arnoutboks #010php
    Use cases for reification
    Subject Predicate Object
    :Statement1 rdf:subject php-fig:CakePHP
    :Statement1 rdf:predicate fw:isBetterThan
    :Statement1 rdf:object php-fig:Symfony
    whitehouse:Trump :says :Statement1
    :Statement1 :reliability "0.1"
    :Statement1 :validUntil "2010-01-01"

    View Slide

  96. @arnoutboks #010php
    Let’s get meta

    View Slide

  97. @arnoutboks #010php
    Let’s get meta
    Subject Predicate Object
    :Statement1 rdf:subject php-fig:CakePHP
    :Statement1 rdf:predicate fw:isBetterThan
    :Statement1 rdf:object php-fig:Symfony
    :Statement2 rdf:subject whitehouse:Trump
    :Statement2 rdf:predicate :says
    :Statement2 rdf:object :Statement1
    whitehouse:PressSec :says :Statement2

    View Slide

  98. @arnoutboks #010php
    Further steps
    Get going with the Semantic Web

    View Slide

  99. @arnoutboks #010php
    Leveraging the Semantic Web
    Network effect

    View Slide

  100. @arnoutboks #010php
    Leveraging the Semantic Web
    Only useful when multiple parties
    speak the same ‘language’

    View Slide

  101. @arnoutboks #010php
    Align with existing
    vocabularies

    View Slide

  102. @arnoutboks #010php
    Leveraging the Semantic Web
    Mapping between vocabularies:
    • rdfs:subclassOf
    • rdfs:subpropertyOf
    • owl:inverseOf
    • owl:sameAs

    View Slide

  103. @arnoutboks #010php
    Existing vocabularies
    • Dublin Core
    • Metadata about publications and authors
    • Friend of a Friend
    • People, connections, social networks
    • GoodRelations
    • Products, prices, eCommerce
    • CB-NL
    • Construction, infrastructure, spatial planning
    • QUDT
    • Quantities, units, dimensions, conversions

    View Slide

  104. @arnoutboks #010php
    Resources
    • Apache Jena (includes Fuseki triple store)
    • Semantic web framework/tools (written in Java)
    • easyrdf/easyrdf
    • RDF parser/writer for PHP
    • semsol/arc2
    • PHP RDF library and MySQL-based triple store
    • FaCT++, HermiT & Pellet
    • Open source OWL reasoners
    • Protégé
    • RDF/OWL IDE with various reasoner plugins

    View Slide

  105. @arnoutboks #010php
    Resources

    View Slide

  106. @arnoutboks #010php
    Resources
    • https://www.w3.org/2013/data/
    • https://www.w3.org/2001/sw/wiki/
    • https://www.w3.org/TR/rdf11-primer/
    • https://www.w3.org/TR/owl2-primer/
    • https://www.w3.org/TR/sparql11-query/
    • http://wiki.dbpedia.org/OnlineAccess
    • https://www.data.gov/
    • http://lod-cloud.net/

    View Slide

  107. @arnoutboks #010php
    Feedback & Questions
    @arnoutboks
    @arnoutboks
    @aboks
    Arnout Boks
    Please leave your feedback on joind.in:
    https://joind.in/talk/53955

    View Slide

  108. @arnoutboks #010php
    Image Credits
    • https://www.flickr.com/photos/lex-photographic/32521124574
    • https://www.flickr.com/photos/flamesworddragon/19686463141
    • https://www.flickr.com/photos/littlehuw/15236543728
    • https://www.flickr.com/photos/crdominguez/422517106
    • https://www.flickr.com/photos/pamwood707/5646757752
    • https://www.flickr.com/photos/blair25/3240686470
    • https://www.flickr.com/photos/tylerbeaulawrence/15167523690
    • https://www.flickr.com/photos/[email protected]/3675503072
    • https://pixabay.com/nl/nuance-stalen-kleur-pantone-1074766/
    • https://www.flickr.com/photos/borkurdotnet/9682277597

    View Slide