Hi,
On Fri, 2011-12-02 at 17:02 +0100, Tran Thai Binh wrote:
> Dear all,
>
> I create a RDF file, I have class HighResolution with definition like :
>
> RasterBased
> and (hasSensor some
> (Sensor
> and (hasResolutionValue some float[> 2.5f , <= 10.0f])))
> -----
> -----
>
> I write a code in Jena
>
> ----
> ----
> package query;
>
> import com.hp.hpl.jena.ontology.OntModel;
> import com.hp.hpl.jena.query.Query;
> import com.hp.hpl.jena.query.QueryExecution;
> import com.hp.hpl.jena.query.QueryExecutionFactory;
> import com.hp.hpl.jena.query.QueryFactory;
> import com.hp.hpl.jena.query.ResultSet;
> import com.hp.hpl.jena.query.ResultSetFormatter;
> import com.hp.hpl.jena.rdf.model.ModelFactory;
>
> public class query {
>
> public static void main(String[] args) {
>
> OntModel model = ModelFactory.createOntologyModel(
> org.mindswap.pellet.jena.PelletReasonerFactory.THE_SPEC, null);
> model.read("file:ModelJena.rdf");
>
> model.prepare();
>
> String queryString =
> "PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>"+
> "PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>"+
> "PREFIX test: <
> http://www.semanticweb.org/ontologies/2011/4/DataDomain.owl#>"+
> "select ?data " +
> "where { "+
> "}";
>
> System.out.println(queryString);
>
> Query query = QueryFactory.create(queryString);
>
> // Execute the query and obtain results
> QueryExecution qe = QueryExecutionFactory.create(query, model);
> ResultSet results = qe.execSelect();
>
> // Output query results
> ResultSetFormatter.out(System.out, results, query);
>
> qe.close();
> System.out.println("----------------------");
>
>
> }
> }
>
> ----
> ----
>
> When I query with predefine class like
>
> select ?data
> where ?data a test:HighResolution
>
> Jena run 20 minutes and it looks like can not finish. But it can return
> correct result quite fast with
>
>
> select ?data
> where ?data test:hasSensor ?sensor.
> ?sensor test:hasResolutionValue ?resolution.
> FILTER ((?resolution > 2.5) && (?resolution <= 10))
This goes fast because no reasoning is required. This is the alternative
that I suggested to you earlier.
>
> It is very strange. Could anybody explant to me why.
>
> Thank in advance.
The code looks reasonable.
It may be that there is some problem with your ontology.
The first step is to run it through one of the online ontology checkers
to make sure it is legal OWL 2 DL and doesn't accidentally include some
OWL-fullism.
If it is legal OWL 2 DL then either it is using some expensive OWL 2
features or perhaps it has hit some corner case with Pellet. For support
on that you would need to ask on the Pellet list.
Dave