Linked Data owl:sameAs Reasoning Guidance

15 views
Skip to first unread message

Tom Kelly

unread,
Apr 15, 2016, 11:29:44 AM4/15/16
to Stardog
Hi Stardog team!

I'm trying out the linked data features of Stardog and need some guidance.  I'm sure that I'm overlooking something, and ask that you point me in the right direction.

For a demo, I'm pulling some resources' data into Stardog 4.0.5 from DBpedia, which I'll use to link to the rest of the data for these resources.  My database was created using the reasoning.sameas=ON configuration option.  I have verified on the Database page that the Reasoning type is SL and SameAs reasoning is ON. 

The following populates Stardog with the triples that I expect:

PREFIX dbo: <http://dbpedia.org/ontology/>
PREFIX dbr: <http://dbpedia.org/resource/>
PREFIX dbp: <http://dbpedia.org/property/>

INSERT {
    ?celebrityURI  rdf:type    :Celebrity ;
                   rdfs:label  ?personName ;
                   owl:sameAs  ?personURI.
}
WHERE {
    BIND (URI(CONCAT('http://mydomain.com/data/Celebrity/CL', substr(str(rand()), 3, 16))) AS ?celebrityURI)

    SERVICE <http://www.dbpedia.org/sparql/> {
        SELECT DISTINCT ?personURI ?personName
        WHERE {
            ?personURI  rdf:type         dbo:Person ;
                        rdfs:label       ?personName ;
                        dbo:birthYear    ?birthYear ;
                        dbo:nationality  dbr:United_States .
            FILTER (langMatches(lang(?personName), "EN"))
            FILTER (?birthYear >= "1900-01-01"^^xsd:date)
        }
    }
}

A new URI (based on a random value) is created as each person is added to the local database.  Every person in the local database has a owl:sameAs triple that references their URI in DBpedia.  With the SPARQL Query Panel Reasoning switched to ON. I run the following query to access the local data AND their data in DBpedia:

PREFIX dbo: <http://dbpedia.org/ontology/>
PREFIX dbr: <http://dbpedia.org/resource/>
PREFIX dbp: <http://dbpedia.org/property/>

SELECT DISTINCT ?personName ?birthPlaceName ?population
WHERE {
    ?celebrityURI   rdf:type          :Celebrity ;
                    rdfs:label        ?personName .
    OPTIONAL {
        ?celebrityURI   dbo:birthPlace       ?BirthPlaceURI .
        ?BirthPlaceURI  rdfs:label           ?birthPlaceName .
        ?BirthPlaceURI  dbp:populationTotal  ?population .
    }
}  ORDER BY ?personName

I'm able to get the local data, but not the linked DBpedia data.  I've also tried the following to force the lookup by the DBpedia URI:

WHERE {
    ?celebrityURI   rdf:type          :Celebrity ;
                    rdfs:label        ?personName ;
                    owl:sameAs   ?personURI .
    OPTIONAL {
        ?personURI   dbo:birthPlace       ?BirthPlaceURI .
        ?BirthPlaceURI  rdfs:label           ?birthPlaceName .

but do not get the linked data in this manner either.  Can you suggest a direction for me to pursue next to resolve this?

Thanks!

Tom

Zachary Whitley

unread,
Apr 15, 2016, 12:36:48 PM4/15/16
to Stardog
It doesn't appear as though you've loaded the dbpedia data into your database. You've just have your remapped data. Were you possibly expecting the owl:sameAs to dereference the url and add it to the default graph similar to a FROM or FROM NAMED clause? (Stardog doesn't support loading data from FROM and FROM NAMED btw). I believe you should be able to get the results you're looking for if you load the dbpedia data you're looking for with your INSERT or adding a SERVICE clause to your query.


PREFIX dbo: <http://dbpedia.org/ontology/>
PREFIX dbr: <http://dbpedia.org/resource/>
PREFIX dbp: <http://dbpedia.org/property/>

INSERT {
    ?celebrityURI  rdf:type    :Celebrity ;
                   rdfs:label  ?personName ;
                   owl:sameAs  ?personURI.
                  ?personURI   dbo:birthPlace       ?BirthPlaceURI .
                  ?BirthPlaceURI  dbp:populationTotal  ?population .

                  ?BirthPlaceURI  rdfs:label           ?birthPlaceName .
}
WHERE {
    BIND (URI(CONCAT('http://mydomain.com/data/Celebrity/CL', substr(str(rand()), 3, 16))) AS ?celebrityURI)

    SERVICE <http://www.dbpedia.org/sparql/> {
        SELECT DISTINCT ?personURI ?personName ?BirthPlaceURI ?birthPlaceName ?population

        WHERE {
            ?personURI  rdf:type         dbo:Person ;
                        rdfs:label       ?personName ;
                        dbo:birthYear    ?birthYear ;
                        dbo:nationality  dbr:United_States .
            OPTIONAL {
                  ?personURI   dbo:birthPlace       ?BirthPlaceURI .
                  ?BirthPlaceURI  dbp:populationTotal  ?population .

                  ?BirthPlaceURI  rdfs:label           ?birthPlaceName .
              }
            FILTER (langMatches(lang(?personName), "EN"))
            FILTER (?birthYear >= "1900-01-01"^^xsd:date)
        }
    }
}

Then you should see the difference with reasoning turned on or off with your query

PREFIX dbo: <http://dbpedia.org/ontology/>
PREFIX dbr: <http://dbpedia.org/resource/>
PREFIX dbp: <http://dbpedia.org/property/>

SELECT DISTINCT ?personName ?birthPlaceName ?population
WHERE {
    ?celebrityURI   rdf:type          :Celebrity ;
                    rdfs:label        ?personName .
    OPTIONAL {
        ?celebrityURI   dbo:birthPlace       ?BirthPlaceURI .
        ?BirthPlaceURI  rdfs:label           ?birthPlaceName .
        ?BirthPlaceURI  dbp:populationTotal  ?population .
    }
}  ORDER BY ?personName

or you can add the SERVICE clause to your query but keep in mind that it's going to hit dbpedia each and every time you execute the query (it might be cached) which might not be so nice to the good folks over at dbpedia :)


PREFIX dbo: <http://dbpedia.org/ontology/>
PREFIX dbr: <http://dbpedia.org/resource/>
PREFIX dbp: <http://dbpedia.org/property/>

SELECT DISTINCT ?personName ?birthPlaceName ?population
WHERE {
    ?celebrityURI   rdf:type          :Celebrity ;
                    rdfs:label        ?personName .
    OPTIONAL {
        ?celebrityURI   dbo:birthPlace       ?BirthPlaceURI .
        ?BirthPlaceURI  rdfs:label           ?birthPlaceName .
        ?BirthPlaceURI  dbp:populationTotal  ?population .
    }
  SERVICE <http://www.dbpedia.org/sparql/> {
        SELECT DISTINCT ?personURI ?personName ?BirthPlaceURI ?birthPlaceName ?population

        WHERE {
            ?personURI  rdf:type         dbo:Person ;
                        rdfs:label       ?personName ;
                        dbo:birthYear    ?birthYear ;
                        dbo:nationality  dbr:United_States .
            OPTIONAL {
                  ?personURI   dbo:birthPlace       ?BirthPlaceURI .
                  ?BirthPlaceURI  dbp:populationTotal  ?population .

                  ?BirthPlaceURI  rdfs:label           ?birthPlaceName .
              }
            FILTER (langMatches(lang(?personName), "EN"))
            FILTER (?birthYear >= "1900-01-01"^^xsd:date)
        }
    }
 
}  ORDER BY ?personName


Let me know if that's what you were looking for.


--
-- --
You received this message because you are subscribed to the C&P "Stardog" group.
To post to this group, send email to sta...@clarkparsia.com
To unsubscribe from this group, send email to
stardog+u...@clarkparsia.com
For more options, visit this group at
http://groups.google.com/a/clarkparsia.com/group/stardog?hl=en
---
You received this message because you are subscribed to the Google Groups "Stardog" group.
To unsubscribe from this group and stop receiving emails from it, send an email to stardog+u...@clarkparsia.com.

Reply all
Reply to author
Forward
0 new messages