Excellent! Thanks Scott, I will try and get this working. -J
On Jul 2, 2:37 pm, Scott Henninger <[email protected]> wrote: > There is a complication to the earlier solution, which will also get > bnodes (i.e. unnamed resources). For example if a class has a > restriction it won't be seen as a "root" class. To correct that, > filter out unnamed classes (I also changed the variable names to be > less confusing): > > CONSTRUCT > { ?cls rdfs:subClassOf owl:Thing .} > > WHERE > { ?cls a owl:Class . > OPTIONAL {?cls rdfs:subClassOf ?superClass . > FILTER isIRI(?superClass)}. > FILTER (!bound(?superClass)) . > > } > > Another solution would be to create a SPIN function that returns a > true for all named classes: > > ASK WHERE { > ?arg1 rdfs:subClassOf ?superClass . > FILTER isIRI(?superClass) . > > } > > This can be used in a query to filter for all unnamed superclasses: > > CONSTRUCT > { ?cls rdfs:subClassOf owl:Thing .}WHERE > > { ?cls a owl:Class > FILTER isIRI(?cls) > FILTER (!:hasNamedSuperClass(?cls)) > > } > > This also outlines a useful idiom. The query calls hasNamedSuperClass > () for each matching resource. In effect, this is a way to do a "for > each" on a query (defined as a SPIN function). I.e. "for each > matching resource, call a query, passing the resource as an argument". > > -- Scott > > On Jul 2, 9:14 am, Scott Henninger <[email protected]> wrote: > > > To determine if a class does not have a named superclass, you could > > use the SPARQL idiom for negation: > > > CONSTRUCT > > { ?cls ?cls rdfs:subClassOf owl:Thing . owl:Thing .} > > > WHERE > > { ?cls a owl:Class . > > OPTIONAL {?cls rdfs:subClassOf ?subc .} . > > FILTER (!bound(?subc)) . > > > } > > > If you do this in a SPARQLMotion script, import the RDF from the > > ontology you need to modify, apply the above construct query, then > > write to a file. > > > -- Scott > > > On Jun 30, 3:18 pm, J-MAN <[email protected]> wrote: > > > > Thanks Holger, thats very helpful. > > > > Is there an easy way (sparql query) to determine if a class does not > > > have a named superclass? > > > > -J > > > > On Jun 30, 3:51 pm, Holger Knublauch <[email protected]> wrote: > > > > > Hi J, > > > > > TopBraid does some background inferencing to infer extra superclass > > > > triples. This makes sure that any class has at least one named > > > > superclass, so that it can be reached from a tree traversal. You would > > > > need to either re-implement this logic yourself, or activate > > > > inferencing on sesame, or simply include the inference graph when you > > > > export the TBC to Sesame. Making matters a bit more complicating, the > > > > triple > > > > > owl:Thing rdfs:subClassOf rdfs:Resource > > > > > has been added by TopBraid into its system triples model, which is > > > > also imported by any project but cannot easily be exported as well. > > > > So, in this case I would recommend to replicate this same triple in > > > > your own file before exporting to Sesame, from the form of owl:Thing. > > > > > Regards, > > > > Holger > > > > > On Jun 30, 2009, at 12:39 PM, J-MAN wrote: > > > > > > We are using TopBraid to build ontologies and data for our > > > > > application. We then move the data & onts to our sesame knowledge > > > > > store. > > > > > > Our RDF works fine inside topbraid composer, but when we move it into > > > > > our sesame store, we are having problems because owl:Thing is not > > > > > being inferred as the base class. > > > > > > How do you infer a class is a direct subclass of owl:Thing? Without > > > > > specifically asserting it? > > > > > > Any suggestions? > > > > > > Thanks > > > > > > -J --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "TopBraid Composer Users" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/topbraid-composer-users?hl=en -~----------~----~----~----~------~----~------~--~---
