-
Notifications
You must be signed in to change notification settings - Fork 8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Enhancement: Support for ABox axioms #3
Comments
While class expressions describe sets of individuals than can be queried via SPARQL Maybe we should generate SPARQL |
I would find class expression -> SPARQL rewriting helpful, too. Maybe that's because I make punning statements? For example, I need to find all drug prescription individuals that mention any drug tablet that (indirectly) has the drug 'rosuvastatin' as an active ingredient X a 'drug prescription' http://purl.obolibrary.org/obo/PDRO_0000024 'rosuvastatin Oral Tablet' Superclasses & Asserted Axioms: where rosuvastatin is http://purl.obolibrary.org/obo/DRON_00018679 See also https://stackoverflow.com/questions/51001818/rewrite-owl-class-expression-as-sparql-query Copied from StackOverflow questionThe example code: var ce2s = new OWLClassExpressionToSPARQLConverter()
var a2s = new OWLAxiomToSPARQLConverter("?s", "?o")
var preManager = new OWLManager
var manager = OWLManager.createOWLOntologyManager()
var ontology = manager.loadOntologyFromOntologyDocument(new File("animals.owl"))
var factory = manager.getOWLDataFactory()
var iri = IRI.create("http://example.com/carnivore")
var someClass = factory.getOWLClass(iri)
var declarationAxiom = factory.getOWLDeclarationAxiom(someClass)
println(declarationAxiom)
var asSparql = a2s.convert(declarationAxiom, "?s", "?o")
example output:
with the warning
expected output: select ?s
where
{
?s rdfs:subClassOf <http://example.com/animal> ?r .
?r a owl:Restriction ;
owl:onProperty <http://example.com/eats> ;
owl:someValuesFrom <http://example.com/animal> .
} |
Thank you for the request. |
@turbomam I added an experimental converter from an OWL class expression to a SPARQL query that retrieves subclasses: https://github.com/SmartDataAnalytics/OWL2SPARQL/blob/develop/src/main/java/org/aksw/owl2sparql/OWLClassExpressionToSPARQLSubClassQueryConverter.java Right now, it is only in the You'll need Not sure whether this is what you need, but you could check with your use-case and let me know what's missing resp. is what's wrong. Usage: OWLClassExpressionToSPARQLSubClassQueryConverter converter = new OWLClassExpressionToSPARQLSubClassQueryConverter();
String targetVar = "?x";
OWLClassExpression ce = ...
// with more compact notation of blank nodes
String queryStr = converter.convert(ce, targetVar);
// alternatively, the Jena query object
Query query = converter.asQuery(ce, targetVar); |
Thanks. It's possible that you have provided exactly what I was asking for, but I can't seem to get it to write a query for anything besides animals.owl
Scala script
actual output
expected/desire output
|
As I said before, a declaration axiom is just a statement about the type and existence of an entity, see the W3C documentation.
is not what I guess you expect. First of all, you're using the datafactory, thus, it's creating a new axiom and not querying existing axioms in the ontology (doesn't matter in this case, but for others it would - clearly you're interested in axioms contained in the ontology). In your example,
is a declaration axiom, just stating that there is an OWL class called An OWL ontology consists of a set of OWL axioms. What you'd need in your example is to get the superclass of OWL API provides access to what you want by
|
Thanks, your feedback was very helpful. I have switched my example (https://github.com/turbomam/owl2sparql4turbo, specifially https://github.com/turbomam/owl2sparql4turbo/blob/master/src/main/scala/ROTS.scala) from using an extremely short ontology about animals to a slightly longer ontology about my real problem, drug tablets. Now I get the kind of output I hoped for:
for an input like
|
Is support for ABox axioms planned? Individuals in class expressions seem to be supported. Or am I missing something?
thanks
The text was updated successfully, but these errors were encountered: