SPARQLing with GraphDB - European Summer School in Logic...

Preview:

Citation preview

SPARQLing with GraphDBJohn P. McCrae, Thierry Declerck

Step 1: Install GraphDB

Go to http://graphdb.ontotext.com/ and download the free version of GraphDB

Step 1: Install GraphDB

Go to your email and “download as stand-alone server”.

(Linux) Unzip this and run the command at bin/graphdb

(Windows) Should start after installPoint your browser to

http://localhost:7200/

Step 1: Success?

Step 2: Load some data

Step 2: Add some data

Step 2: Add some data

Step 2: Add some data

Step 3: Do some SPARQLing

Task

● Look at the example entry here:http://wordnet-rdf.princeton.edu/ttl/lemma/cat

● Task: Rewrite the query to return only nouns● Task: List the definition of each sense● Task: Find the lemmas of all hypernyms

Step 4: Interoperability

Add two datasets:https://github.com/jmccrae/wn-wiki-instances/raw/master/ili-map-dbpedia.ttlhttp://downloads.dbpedia.org/2016-10/core-i18n/en/genders_en.ttl.bz2

(You will need to download and unzip this one)

Task

Use this to find a male philosopher

Hints A philosopher is an wn:instance_hypernym of

http://wordnet-rdf.princeton.edu/id/10443334-n

Synsets are connected to the ILI with http://www.w3.org/2002/07/owl#sameAs

The ILI is connected to DBpedia with http://www.w3.org/2004/02/skos/core#exactMatch

The gender is given in DBpedia with http://xmlns.com/foaf/0.1/gender

Solutions

PREFIX ontolex: <http://www.w3.org/ns/lemon/ontolex#>

PREFIX wn: <http://wordnet-rdf.princeton.edu/ontology#>

select distinct * where {

?s ontolex:canonicalForm [ ontolex:writtenRep "cat"@en ] ;

wn:partOfSpeech wn:noun .

} limit 100

Solutions

PREFIX ontolex: <http://www.w3.org/ns/lemon/ontolex#>

PREFIX wn: <http://wordnet-rdf.princeton.edu/ontology#>

PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>

select distinct ?value where {

?s ontolex:canonicalForm [ ontolex:writtenRep "cat"@en ] ;

ontolex:sense ?sense .

?sense ontolex:isLexicalizedSenseOf ?synset .

?synset wn:definition ?defn .

?defn rdf:value ?value .

} limit 100

Solutions

PREFIX ontolex: <http://www.w3.org/ns/lemon/ontolex#> PREFIX wn: <http://wordnet-rdf.princeton.edu/ontology#> PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>select distinct ?lemma2 where { ?entry1 ontolex:canonicalForm [ ontolex:writtenRep "cat"@en ] ; ontolex:sense ?sense1 . ?sense1 ontolex:isLexicalizedSenseOf ?synset1 . ?entry2 ontolex:canonicalForm [ ontolex:writtenRep ?lemma2 ] ; ontolex:sense ?sense2 . ?sense2 ontolex:isLexicalizedSenseOf ?synset2 . ?synset1 wn:hypernym ?synset2 . } limit 100

Solutions

PREFIX ontolex: <http://www.w3.org/ns/lemon/ontolex#>

PREFIX wn: <http://wordnet-rdf.princeton.edu/ontology#>

PREFIX owl: <http://www.w3.org/2002/07/owl#>

PREFIX skos: <http://www.w3.org/2004/02/skos/core#>

PREFIX wnid: <http://wordnet-rdf.princeton.edu/id/>

select distinct * where {

?s wn:instance_hypernym wnid:10443334-n.

?s owl:sameAs ?ili .

?ili skos:exactMatch ?dbp .

?dbp <http://xmlns.com/foaf/0.1/gender> ?gender

} limit 100

Thanks.

This publication has emanated from research supported in part by a research grant from Science Foundation Ireland (SFI) under Grant Number SFI/12/RC/2289, co-funded by the European Regional Development Fund

Recommended