Creating Knowledge Graphs



Triply B.V.

Overview

  1. Names
  2. Triples
  3. Graphs

Part 1: Names

Throughout history, in human communication, in databases, in research literature, in spreadsheets, on the Internet, names have always been ambiguous.

An example of ambiguity

What does ‘40’ mean?
“40 feet?”
“40 meters?”

Another example of ambiguity

Who or what is ‘Mew’?

In a Knowledge Graph, names must be unambiguous

Names (1/2): IRIs

Globally unique & unambiguous names.

‘Mew’ the Pokemon
https://triplydb.com/academy/pokemon/id/pokemon/mew
‘Mew’ the band
http://dbpedia.org/resource/Mew_(band)
Etc.

Names (2/2): Literals

Some things are not easily expressed with IRIs.

Natural language
あらゆる わざを つかうため ポケモンの せんぞと かんがえる がくしゃが たくさん いる。
Numbers
0.333333; 1,000,000,000; etc.
Date/time
2018-01-01T09:30:45.0Z
Etc.

Syntax for names

  • IRI
    <https://triplydb.com/academy/pokemon/id/pokemon/mew>
  • Literal
    • Typed literal
      "40"^^<http://www.w3.org/2001/XMLSchema#integer>
    • Language-tagged string
      "ミュウ"@ja

Short syntax for names (1/2): IRIs

Full IRI


                <https://triplydb.com/academy/pokemon/id/pokemon/mew>
            

Prefix declaration


                prefix id: <https://triplydb.com/academy/pokemon/id/pokemon/>
            

Short IRI


                id:mew
            

Short syntax for names (2/2): Literals

Full literal


                "40"^^<http://www.w3.org/2001/XMLSchema#integer>
            

Prefix declaration


                prefix xsd: <http://www.w3.org/2001/XMLSchema#>
            

Short literal


                "40"^^xsd:integer
            

Difference between URI, URL, IRI

Universal Resource Identifier (URI)
A universal identifier for a specific resource.
Universal Resource Locator (URL)
A URI that works (dereferences).
International Resource Identifier (IRI)
URI with Unicode support

                  prefix : <https://example.org/>
                  prefix foaf: <http://xmlns.com/foaf/0.1/>
                  prefix graph: <https://triplydb.com/academy/pokemon/graph/>
                  prefix id: <https://triplydb.com/academy/pokemon/id/pokemon/>
                  prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
                  prefix time: <http://www.w3.org/2006/time#>
                  prefix vocab: <https://triplydb.com/academy/pokemon/vocab/>
                  prefix void: <http://rdfs.org/ns/void#>
                  prefix xsd: <http://www.w3.org/2001/XMLSchema#>
              
In the following, we will assume these prefix declarations.

Part 2: Triples

By combining names, we can express meaning.


The smallest unit of meaning in a Knowledge Graph is called a ‘triple’

Semantics of a triple

“Pikachu knows Mew.”

Syntax of a triple

“Pikachu knows Mew.”

                id:pikachu foaf:knows id:mew.
            

Terminology


                  id:pikachu foaf:knows id:mew.
              

Statement

  • Subject (id:pikachu)
  • Predicate (foaf:knows)
  • Object (id:mew)

Arc

  • Nodes (id:pikachu and id:mew)
  • Predicate (foaf:knows)

Triple (summary slide)

Semantically, an atomic assertion.

id:pikachu foaf:knows id:mew.
Syntactically, a sequence of three names.

Part 3: Graphs

Graph

A collection of zero or more triples.

A graph with 1 triple

Semantics

Syntax


                  id:pikachu foaf:knows id:mew.
              

A graph with 3 triples


                    id:pikachu foaf:knows   id:mew.
                    id:pikachu vocab:name   "ピカチュウ"@ja.
                    id:pikachu vocab:weight "60"^^xsd:integer.
                

Short Syntax for triples (1/2)


                    :s :p :o1;
                       :q :o2,
                          :o3.
                

                  :s :p :o1.
                  :s :q :o2.
                  :s :q :o3.
                
Dot (.)
Regular end of triple symbol.
Semicolon (;)
The next triple uses the same subject term (:s).
Comma (,)
The next triple uses the same subject and predicate terms (:s :q).

Short syntax for triples (2/2)


                    :s :p 60,
                          60.0,
                          6.0e2,
                          "6".
                

                    :s :p "60"^^xsd:integer.
                    :s :p "60.0"^^xsd:decimal.
                    :s :p "6.0e2"^^xsd:double,
                    :s :p "6"^^xsd:string.
                
  • Whole numbers (60) have datatype IRI xsd:integer.
  • Numbers with a decimal separator (60.0) have datatype IRI xsd:decimal.
  • Numbers with decimal separator ánd engineering notation (6.0e2) have datatype IRI xsd:double.
  • Strings ("6") have datatype IRI xsd:string.

A graph with 3 triples (short syntax)


                    id:pikachu foaf:knows   id:mew;
                               vocab:name   "ピカチュウ"@ja;
                               vocab:weight 60.
                

A graph with 5 triples (short syntax)


                    id:mew     vocab:name   "ミュウ"@ja;
                               vocab:weight 40.
                    id:pikachu foaf:knows   id:mew;
                               vocab:name   "ピカチュウ"@ja;
                               vocab:weight 60.
                

Creating Knowledge Graphs



Triply B.V.