Luna the feather
Luna the feather

Reputation: 1

How to add classes to a specific class in an ontology with sparql?

We have a question about sparql, because we’re trying to link classes from dbpedia to our ontology in Protégé. Our protégé is about pets. We’re trying with the query below to get all the dog breeds from dbpedia and implement them as a subclass to our class ‘Dog’ in Protégé.

What happens with this query is that all the dog breeds become normal classes our ontology, but we want it to be subclasses of the class ‘Dog’.

Thanks a lot!

    PREFIX dbo: <http://dbpedia.org/ontology/>
    PREFIX umbelrc: <http://umbel.org/umbel/rc/>
    PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
    PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
    PREFIX owl: <http://www.w3.org/2002/07/owl#>
    PREFIX dct: <http://purl.org/dc/terms/>
    PREFIX ex: <http://data.kingcounty.cov/resource/yaai-7rfk/>
    PREFIX dbc: <http://dbpedia.org/resource/Category:>


    CONSTRUCT {
      ?x a owl:Class .
      ?x owl:equivalentClass [
        rdf:type owl:Restriction ;
        owl:onProperty ex:animal_type ;
        owl:hasValue ?xls ;
      ] .
    } WHERE {
      SELECT ?x ?xls WHERE {
      ?x a dbc:Dog_breeds .
      ?x rdfs:label ?xl .
      FILTER(lang(?xl) = 'en')
        BIND(str(?xl) as ?xls)
      }
    } 

Upvotes: 0

Views: 354

Answers (1)

UninformedUser
UninformedUser

Reputation: 8465

Resources are connected to a DBpedia category by the property dct:subject and not rdf:type (aka a in Turtle). that means, change the triple pattern from

?x a dbc:Dog_breeds .

to

?x dct:subject dbc:Dog_breeds .

should work (modulo other issues that might arise afterwards indeed).

Upvotes: 1

Related Questions