Would there by any differences in performance or eventually in result set if we 
would substitute 
FILTER NOT EXISTS { ?root rdfs:subClassOf ?super }
with

MINUS { ?root rdfs:subClassOf ?super }
in the previous query?

Milorad



>________________________________
> From: Federico López <[email protected]>
>To: [email protected] 
>Sent: Thursday, July 5, 2012 5:28 PM
>Subject: Re: I need to get the root element of a ontology
> 
>2012/7/5 Andy Seaborne <[email protected]>
>
>> On 05/07/12 06:49, Federico López wrote:
>>
>>> I looking for a good quey that allows me to get the roots elements of a
>>> Ontology. Also, I need to know wich one of these roots have children...
>>>
>>>
>>>
>> Version of Jena used?
>> I'm using fuseki 0.2.2...
>>
>>  I have each ontology in a NAMED GRAPH....
>>>
>>
>> And you are querying the union graph?
>
>
>I'm Querying each GRAPH at time...
>
>>
>>
>>
>>> This is what I using for it but the query is taking too much.
>>>
>>
>> How big is the data (in triples)?
>>
>Well...  I'm querying Biomedical Ontologies like FMA(1'859.969 triples),
>RadLex(234.442), ICD10(165.310)...
>
>>
>> Are you using inference?
>
>I don't....
>
>>
>>
>>
>>> SELECT DISTINCT ?root ?label (COUNT(?child) AS ?nChild)
>>> FROM  <http://ontologyURI>
>>> WHERE
>>> {
>>>   ?root a ?class .
>>>   ?class rdfs:subClassOf owl:Class .
>>>   ?root rdfs:label ?label .
>>>   OPTIONAL {
>>>   ?root rdfs:subClassOf ?super .
>>>   }
>>>   OPTIONAL {
>>>   ?child rdfs:subClassOf ?root .
>>>   }
>>>   FILTER (!bound(?super))
>>> }
>>> GROUP BY ?root ?label
>>>
>>> Any idea?
>>>
>>> Thanks...
>>>
>>>
>>>
>> without inference, this maybe what you want: I'm guessing from your
>> description:
>>
>> SELECT ?root
>> {
>>   # A root is something that is of type class
>>   # which has no super class mentioned.
>>   ?root rdf:type owl:Class .
>>   FILTER NOT EXISTS { ?root rdfs:subClassOf ?super }
>>
>>   ?root rdfs:label ?label .
>> }
>>
>> Adding in the COUNT of ?child and GROUP BY is unlikely to be cheap.
>>
>> SELECT ?root (COUNT(DISTINCT ?child) AS ?nChild)
>> {
>>   # A root is something that is of type class
>>   # which has no super class mentioned.
>>   ?root rdf:type owl:Class .
>>   FILTER NOT EXISTS { ?root rdfs:subClassOf ?super }
>>
>>   ?root rdfs:label ?label .
>>   # Children, any depth, by property paths
>>   OPTIONAL { ?child rdfs:subClassOf+ ?root }
>> }
>> GROUP BY ?root
>>         Andy
>>
>
>And thanks, I going to try your query, but I think that is just that I need
>:D
>
>-- 
>*FEDERICO LÓPEZ GÓMEZ*
>Estudiante Ingeniería de Sistemas
>Universidad del Valle - Sede Tuluá
>
>
>

Reply via email to