ewpatton / SemantEco

Source code for SemantEco
4 stars 5 forks source link

enable use of OWLAPI for testing other reasoners. #49

Open apseyed opened 11 years ago

apseyed commented 11 years ago

consult: OwlapiQueryExecutorImpl.java QueryExecutorImpl.java

(when browsing these in eclipse go through the webapp package (not parent) to get the hyperlinks between classes.

and RegulationModule.java

main tasks: 1) convert the SPARQL restrictions in RegulationModule:queryForSites into an OWL class expression.

OwlapiQueryExecutorImpl:executeLocalQuery handles translating the Jena model into a byte stream into an OWLAPI model, so you just need to be concerned with creating a class expression

2) handle the bindings for retrieving the results to the calling module. Typically the bindings from a sparql query are automatically translated into json. You need to do this for the results of the DL expression query.

Once this is done, you need to have the module manager use the OwlapiQueryExecutorImpl object instead of the QueryExecutorImpl for method executeLocalQuery.

Before adding jars for the reasoners when testing, check if the reasoners have a maven repository.

apseyed commented 11 years ago

line 211 of RegulationModule.java:

// Variables final Variable site = query.getVariable(VAR_NS+SITE_VAR); final Variable lat = query.getVariable(VAR_NS+"lat"); final Variable lng = query.getVariable(VAR_NS+"lng"); final Variable facility = query.createVariableExpression("EXISTS { ?"+SITE_VAR+" a pol:Facility } as ?"+FACILITY_VAR); final Variable polluted = query.createVariableExpression("EXISTS { ?"+SITE_VAR+" a pol:PollutedSite } as ?"+POLLUTED_VAR); final Variable label = query.createVariable(VAR_NS+LABEL_VAR);

    // known uris
    final QueryResource rdfType = query.getResource(RDF_NS+"type");
    final QueryResource polMeasurementSite = query.getResource(POL_NS+"MeasurementSite");
    final QueryResource wgsLat = query.getResource(WGS_NS+"lat");
    final QueryResource wgsLong = query.getResource(WGS_NS+"long");
    final QueryResource rdfsLabel = query.getResource(RDFS_NS+LABEL_VAR);

query.addPattern(site, rdfType, polMeasurementSite); query.addPattern(site, wgsLat, lat); query.addPattern(site, wgsLong, lng); final OptionalComponent optional = query.createOptional(); query.addGraphComponent(optional); optional.addPattern(site, rdfsLabel, label)

apseyed commented 11 years ago

for example:

PREFIX rdfs: http://www.w3.org/2000/01/rdf-schema# PREFIX pol: http://escience.rpi.edu/ontology/semanteco/2/0/pollution.owl# PREFIX xsd: http://www.w3.org/2001/XMLSchema# PREFIX owl: http://www.w3.org/2002/07/owl# PREFIX rdf: http://www.w3.org/1999/02/22-rdf-syntax-ns# SELECT ?site ?lat ?lng (EXISTS { ?site a pol:Facility } as ?facility) (EXISTS { ?site a pol:PollutedSite } as ?polluted) ?label (EXISTS { ?site a http://escience.rpi.edu/ontology/semanteco/2/0/bird.owl#BirdSite } as ?isBird) (EXISTS { ?site a water:WaterSite } as ?isWater) WHERE { ?site http://www.w3.org/1999/02/22-rdf-syntax-ns#type http://escience.rpi.edu/ontology/semanteco/2/0/pollution.owl#MeasurementSite . ?site http://www.w3.org/2003/01/geo/wgs84_pos#lat ?lat . ?site http://www.w3.org/2003/01/geo/wgs84_pos#long ?lng . OPTIONAL { ?site http://www.w3.org/2000/01/rdf-schema#label ?label . } }

apseyed commented 11 years ago

adding note email from Dmitry (Fact++ developer):

Hi Patrice,

thanks, I'm fine. How's ISWC?

FaCT++ does not have Jena interface. Mainly because they are working on different levels: Jena is triple-oriented and FaCT++ is axiom-oriented. In order to implement Jena support it would be necessary to have something like an OWL RDF parser, which I think is too much.

As a partial solution you might have a look at http://www.derivo.de/en/resources/sparql-dl-api.html . This is a SPARQL-DL engine working over the OWL API, so you can use any reasoner with it.

Best, Dmitry.

On 15 November 2012 14:28, Patrice Seyed apseyed@gmail.com wrote: Hi Dimitry,

Hello from ISWC, I hope you are doing well.

I just wanted to ask you, is there an jena interface to Fact++? I am working on a semantic web application that uses Pellet/Sparql, but I don't believe it will be very easy to test and evaluate performance with other reasoners without rewriting the sparql queries as owl-dl type queries. Any information greatly appreciated.

Thanks, Patrice