简体   繁体   中英

SPARQL query not inferencing properties after class specified

I am running a test query on SPARQL to test inferencing. My query is as follows:

    PREFIX eem: <http://purl.org/eem#>
    PREFIX ns: <http://purl.org/net/ns/>
    PREFIX sc_data: <http://purl.org/net/ns/sc_data/>
    PREFIX dbp: <http://dbpedia.org/resource/>
    PREFIX dbpprop: <http://dbpedia.org/property/>
    PREFIX ex: <http://www.example.org/rdf#>
    SELECT  ?roa
    WHERE {
    SERVICE <http://dbpedia.org/sparql>{
    ex:vaccine a dbp:Polio_vaccine.
    ex:vaccine dbpprop:routesOfAdministration ?roa.
}
    }

I get no results for this query when trying at the snorql page. When I specify that something is polio vaccine, shouldn't it automatically inherit the properties specified for the vaccine? What do I need to change?

In your original query, ex:vaccine is a URI node, short for <http://www.example.org/rdf#vaccine> . It's very unlikely that DBpedia contains any information about it. While the DBpedia endpoint may (or may not) include information that is inferrable from the DBpedia data, it doesn't treat your SPARQL query as part assertion and part query.

You're literally saying "find values of ?roa such that ?roa is the route of administration of ex:vaccine and ex:vaccine is an instance of dbp:Polio_vaccine". ex:vaccine is a constant though, so it's kind of like saying, "find factors of 10, and by the way, 10 is the sum of 3 and 4." The "10 is the sum of 3 and 4" isn't in the data, though, so there won't be any matches, even if there are recorded factors of 10. On top of that, dbp:Polio_vaccine is an individual in DBpedia, not a class, so there won't be any instance of it.

Instead, you want to ask for any values of the dbpprop:routesOfAdministation property for the individual dbpedia:Polio_vaccine . The query you need here is (I'm using the prefixes that are defined at http://dbpedia.org/sparql , the public endpoint):

select ?routes where {
  dbpedia:Polio_vaccine dbpprop:routesOfAdministration ?routes
}

SPARQL results

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM