Ontology SPARQL Query

I would like to know how to query ontology data like this Ontology Classes
I want to have a csv file that looks like this:
animal | mammal | dog
or
animal | mammal
animal | dog

and i would like to search the abstract (?) meaning the text something like this
animal | text from wiki about animals

how can i do this? the documentation is hard to read imo

Hi, assuming you want to filter dogs belonging to ontology mammal, I have attempted to partially answer your question with the below query, which can possibly get you started on completing your entire query. You might get no results if you directly fetch instances of ontology class - Dog, and mammals with return all instances that are mammals (even those that are not dogs) and animals would also fetch you those that are mammal and person. Here’s a query that helps you return the instances of mammals that dogs -

SELECT DISTINCT ?mammal ?mammalName
WHERE {
  ?mammal rdf:type dbo:Mammal ;
          rdfs:label ?mammalName ;
          dbo:abstract ?abstract .
  FILTER (lang(?mammalName) = "en" && lang(?abstract) = "en" && regex(?abstract, "dog", "i"))
}

What this query returns is:

  1. selects instances of ontology mammal, further extracts the label of that resource and stores in mammalName
  2. of those instances, selects the abstract of that resource in variable abstract
  3. filters mammalName that are in language English, filters abstract text which is in English and filters resources that have “dog” in abstract

I tried to use the abstract to filter dog instances from Mammal class because I always got blank responses when I tried to get instances of class Dog directly.
You can try the above query here: OpenLink Virtuoso SPARQL Query Editor

This was my attempt, hope it helps! Prolly the dbpedia members can confirm or get you a better answer! :smile: