Query: what are the advantages of the various methods to query an ontology?

classic Classic list List threaded Threaded
19 messages Options
Reply | Threaded
Open this post in threaded view
|

Query: what are the advantages of the various methods to query an ontology?

William Fitzgerald-2
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Dear Semantic Experts:

I have a question in relation to querying ontologies using Protege,
Jena, Pellet and ARQ API's. I hope it can provoke some interesting
conversation.

Am I correct in saying there are 3 ways in which an ontology can be queried?

1) OWL-API or Jena API: It provides a way to get a class for example and
list its subclasses, restrictions, individuals and so forth. Hence, in
one sense, one could write and application that queries the ontologies
in this way. For example. a swing GUI could pass in a string to name a
class in return to have its super and subclasses listed etc etc.


2) Pellet (or FACT for Example): it provides "Logical Query
Capabilities" in the sense that "Equivalent" or "Complete" Classes can
be classified into an existing asserted model. One can view a "complete
class" as a "logical query" placed on the ontology which states
something along the lines of "find me all my subclasses based on my
constraints...". Note: I have used Protege 3.3 in this way when building
an OWL-DL ontology.

3) SPARQL: via Protege's plugin or Jena's ARQ, one can pass SQL like
queries over an OWL ontology (OWL-DL) and have a result passed back
based on pattern matching.

4) I suppose a 4th is using SWRL rules!

Note:
A example Query:
SELECT ?subject WHERE { ?subject rdfs:subClassOf <#Vegetable> }";
Example Class Structure:
Vegetable --> Apple --> Magic Apple

I find that in Protege that when this example is run for instance that I
am only returned Apple (regardless of the ontology be already "classified").

However, in Jena ,I notice that I am returned also the subclass of
Apple. Hence I am returned the result of "Apple" and "Magic Apple". Also
Jena seems to return the Vegetable class itself and the Nothing Class.

Interesting results!!!

Anyhow to play devils advocate:

Why would I use SPARQL to query an ontology rather than developing an
application that directly uses the OWL-API (or even the Jena API)?

Why shouldn't one just focus on Logic Querying when working solely on
OWL-DL models as opposed to the other two methods?

I suppose ultimately what I am asking is: what advantages/disadvantages
have one over the other and why should one care about it?

I am keen to fully understand the semantic web arena and I believe
answering such questions should help me ( and I presume other beginners
too) in developing and packaging various API's, tools etc to do
something useful with an ontology (OWL-DL models in my case, reasoning
is vital in my case).

Its one thing to develop an ontology with an IDE like Protege, but its
quite another trying to maximize usage of that model in real world end
user applications using Jena or Protege api for example to extract the
usefulness of the ontology. (I am guessing Protege uses both OWL-API and
Jena API when programmers use it to develop applications).


Looking forward to some comments.
regards,
Will.


- --
William M. Fitzgerald,
PhD Student,
Telecommunications Software & Systems Group,
ArcLabs Research and Innovation Centre,
Waterford Institute of Technology,
WIT West Campus,
Carriganore,
Waterford.
Office Ph: +353 51 302937
Mobile Ph: +353 87 9527083
Web: www.williamfitzgerald.org



-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFGgSuTIcwlebz1MmwRAvr8AKDcbq8V8HOcLDULbhtpnAohv41C0ACfRANf
MoX8DhsnuV5HgT5R4g2SWw0=
=bSqF
-----END PGP SIGNATURE-----
_______________________________________________
protege-owl mailing list
[hidden email]
https://mailman.stanford.edu/mailman/listinfo/protege-owl

Instructions for unsubscribing: http://protege.stanford.edu/doc/faq.html#01a.03 
Reply | Threaded
Open this post in threaded view
|

Re: Query: what are the advantages of the various methods to query an ontology?

Martin O'Connor

SPARQL is an RDF query language - not an OWL query language. It has no
understanding of many OWL constructs so often does not do what one would
expect it to do when used with OWL.

An equivalent SWRL query [1] will correctly return the subclasses of
Vegetable:

tbox:isSubClassOf(?x, Vegetable) → query:select(?x)

>Why would I use SPARQL to query an ontology rather than developing an
>application that directly uses the OWL-API (or even the Jena API)?
>
>Why shouldn't one just focus on Logic Querying when working solely on
>OWL-DL models as opposed to the other two methods?
>  
>
I wouldn't use SPARQL with OWL because you lose too much semantics.
However, lets assume you use SWRL queries or the equivalent.

The decision to chose one over the other is purely a practical one. If
you are pulling information from an ontology without any processing,
perhaps the API route makes the most sense. However, if you would like
to use relatively complex filters on the information you retrieve,
queries may be appropriate.

Say, for example, your application would like to retrieve all persons
over the age of 15 from an ontology. You could write a SWRL query as
follows:

Person(?p) ^ hasAge(?p, ?age) ^ swrlb:greaterThan(?age, 15) ->
query:select(?p)

and use the SWRLQueryAPI [2] to process the results in a JDBC-like fashion.

Alternative, you could write API level code that retrieves all persons,
all hasAge properties attached to those persons, and then discard the
persons with a property values of 15 or under. This code can get
tiresome to write and can be difficult to maintain and modify. If the
retrieval conditions are complex, the code can get very involved. The
queries on the other hand can be easier to modify and extend - though
they are not a magic bullet.

I think the decision should be based on the expected complexity of the
retrieval requests from the ontology. Mixing both approaches may be
appropriate for some applications.

Martin

[1] http://protege.cim3.net/cgi-bin/wiki.pl?SWRLQueryBuiltIns
[2] http://protege.cim3.net/cgi-bin/wiki.pl?SWRLQueryAPI
_______________________________________________
protege-owl mailing list
[hidden email]
https://mailman.stanford.edu/mailman/listinfo/protege-owl

Instructions for unsubscribing: http://protege.stanford.edu/doc/faq.html#01a.03 
Reply | Threaded
Open this post in threaded view
|

Re: Query: what are the advantages of the various methods to query an ontology?

Michael Fellmann
In reply to this post by William Fitzgerald-2

Hi William,

perhaps a mixture of all the different querying methods depending on the use
case is appropriate. For my purposes, i used Jena's ability to create nested
inference models. First, I created an OWL-inference model and then I
attached this model to Jenas rule reasoner. At the end, I used SPARQL to
query the ontology.
This approach gives me the ability to use SPARQL to retrieve triples that
have been inserted by the reasoners prior to the query execution.

Below is an excerpt of the code I used with the Jena-API.

// configure a rule reasoner
Model m = ModelFactory.createDefaultModel();
Resource config =  m.createResource();
config.addProperty(ReasonerVocabulary.PROPruleMode, "hybrid");
config.addProperty(ReasonerVocabulary.PROPruleSet,  
        "C:\\webapps-dev\\test\\src\\test\\demo.rules");
Reasoner reasoner = GenericRuleReasonerFactory.theInstance().create(config);

// load data into an inference model
OntModelSpec s = new OntModelSpec(OntModelSpec.OWL_MEM_RULE_INF);
OntDocumentManager mgr = new OntDocumentManager();
mgr.setProcessImports(true);
mgr.setCacheModels(false);
s.setDocumentManager(mgr);
Model data = ModelFactory.createOntologyModel(s);
data.read("http://example.org/test.owl");
       
// apply the rule-reasoner on top of the inference model
InfModel infmodel = ModelFactory.createInfModel(reasoner, data);
 
// query this model using SPARQL
...
                       

Michael.






> Message: 1
> Date: Tue, 26 Jun 2007 16:06:59 +0100
> From: william fitzgerald <[hidden email]>
> Subject: [protege-owl] Query: what are the advantages of the various
> methods to query an ontology?
> To: User support for the Protege-OWL editor
> <[hidden email]>
> Message-ID: <[hidden email]>
> Content-Type: text/plain; charset=ISO-8859-1
>
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> Dear Semantic Experts:
>
> I have a question in relation to querying ontologies using Protege,
> Jena, Pellet and ARQ API's. I hope it can provoke some interesting
> conversation.
>
> Am I correct in saying there are 3 ways in which an ontology can be
> queried?
>
> 1) OWL-API or Jena API: It provides a way to get a class for example and
> list its subclasses, restrictions, individuals and so forth. Hence, in
> one sense, one could write and application that queries the ontologies
> in this way. For example. a swing GUI could pass in a string to name a
> class in return to have its super and subclasses listed etc etc.
>
>
> 2) Pellet (or FACT for Example): it provides "Logical Query
> Capabilities" in the sense that "Equivalent" or "Complete" Classes can
> be classified into an existing asserted model. One can view a "complete
> class" as a "logical query" placed on the ontology which states
> something along the lines of "find me all my subclasses based on my
> constraints...". Note: I have used Protege 3.3 in this way when building
> an OWL-DL ontology.
>
> 3) SPARQL: via Protege's plugin or Jena's ARQ, one can pass SQL like
> queries over an OWL ontology (OWL-DL) and have a result passed back
> based on pattern matching.
>
> 4) I suppose a 4th is using SWRL rules!
>
> Note:
> A example Query:
> SELECT ?subject WHERE { ?subject rdfs:subClassOf <#Vegetable> }";
> Example Class Structure:
> Vegetable --> Apple --> Magic Apple
>
> I find that in Protege that when this example is run for instance that I
> am only returned Apple (regardless of the ontology be already
> "classified").
>
> However, in Jena ,I notice that I am returned also the subclass of
> Apple. Hence I am returned the result of "Apple" and "Magic Apple". Also
> Jena seems to return the Vegetable class itself and the Nothing Class.
>
> Interesting results!!!
>
> Anyhow to play devils advocate:
>
> Why would I use SPARQL to query an ontology rather than developing an
> application that directly uses the OWL-API (or even the Jena API)?
>
> Why shouldn't one just focus on Logic Querying when working solely on
> OWL-DL models as opposed to the other two methods?
>
> I suppose ultimately what I am asking is: what advantages/disadvantages
> have one over the other and why should one care about it?
>
> I am keen to fully understand the semantic web arena and I believe
> answering such questions should help me ( and I presume other beginners
> too) in developing and packaging various API's, tools etc to do
> something useful with an ontology (OWL-DL models in my case, reasoning
> is vital in my case).
>
> Its one thing to develop an ontology with an IDE like Protege, but its
> quite another trying to maximize usage of that model in real world end
> user applications using Jena or Protege api for example to extract the
> usefulness of the ontology. (I am guessing Protege uses both OWL-API and
> Jena API when programmers use it to develop applications).
>
>
> Looking forward to some comments.
> regards,
> Will.
>
>
> - --
> William M. Fitzgerald,
> PhD Student,
> Telecommunications Software & Systems Group,
> ArcLabs Research and Innovation Centre,
> Waterford Institute of Technology,
> WIT West Campus,
> Carriganore,
> Waterford.
> Office Ph: +353 51 302937
> Mobile Ph: +353 87 9527083
> Web: www.williamfitzgerald.org
>
>
>
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.6 (GNU/Linux)
> Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
>
> iD8DBQFGgSuTIcwlebz1MmwRAvr8AKDcbq8V8HOcLDULbhtpnAohv41C0ACfRANf
> MoX8DhsnuV5HgT5R4g2SWw0=
> =bSqF
> -----END PGP SIGNATURE-----





_______________________________________________
protege-owl mailing list
[hidden email]
https://mailman.stanford.edu/mailman/listinfo/protege-owl

Instructions for unsubscribing: http://protege.stanford.edu/doc/faq.html#01a.03 
Reply | Threaded
Open this post in threaded view
|

Re: Query: what are the advantages of the various methods to query an ontology?

Martin O'Connor

An equivalent Protege-OWL example would somewhat simpler because SWRL
rules and queries are integrated [1]:

OWLModel owlModel = ... // Create model using normal Protege-OWL mechanisms
SWRLRuleEngineBridge bridge = BridgeFactory.createBridge(owlModel); // Create rule engine
bridge.infer(); // Run the rules and queries
Result result = bridge.getQueryResult("Query-1"); // Query model

For example, if "Query-1" is:

Person(?p) ^ hasName(?p, ?name) ^ hasSalary(?p, ?salary) ->
query:select(?name, ?salary)

the query result can be processed as follows:

while (result.hasNext()) {
  DatatypeValue nameValue = result.getDatatypeValue("?name");
  DatatypeValue salaryValue = result.getDatatypeValue("?salary");
  System.out.println("Name: " + nameValue.getString());
  System.out.println("Salary: " + salaryValue.getInt());
  result.next();
} // while

The query can return both information that already existed in the model
prior to inference and information that was inferred by SWRL rules.

Martin

[1] http://protege.cim3.net/cgi-bin/wiki.pl?SWRLQueryAPI

Michael Fellmann wrote:

>Hi William,
>
>perhaps a mixture of all the different querying methods depending on the use
>case is appropriate. For my purposes, i used Jena's ability to create nested
>inference models. First, I created an OWL-inference model and then I
>attached this model to Jenas rule reasoner. At the end, I used SPARQL to
>query the ontology.
>This approach gives me the ability to use SPARQL to retrieve triples that
>have been inserted by the reasoners prior to the query execution.
>
>Below is an excerpt of the code I used with the Jena-API.
>
>// configure a rule reasoner
>Model m = ModelFactory.createDefaultModel();
>Resource config =  m.createResource();
>config.addProperty(ReasonerVocabulary.PROPruleMode, "hybrid");
>config.addProperty(ReasonerVocabulary.PROPruleSet,  
> "C:\\webapps-dev\\test\\src\\test\\demo.rules");
>Reasoner reasoner = GenericRuleReasonerFactory.theInstance().create(config);
>
>// load data into an inference model
>OntModelSpec s = new OntModelSpec(OntModelSpec.OWL_MEM_RULE_INF);
>OntDocumentManager mgr = new OntDocumentManager();
>mgr.setProcessImports(true);
>mgr.setCacheModels(false);
>s.setDocumentManager(mgr);
>Model data = ModelFactory.createOntologyModel(s);
>data.read("http://example.org/test.owl");
>
>// apply the rule-reasoner on top of the inference model
>InfModel infmodel = ModelFactory.createInfModel(reasoner, data);
>
>// query this model using SPARQL
>...
>
>
>Michael.
>
>
>
>
>
>
>  
>
>>Message: 1
>>Date: Tue, 26 Jun 2007 16:06:59 +0100
>>From: william fitzgerald <[hidden email]>
>>Subject: [protege-owl] Query: what are the advantages of the various
>> methods to query an ontology?
>>To: User support for the Protege-OWL editor
>> <[hidden email]>
>>Message-ID: <[hidden email]>
>>Content-Type: text/plain; charset=ISO-8859-1
>>
>>-----BEGIN PGP SIGNED MESSAGE-----
>>Hash: SHA1
>>
>>Dear Semantic Experts:
>>
>>I have a question in relation to querying ontologies using Protege,
>>Jena, Pellet and ARQ API's. I hope it can provoke some interesting
>>conversation.
>>
>>Am I correct in saying there are 3 ways in which an ontology can be
>>queried?
>>
>>1) OWL-API or Jena API: It provides a way to get a class for example and
>>list its subclasses, restrictions, individuals and so forth. Hence, in
>>one sense, one could write and application that queries the ontologies
>>in this way. For example. a swing GUI could pass in a string to name a
>>class in return to have its super and subclasses listed etc etc.
>>
>>
>>2) Pellet (or FACT for Example): it provides "Logical Query
>>Capabilities" in the sense that "Equivalent" or "Complete" Classes can
>>be classified into an existing asserted model. One can view a "complete
>>class" as a "logical query" placed on the ontology which states
>>something along the lines of "find me all my subclasses based on my
>>constraints...". Note: I have used Protege 3.3 in this way when building
>>an OWL-DL ontology.
>>
>>3) SPARQL: via Protege's plugin or Jena's ARQ, one can pass SQL like
>>queries over an OWL ontology (OWL-DL) and have a result passed back
>>based on pattern matching.
>>
>>4) I suppose a 4th is using SWRL rules!
>>
>>Note:
>>A example Query:
>>SELECT ?subject WHERE { ?subject rdfs:subClassOf <#Vegetable> }";
>>Example Class Structure:
>>Vegetable --> Apple --> Magic Apple
>>
>>I find that in Protege that when this example is run for instance that I
>>am only returned Apple (regardless of the ontology be already
>>"classified").
>>
>>However, in Jena ,I notice that I am returned also the subclass of
>>Apple. Hence I am returned the result of "Apple" and "Magic Apple". Also
>>Jena seems to return the Vegetable class itself and the Nothing Class.
>>
>>Interesting results!!!
>>
>>Anyhow to play devils advocate:
>>
>>Why would I use SPARQL to query an ontology rather than developing an
>>application that directly uses the OWL-API (or even the Jena API)?
>>
>>Why shouldn't one just focus on Logic Querying when working solely on
>>OWL-DL models as opposed to the other two methods?
>>
>>I suppose ultimately what I am asking is: what advantages/disadvantages
>>have one over the other and why should one care about it?
>>
>>I am keen to fully understand the semantic web arena and I believe
>>answering such questions should help me ( and I presume other beginners
>>too) in developing and packaging various API's, tools etc to do
>>something useful with an ontology (OWL-DL models in my case, reasoning
>>is vital in my case).
>>
>>Its one thing to develop an ontology with an IDE like Protege, but its
>>quite another trying to maximize usage of that model in real world end
>>user applications using Jena or Protege api for example to extract the
>>usefulness of the ontology. (I am guessing Protege uses both OWL-API and
>>Jena API when programmers use it to develop applications).
>>
>>
>>Looking forward to some comments.
>>regards,
>>Will.
>>
>>
>>- --
>>William M. Fitzgerald,
>>PhD Student,
>>Telecommunications Software & Systems Group,
>>ArcLabs Research and Innovation Centre,
>>Waterford Institute of Technology,
>>WIT West Campus,
>>Carriganore,
>>Waterford.
>>Office Ph: +353 51 302937
>>Mobile Ph: +353 87 9527083
>>Web: www.williamfitzgerald.org
>>
>>
>>
>>-----BEGIN PGP SIGNATURE-----
>>Version: GnuPG v1.4.6 (GNU/Linux)
>>Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
>>
>>iD8DBQFGgSuTIcwlebz1MmwRAvr8AKDcbq8V8HOcLDULbhtpnAohv41C0ACfRANf
>>MoX8DhsnuV5HgT5R4g2SWw0=
>>=bSqF
>>-----END PGP SIGNATURE-----
>>    
>>
>
>
>
>
>
>_______________________________________________
>protege-owl mailing list
>[hidden email]
>https://mailman.stanford.edu/mailman/listinfo/protege-owl
>
>Instructions for unsubscribing: http://protege.stanford.edu/doc/faq.html#01a.03 
>
>  
>

_______________________________________________
protege-owl mailing list
[hidden email]
https://mailman.stanford.edu/mailman/listinfo/protege-owl

Instructions for unsubscribing: http://protege.stanford.edu/doc/faq.html#01a.03 
Reply | Threaded
Open this post in threaded view
|

reference ontology import failure?

Bernhard Schiemann
In reply to this post by Michael Fellmann
Dear all,
we've builded a reference ontology where:
  <owl:DatatypeProperty rdf:about="#hasString">
    <rdfs:range rdf:resource="http://www.w3.org/2001/XMLSchema#string"/>
    <rdfs:domain rdf:resource="#myContainer"/>
  </owl:DatatypeProperty>
and
  <owl:Class rdf:about="#myContainer">
    <rdfs:subClassOf>
      <owl:Restriction>
        <owl:onProperty>
          <owl:DatatypeProperty rdf:ID="hasString"/>
        </owl:onProperty>
        <owl:cardinality rdf:datatype="http://www.w3.org/2001/XMLSchema#int"
        >1</owl:cardinality>
      </owl:Restriction>
    </rdfs:subClassOf>
  </owl:Class>
everything looks fine. After an import in an empty ontology
myContainer is shown in Protege 3.3beta OWL, but hasString and
the restriction is not shown in the prperties view of protege (clicked
on myContainer).

Is this an import failure?


Greetz
Bernhard


--
*************************************************************
Bernhard Schiemann, Dipl. Ing.
Artificial Intelligence Division
Department of Computer Science
University of Erlangen-Nuremberg
Haberstr. 2, D-91058 Erlangen, Germany

Tel.:  +49-9131-85-28984
Fax :  +49-9131-85-28986
Email: [hidden email]
http://www8.informatik.uni-erlangen.de/inf8/en/schiemann.html
To verify my keys, please use gpg keyserver:
pgp.mit.edu
*************************************************************

_______________________________________________
protege-owl mailing list
[hidden email]
https://mailman.stanford.edu/mailman/listinfo/protege-owl

Instructions for unsubscribing: http://protege.stanford.edu/doc/faq.html#01a.03 

schiemann.vcf (406 bytes) Download Attachment
signature.asc (260 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Query: what are the advantages of the various methods to query an ontology?

William Fitzgerald-2
In reply to this post by Martin O'Connor
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Thanks Martin,

Your comment on SPARQL's appropriateness over OWL has struck a cord. I
was finding it hard to make certain queries and figured it was down to
my current lack of experience (began learning it yesterday).

However, I presumed that OWL is a add-on of RDF and RDF. Hence I
presumed that OWL would also have triples like RDF (although OWL would
have more semantic characteristics).

You have certainly given me food for thought!!!

I am wondering now having built my ontology using Protege should I now
focus on the OWL-API to build a user front-end (possible servlets etc)
rather than Jena?

If Jena is largely RDF based and since I am in the OWL-DL space maybe
Jena is not what I should be using for this. However Jena has an OWL API
inside its shell.

Also if SWRL, as you suggest, can be more beneficial rather than SPARQL
I would need to have Jess working along with the SWRL API. Jena does not
support SWRL :-(

Might I be so bold as to ask what advantages can the "Protege OWL API"
give me over Jena (and the standard OWL-API)?

With Jena I can use the Pellet API directly (developing code in Eclipse
IDE) hence no DIG interface required. I want to stay in the OWL-DL space
so I can reason over (pellet) my ontology if at all possible. Is the
protege API a mixture of both Jena and OWL-API and I suppose SWRL and
SPARQL also? Can it interact with Protege API directly?

I have found the Protege API link:
http://protege.stanford.edu/plugins/owl/api/guide.html

And now I am more confused as to what technology to use, as this link
shows examples of API Querying and other nuts and bolts that Jena does!

regards,
Will.


Martin O'Connor wrote:

>
> SPARQL is an RDF query language - not an OWL query language. It has no
> understanding of many OWL constructs so often does not do what one would
> expect it to do when used with OWL.
>
> An equivalent SWRL query [1] will correctly return the subclasses of
> Vegetable:
>
> tbox:isSubClassOf(?x, Vegetable) → query:select(?x)
>
>> Why would I use SPARQL to query an ontology rather than developing an
>> application that directly uses the OWL-API (or even the Jena API)?
>>
>> Why shouldn't one just focus on Logic Querying when working solely on
>> OWL-DL models as opposed to the other two methods?
>>  
>>
> I wouldn't use SPARQL with OWL because you lose too much semantics.
> However, lets assume you use SWRL queries or the equivalent.
>
> The decision to chose one over the other is purely a practical one. If
> you are pulling information from an ontology without any processing,
> perhaps the API route makes the most sense. However, if you would like
> to use relatively complex filters on the information you retrieve,
> queries may be appropriate.
>
> Say, for example, your application would like to retrieve all persons
> over the age of 15 from an ontology. You could write a SWRL query as
> follows:
>
> Person(?p) ^ hasAge(?p, ?age) ^ swrlb:greaterThan(?age, 15) ->
> query:select(?p)
>
> and use the SWRLQueryAPI [2] to process the results in a JDBC-like fashion.
>
> Alternative, you could write API level code that retrieves all persons,
> all hasAge properties attached to those persons, and then discard the
> persons with a property values of 15 or under. This code can get
> tiresome to write and can be difficult to maintain and modify. If the
> retrieval conditions are complex, the code can get very involved. The
> queries on the other hand can be easier to modify and extend - though
> they are not a magic bullet.
>
> I think the decision should be based on the expected complexity of the
> retrieval requests from the ontology. Mixing both approaches may be
> appropriate for some applications.
>
> Martin
>
> [1] http://protege.cim3.net/cgi-bin/wiki.pl?SWRLQueryBuiltIns
> [2] http://protege.cim3.net/cgi-bin/wiki.pl?SWRLQueryAPI
>

- --
William M. Fitzgerald,
PhD Student,
Telecommunications Software & Systems Group,
ArcLabs Research and Innovation Centre,
Waterford Institute of Technology,
WIT West Campus,
Carriganore,
Waterford.
Office Ph: +353 51 302937
Mobile Ph: +353 87 9527083
Web: www.williamfitzgerald.org



-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFGgh5VIcwlebz1MmwRAj8pAKCYIZighd2mVCJJ8g0hlGXhP4pUBACeMSIw
zpX7SHYMcmVozIpY3324vjw=
=VgG1
-----END PGP SIGNATURE-----
_______________________________________________
protege-owl mailing list
[hidden email]
https://mailman.stanford.edu/mailman/listinfo/protege-owl

Instructions for unsubscribing: http://protege.stanford.edu/doc/faq.html#01a.03 
Reply | Threaded
Open this post in threaded view
|

Re: Query: what are the advantages of the various methods to query an ontology?

William Fitzgerald-2
In reply to this post by Michael Fellmann
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi Micheal,

So you use Jena also. Is there a reason for not using say the Protege
API? I never used it, so playing devils advocate to glean more knowledge
of various API routes to take.

I looked at the Jena API in terms of reasoning and found that it only
supports moderate reasoning across OWL-DL. So I now can reason with an
external reasoner via pellet's API without the need for DIG. Without DIG
 provides more efficiency, more capability (as far as I am aware
reasoning was limited to what DIG could translate to the the reasoner)
and you now don't need to run the pellet server.

Code snippet of direct JENA/PELLET API:
model = ModelFactory.createOntologyModel( PelletReasonerFactory.THE_SPEC );
// create a model for the ontology
model.read( ontology );
// load the model to the reasoner
 model.prepare();
// compute the classification tree
((PelletInfGraph) model.getGraph()).getKB().classify();

Currently I make SPARQL (all be it simple ones, just started this
yesterday) like you, that is after the model has been reasoned over.

Micheal, thanks for your reply.
regards,
Will.


Michael Fellmann wrote:

> Hi William,
>
> perhaps a mixture of all the different querying methods depending on the use
> case is appropriate. For my purposes, i used Jena's ability to create nested
> inference models. First, I created an OWL-inference model and then I
> attached this model to Jenas rule reasoner. At the end, I used SPARQL to
> query the ontology.
> This approach gives me the ability to use SPARQL to retrieve triples that
> have been inserted by the reasoners prior to the query execution.
>
> Below is an excerpt of the code I used with the Jena-API.
>
> // configure a rule reasoner
> Model m = ModelFactory.createDefaultModel();
> Resource config =  m.createResource();
> config.addProperty(ReasonerVocabulary.PROPruleMode, "hybrid");
> config.addProperty(ReasonerVocabulary.PROPruleSet,  
> "C:\\webapps-dev\\test\\src\\test\\demo.rules");
> Reasoner reasoner = GenericRuleReasonerFactory.theInstance().create(config);
>
> // load data into an inference model
> OntModelSpec s = new OntModelSpec(OntModelSpec.OWL_MEM_RULE_INF);
> OntDocumentManager mgr = new OntDocumentManager();
> mgr.setProcessImports(true);
> mgr.setCacheModels(false);
> s.setDocumentManager(mgr);
> Model data = ModelFactory.createOntologyModel(s);
> data.read("http://example.org/test.owl");
>
> // apply the rule-reasoner on top of the inference model
> InfModel infmodel = ModelFactory.createInfModel(reasoner, data);
>  
> // query this model using SPARQL
> ...
>
>
> Michael.
>
>
>
>
>
>
>> Message: 1
>> Date: Tue, 26 Jun 2007 16:06:59 +0100
>> From: william fitzgerald <[hidden email]>
>> Subject: [protege-owl] Query: what are the advantages of the various
>> methods to query an ontology?
>> To: User support for the Protege-OWL editor
>> <[hidden email]>
>> Message-ID: <[hidden email]>
>> Content-Type: text/plain; charset=ISO-8859-1
>>
> Dear Semantic Experts:
>
> I have a question in relation to querying ontologies using Protege,
> Jena, Pellet and ARQ API's. I hope it can provoke some interesting
> conversation.
>
> Am I correct in saying there are 3 ways in which an ontology can be
> queried?
>
> 1) OWL-API or Jena API: It provides a way to get a class for example and
> list its subclasses, restrictions, individuals and so forth. Hence, in
> one sense, one could write and application that queries the ontologies
> in this way. For example. a swing GUI could pass in a string to name a
> class in return to have its super and subclasses listed etc etc.
>
>
> 2) Pellet (or FACT for Example): it provides "Logical Query
> Capabilities" in the sense that "Equivalent" or "Complete" Classes can
> be classified into an existing asserted model. One can view a "complete
> class" as a "logical query" placed on the ontology which states
> something along the lines of "find me all my subclasses based on my
> constraints...". Note: I have used Protege 3.3 in this way when building
> an OWL-DL ontology.
>
> 3) SPARQL: via Protege's plugin or Jena's ARQ, one can pass SQL like
> queries over an OWL ontology (OWL-DL) and have a result passed back
> based on pattern matching.
>
> 4) I suppose a 4th is using SWRL rules!
>
> Note:
> A example Query:
> SELECT ?subject WHERE { ?subject rdfs:subClassOf <#Vegetable> }";
> Example Class Structure:
> Vegetable --> Apple --> Magic Apple
>
> I find that in Protege that when this example is run for instance that I
> am only returned Apple (regardless of the ontology be already
> "classified").
>
> However, in Jena ,I notice that I am returned also the subclass of
> Apple. Hence I am returned the result of "Apple" and "Magic Apple". Also
> Jena seems to return the Vegetable class itself and the Nothing Class.
>
> Interesting results!!!
>
> Anyhow to play devils advocate:
>
> Why would I use SPARQL to query an ontology rather than developing an
> application that directly uses the OWL-API (or even the Jena API)?
>
> Why shouldn't one just focus on Logic Querying when working solely on
> OWL-DL models as opposed to the other two methods?
>
> I suppose ultimately what I am asking is: what advantages/disadvantages
> have one over the other and why should one care about it?
>
> I am keen to fully understand the semantic web arena and I believe
> answering such questions should help me ( and I presume other beginners
> too) in developing and packaging various API's, tools etc to do
> something useful with an ontology (OWL-DL models in my case, reasoning
> is vital in my case).
>
> Its one thing to develop an ontology with an IDE like Protege, but its
> quite another trying to maximize usage of that model in real world end
> user applications using Jena or Protege api for example to extract the
> usefulness of the ontology. (I am guessing Protege uses both OWL-API and
> Jena API when programmers use it to develop applications).
>
>
> Looking forward to some comments.
> regards,
> Will.
>
>

> _______________________________________________
> protege-owl mailing list
> [hidden email]
> https://mailman.stanford.edu/mailman/listinfo/protege-owl

> Instructions for unsubscribing: http://protege.stanford.edu/doc/faq.html#01a.03 


- --
William M. Fitzgerald,
PhD Student,
Telecommunications Software & Systems Group,
ArcLabs Research and Innovation Centre,
Waterford Institute of Technology,
WIT West Campus,
Carriganore,
Waterford.
Office Ph: +353 51 302937
Mobile Ph: +353 87 9527083
Web: www.williamfitzgerald.org



-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFGgiDMIcwlebz1MmwRAng8AKDtdRqgUIZraP1pvoMBBrYCQB9YCgCggZeL
1Ulu1unugt5Icwx3XIzHeC0=
=hriz
-----END PGP SIGNATURE-----
_______________________________________________
protege-owl mailing list
[hidden email]
https://mailman.stanford.edu/mailman/listinfo/protege-owl

Instructions for unsubscribing: http://protege.stanford.edu/doc/faq.html#01a.03 
Reply | Threaded
Open this post in threaded view
|

Re: Query: what are the advantages of the various methods to query an ontology?

William Fitzgerald-2
In reply to this post by Martin O'Connor
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi once again Martin,

when you say "equivalent Protege-OWL example" I presume you mean if I
was to download and start using the Protege API instead of Jena I can
achieve the same results if not more functionality (SWRL API).

Can I ask, once you go the route of SWRL or any rule like engine does
the ontology now become more like OWL-FULL rather than OWL-DL. In that
reasoning is not finite with OWL-FULL like it is for OWL-DL over Pellet
or FACT++ reasoning for example.

Does SWRL only benefit ontologies with lots on individuals? My ontology
for all the world is similar in structure to the Manchester Pizza
Example. The Pizza ontology is 99% Classes. In the tutorial we are
provided with "Logical Queries" rather than SPARQL or SWRL. So for
instance an Vegie Pizza was defined as a Complete Class and the reasoner
could under subsumption query the ontology and logically infer the Vegie
subclasses. Well my ontology is largely like this.



Martin O'Connor wrote:

> An equivalent Protege-OWL example would somewhat simpler because SWRL
> rules and queries are integrated [1]:
>
> OWLModel owlModel = ... // Create model using normal Protege-OWL mechanisms
> SWRLRuleEngineBridge bridge = BridgeFactory.createBridge(owlModel); // Create rule engine
> bridge.infer(); // Run the rules and queries
> Result result = bridge.getQueryResult("Query-1"); // Query model
>
> For example, if "Query-1" is:
>
> Person(?p) ^ hasName(?p, ?name) ^ hasSalary(?p, ?salary) ->
> query:select(?name, ?salary)
>
> the query result can be processed as follows:
>
> while (result.hasNext()) {
>   DatatypeValue nameValue = result.getDatatypeValue("?name");
>   DatatypeValue salaryValue = result.getDatatypeValue("?salary");
>   System.out.println("Name: " + nameValue.getString());
>   System.out.println("Salary: " + salaryValue.getInt());
>   result.next();
> } // while
>
> The query can return both information that already existed in the model
> prior to inference and information that was inferred by SWRL rules.
>
> Martin
>
> [1] http://protege.cim3.net/cgi-bin/wiki.pl?SWRLQueryAPI
>
> Michael Fellmann wrote:
>
>> Hi William,
>>
>> perhaps a mixture of all the different querying methods depending on the use
>> case is appropriate. For my purposes, i used Jena's ability to create nested
>> inference models. First, I created an OWL-inference model and then I
>> attached this model to Jenas rule reasoner. At the end, I used SPARQL to
>> query the ontology.
>> This approach gives me the ability to use SPARQL to retrieve triples that
>> have been inserted by the reasoners prior to the query execution.
>>
>> Below is an excerpt of the code I used with the Jena-API.
>>
>> // configure a rule reasoner
>> Model m = ModelFactory.createDefaultModel();
>> Resource config =  m.createResource();
>> config.addProperty(ReasonerVocabulary.PROPruleMode, "hybrid");
>> config.addProperty(ReasonerVocabulary.PROPruleSet,  
>> "C:\\webapps-dev\\test\\src\\test\\demo.rules");
>> Reasoner reasoner = GenericRuleReasonerFactory.theInstance().create(config);
>>
>> // load data into an inference model
>> OntModelSpec s = new OntModelSpec(OntModelSpec.OWL_MEM_RULE_INF);
>> OntDocumentManager mgr = new OntDocumentManager();
>> mgr.setProcessImports(true);
>> mgr.setCacheModels(false);
>> s.setDocumentManager(mgr);
>> Model data = ModelFactory.createOntologyModel(s);
>> data.read("http://example.org/test.owl");
>>
>> // apply the rule-reasoner on top of the inference model
>> InfModel infmodel = ModelFactory.createInfModel(reasoner, data);
>>
>> // query this model using SPARQL
>> ...
>>
>>
>> Michael.
>>
>>
>>
>>
>>
>>
>>  
>>
>>> Message: 1
>>> Date: Tue, 26 Jun 2007 16:06:59 +0100
>>> From: william fitzgerald <[hidden email]>
>>> Subject: [protege-owl] Query: what are the advantages of the various
>>> methods to query an ontology?
>>> To: User support for the Protege-OWL editor
>>> <[hidden email]>
>>> Message-ID: <[hidden email]>
>>> Content-Type: text/plain; charset=ISO-8859-1
>>>
> Dear Semantic Experts:
>
> I have a question in relation to querying ontologies using Protege,
> Jena, Pellet and ARQ API's. I hope it can provoke some interesting
> conversation.
>
> Am I correct in saying there are 3 ways in which an ontology can be
> queried?
>
> 1) OWL-API or Jena API: It provides a way to get a class for example and
> list its subclasses, restrictions, individuals and so forth. Hence, in
> one sense, one could write and application that queries the ontologies
> in this way. For example. a swing GUI could pass in a string to name a
> class in return to have its super and subclasses listed etc etc.
>
>
> 2) Pellet (or FACT for Example): it provides "Logical Query
> Capabilities" in the sense that "Equivalent" or "Complete" Classes can
> be classified into an existing asserted model. One can view a "complete
> class" as a "logical query" placed on the ontology which states
> something along the lines of "find me all my subclasses based on my
> constraints...". Note: I have used Protege 3.3 in this way when building
> an OWL-DL ontology.
>
> 3) SPARQL: via Protege's plugin or Jena's ARQ, one can pass SQL like
> queries over an OWL ontology (OWL-DL) and have a result passed back
> based on pattern matching.
>
> 4) I suppose a 4th is using SWRL rules!
>
> Note:
> A example Query:
> SELECT ?subject WHERE { ?subject rdfs:subClassOf <#Vegetable> }";
> Example Class Structure:
> Vegetable --> Apple --> Magic Apple
>
> I find that in Protege that when this example is run for instance that I
> am only returned Apple (regardless of the ontology be already
> "classified").
>
> However, in Jena ,I notice that I am returned also the subclass of
> Apple. Hence I am returned the result of "Apple" and "Magic Apple". Also
> Jena seems to return the Vegetable class itself and the Nothing Class.
>
> Interesting results!!!
>
> Anyhow to play devils advocate:
>
> Why would I use SPARQL to query an ontology rather than developing an
> application that directly uses the OWL-API (or even the Jena API)?
>
> Why shouldn't one just focus on Logic Querying when working solely on
> OWL-DL models as opposed to the other two methods?
>
> I suppose ultimately what I am asking is: what advantages/disadvantages
> have one over the other and why should one care about it?
>
> I am keen to fully understand the semantic web arena and I believe
> answering such questions should help me ( and I presume other beginners
> too) in developing and packaging various API's, tools etc to do
> something useful with an ontology (OWL-DL models in my case, reasoning
> is vital in my case).
>
> Its one thing to develop an ontology with an IDE like Protege, but its
> quite another trying to maximize usage of that model in real world end
> user applications using Jena or Protege api for example to extract the
> usefulness of the ontology. (I am guessing Protege uses both OWL-API and
> Jena API when programmers use it to develop applications).
>
>
> Looking forward to some comments.
> regards,
> Will.
>
>

>>>
>>
>>
>>
>>
>> _______________________________________________
>> protege-owl mailing list
>> [hidden email]
>> https://mailman.stanford.edu/mailman/listinfo/protege-owl
>>
>> Instructions for unsubscribing: http://protege.stanford.edu/doc/faq.html#01a.03 
>>
>>  
>>

> _______________________________________________
> protege-owl mailing list
> [hidden email]
> https://mailman.stanford.edu/mailman/listinfo/protege-owl

> Instructions for unsubscribing: http://protege.stanford.edu/doc/faq.html#01a.03 


- --
William M. Fitzgerald,
PhD Student,
Telecommunications Software & Systems Group,
ArcLabs Research and Innovation Centre,
Waterford Institute of Technology,
WIT West Campus,
Carriganore,
Waterford.
Office Ph: +353 51 302937
Mobile Ph: +353 87 9527083
Web: www.williamfitzgerald.org



-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFGgiOAIcwlebz1MmwRAg5PAJ4wt48cd9Xta62sBwqP9nkVuwWlIQCfW2du
mp1YRYMqTWNG91Nb+S7lEHw=
=lhHC
-----END PGP SIGNATURE-----
_______________________________________________
protege-owl mailing list
[hidden email]
https://mailman.stanford.edu/mailman/listinfo/protege-owl

Instructions for unsubscribing: http://protege.stanford.edu/doc/faq.html#01a.03 
Reply | Threaded
Open this post in threaded view
|

Re: Query: what are the advantages of the various methods to query an ontology?

Michael Fellmann
In reply to this post by William Fitzgerald-2

Hi William,

> So you use Jena also. Is there a reason for not using say the Protege
> API?

Definitely no. If you rely on extensive use of SWRL then i presume the
Protege-API is a better fit. If you are enforced (for some other reasons) to
use Jena in your (web-) application then you can use its built-in reasoners.
In this case, you have to convert the SWRL rules to the proprietary Jena
format, which is to a limited extent possible using Sweetrules.      

Kind regards,
Michael.



> I looked at the Jena API in terms of reasoning and found that it only
> supports moderate reasoning across OWL-DL. So I now can reason with an
> external reasoner via pellet's API without the need for DIG. Without DIG
>  provides more efficiency, more capability (as far as I am aware
> reasoning was limited to what DIG could translate to the the reasoner)
> and you now don't need to run the pellet server.
>
> Code snippet of direct JENA/PELLET API:
> model =
> ModelFactory.createOntologyModel( PelletReasonerFactory.THE_SPEC );
> // create a model for the ontology
> model.read( ontology );
> // load the model to the reasoner
>  model.prepare();
> // compute the classification tree
> ((PelletInfGraph) model.getGraph()).getKB().classify();
>
> Currently I make SPARQL (all be it simple ones, just started this
> yesterday) like you, that is after the model has been reasoned over.
>
> Micheal, thanks for your reply.
> regards,
> Will.
>
>

_______________________________________________
protege-owl mailing list
[hidden email]
https://mailman.stanford.edu/mailman/listinfo/protege-owl

Instructions for unsubscribing: http://protege.stanford.edu/doc/faq.html#01a.03 
Reply | Threaded
Open this post in threaded view
|

Re: Query: what are the advantages of the various methods to query an ontology?

William Fitzgerald-2
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Thanks Micheal.

Michael Fellmann wrote:

> Hi William,
>
>> So you use Jena also. Is there a reason for not using say the Protege
>> API?
>
> Definitely no. If you rely on extensive use of SWRL then i presume the
> Protege-API is a better fit. If you are enforced (for some other reasons) to
> use Jena in your (web-) application then you can use its built-in reasoners.
> In this case, you have to convert the SWRL rules to the proprietary Jena
> format, which is to a limited extent possible using Sweetrules.      
>
> Kind regards,
> Michael.
>
>
>
>> I looked at the Jena API in terms of reasoning and found that it only
>> supports moderate reasoning across OWL-DL. So I now can reason with an
>> external reasoner via pellet's API without the need for DIG. Without DIG
>>  provides more efficiency, more capability (as far as I am aware
>> reasoning was limited to what DIG could translate to the the reasoner)
>> and you now don't need to run the pellet server.
>>
>> Code snippet of direct JENA/PELLET API:
>> model =
>> ModelFactory.createOntologyModel( PelletReasonerFactory.THE_SPEC );
>> // create a model for the ontology
>> model.read( ontology );
>> // load the model to the reasoner
>>  model.prepare();
>> // compute the classification tree
>> ((PelletInfGraph) model.getGraph()).getKB().classify();
>>
>> Currently I make SPARQL (all be it simple ones, just started this
>> yesterday) like you, that is after the model has been reasoned over.
>>
>> Micheal, thanks for your reply.
>> regards,
>> Will.
>>
>>
>
> _______________________________________________
> protege-owl mailing list
> [hidden email]
> https://mailman.stanford.edu/mailman/listinfo/protege-owl
>
> Instructions for unsubscribing: http://protege.stanford.edu/doc/faq.html#01a.03 
>

- --
William M. Fitzgerald,
PhD Student,
Telecommunications Software & Systems Group,
ArcLabs Research and Innovation Centre,
Waterford Institute of Technology,
WIT West Campus,
Carriganore,
Waterford.
Office Ph: +353 51 302937
Mobile Ph: +353 87 9527083
Web: www.williamfitzgerald.org



-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD4DBQFGgnLVIcwlebz1MmwRAhm6AKCJiB409puXgdRS19/4vGLc28tTsgCWJZ72
MaTFhWqqtAoz804UPP9jdg==
=uiFh
-----END PGP SIGNATURE-----
_______________________________________________
protege-owl mailing list
[hidden email]
https://mailman.stanford.edu/mailman/listinfo/protege-owl

Instructions for unsubscribing: http://protege.stanford.edu/doc/faq.html#01a.03 
Reply | Threaded
Open this post in threaded view
|

Re: Query: what are the advantages of the various methods to query an ontology?

Martin O'Connor
In reply to this post by William Fitzgerald-2

>However, I presumed that OWL is a add-on of RDF and RDF. Hence I
>presumed that OWL would also have triples like RDF (although OWL would
>have more semantic characteristics).
>  
>
OWL can be represented using RDF but there are semantics for OWL that
are completely independent of RDF. OWL ontologies can be represented as
RDF triples (among other representations) - but this representation can
be quite complex to query at the triple level with SPARQL (as you have
discovered).

>Might I be so bold as to ask what advantages can the "Protege OWL API"
>give me over Jena (and the standard OWL-API)?
>  
>

They are more or less equivalent and choice of which one you should use
depends on the features you require. Jena has more direct contact with
reasoners (though Protege 4 will have too) but has no SWRL support, for
example. Both Protege-OWL and Jena have very active user bases.

Martin


_______________________________________________
protege-owl mailing list
[hidden email]
https://mailman.stanford.edu/mailman/listinfo/protege-owl

Instructions for unsubscribing: http://protege.stanford.edu/doc/faq.html#01a.03 
Reply | Threaded
Open this post in threaded view
|

Re: Query: what are the advantages of the various methods to query an ontology?

Martin O'Connor
In reply to this post by William Fitzgerald-2

>when you say "equivalent Protege-OWL example" I presume you mean if I
>was to download and start using the Protege API instead of Jena I can
>achieve the same results if not more functionality (SWRL API).
>  
>
Yes.

>Can I ask, once you go the route of SWRL or any rule like engine does
>the ontology now become more like OWL-FULL rather than OWL-DL. In that
>reasoning is not finite with OWL-FULL like it is for OWL-DL over Pellet
>or FACT++ reasoning for example.
>  
>
SWRL is based on OWL DL - so you do not have to go to OWL Full when
using SWRL. What you lose with SWRL is the decidability of inference OWL
DL - but that may be an academic rather than a practical issue.

>Does SWRL only benefit ontologies with lots on individuals?
>  
>
Usually, yes. OWL does a good job reasoning with classes and SWRL is
rarely required here. With the TBox library SWRL can be used to query
such an ontology [1] but is probably not going to be useful for inference.

Martin

[1] http://protege.cim3.net/cgi-bin/wiki.pl?SWRLTBoxBuiltIns#nid99P

>
>
>Martin O'Connor wrote:
>  
>
>>An equivalent Protege-OWL example would somewhat simpler because SWRL
>>rules and queries are integrated [1]:
>>
>>OWLModel owlModel = ... // Create model using normal Protege-OWL mechanisms
>>SWRLRuleEngineBridge bridge = BridgeFactory.createBridge(owlModel); // Create rule engine
>>bridge.infer(); // Run the rules and queries
>>Result result = bridge.getQueryResult("Query-1"); // Query model
>>
>>For example, if "Query-1" is:
>>
>>Person(?p) ^ hasName(?p, ?name) ^ hasSalary(?p, ?salary) ->
>>query:select(?name, ?salary)
>>
>>the query result can be processed as follows:
>>
>>while (result.hasNext()) {
>>  DatatypeValue nameValue = result.getDatatypeValue("?name");
>>  DatatypeValue salaryValue = result.getDatatypeValue("?salary");
>>  System.out.println("Name: " + nameValue.getString());
>>  System.out.println("Salary: " + salaryValue.getInt());
>>  result.next();
>>} // while
>>
>>The query can return both information that already existed in the model
>>prior to inference and information that was inferred by SWRL rules.
>>
>>Martin
>>
>>[1] http://protege.cim3.net/cgi-bin/wiki.pl?SWRLQueryAPI
>>
>>Michael Fellmann wrote:
>>
>>    
>>
>>>Hi William,
>>>
>>>perhaps a mixture of all the different querying methods depending on the use
>>>case is appropriate. For my purposes, i used Jena's ability to create nested
>>>inference models. First, I created an OWL-inference model and then I
>>>attached this model to Jenas rule reasoner. At the end, I used SPARQL to
>>>query the ontology.
>>>This approach gives me the ability to use SPARQL to retrieve triples that
>>>have been inserted by the reasoners prior to the query execution.
>>>
>>>Below is an excerpt of the code I used with the Jena-API.
>>>
>>>// configure a rule reasoner
>>>Model m = ModelFactory.createDefaultModel();
>>>Resource config =  m.createResource();
>>>config.addProperty(ReasonerVocabulary.PROPruleMode, "hybrid");
>>>config.addProperty(ReasonerVocabulary.PROPruleSet,  
>>> "C:\\webapps-dev\\test\\src\\test\\demo.rules");
>>>Reasoner reasoner = GenericRuleReasonerFactory.theInstance().create(config);
>>>
>>>// load data into an inference model
>>>OntModelSpec s = new OntModelSpec(OntModelSpec.OWL_MEM_RULE_INF);
>>>OntDocumentManager mgr = new OntDocumentManager();
>>>mgr.setProcessImports(true);
>>>mgr.setCacheModels(false);
>>>s.setDocumentManager(mgr);
>>>Model data = ModelFactory.createOntologyModel(s);
>>>data.read("http://example.org/test.owl");
>>>
>>>// apply the rule-reasoner on top of the inference model
>>>InfModel infmodel = ModelFactory.createInfModel(reasoner, data);
>>>
>>>// query this model using SPARQL
>>>...
>>>
>>>
>>>Michael.
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>      
>>>
>>>>Message: 1
>>>>Date: Tue, 26 Jun 2007 16:06:59 +0100
>>>>From: william fitzgerald <[hidden email]>
>>>>Subject: [protege-owl] Query: what are the advantages of the various
>>>> methods to query an ontology?
>>>>To: User support for the Protege-OWL editor
>>>> <[hidden email]>
>>>>Message-ID: <[hidden email]>
>>>>Content-Type: text/plain; charset=ISO-8859-1
>>>>
>>>>        
>>>>
>>Dear Semantic Experts:
>>
>>I have a question in relation to querying ontologies using Protege,
>>Jena, Pellet and ARQ API's. I hope it can provoke some interesting
>>conversation.
>>
>>Am I correct in saying there are 3 ways in which an ontology can be
>>queried?
>>
>>1) OWL-API or Jena API: It provides a way to get a class for example and
>>list its subclasses, restrictions, individuals and so forth. Hence, in
>>one sense, one could write and application that queries the ontologies
>>in this way. For example. a swing GUI could pass in a string to name a
>>class in return to have its super and subclasses listed etc etc.
>>
>>
>>2) Pellet (or FACT for Example): it provides "Logical Query
>>Capabilities" in the sense that "Equivalent" or "Complete" Classes can
>>be classified into an existing asserted model. One can view a "complete
>>class" as a "logical query" placed on the ontology which states
>>something along the lines of "find me all my subclasses based on my
>>constraints...". Note: I have used Protege 3.3 in this way when building
>>an OWL-DL ontology.
>>
>>3) SPARQL: via Protege's plugin or Jena's ARQ, one can pass SQL like
>>queries over an OWL ontology (OWL-DL) and have a result passed back
>>based on pattern matching.
>>
>>4) I suppose a 4th is using SWRL rules!
>>
>>Note:
>>A example Query:
>>SELECT ?subject WHERE { ?subject rdfs:subClassOf <#Vegetable> }";
>>Example Class Structure:
>>Vegetable --> Apple --> Magic Apple
>>
>>I find that in Protege that when this example is run for instance that I
>>am only returned Apple (regardless of the ontology be already
>>"classified").
>>
>>However, in Jena ,I notice that I am returned also the subclass of
>>Apple. Hence I am returned the result of "Apple" and "Magic Apple". Also
>>Jena seems to return the Vegetable class itself and the Nothing Class.
>>
>>Interesting results!!!
>>
>>Anyhow to play devils advocate:
>>
>>Why would I use SPARQL to query an ontology rather than developing an
>>application that directly uses the OWL-API (or even the Jena API)?
>>
>>Why shouldn't one just focus on Logic Querying when working solely on
>>OWL-DL models as opposed to the other two methods?
>>
>>I suppose ultimately what I am asking is: what advantages/disadvantages
>>have one over the other and why should one care about it?
>>
>>I am keen to fully understand the semantic web arena and I believe
>>answering such questions should help me ( and I presume other beginners
>>too) in developing and packaging various API's, tools etc to do
>>something useful with an ontology (OWL-DL models in my case, reasoning
>>is vital in my case).
>>
>>Its one thing to develop an ontology with an IDE like Protege, but its
>>quite another trying to maximize usage of that model in real world end
>>user applications using Jena or Protege api for example to extract the
>>usefulness of the ontology. (I am guessing Protege uses both OWL-API and
>>Jena API when programmers use it to develop applications).
>>
>>
>>Looking forward to some comments.
>>regards,
>>Will.
>>
>>
>>    
>>
>
>  
>
>>>
>>>
>>>_______________________________________________
>>>protege-owl mailing list
>>>[hidden email]
>>>https://mailman.stanford.edu/mailman/listinfo/protege-owl
>>>
>>>Instructions for unsubscribing: http://protege.stanford.edu/doc/faq.html#01a.03 
>>>
>>>
>>>
>>>      
>>>
>
>  
>
>>_______________________________________________
>>protege-owl mailing list
>>[hidden email]
>>https://mailman.stanford.edu/mailman/listinfo/protege-owl
>>    
>>
>
>  
>
>>Instructions for unsubscribing: http://protege.stanford.edu/doc/faq.html#01a.03 
>>    
>>
>
>
>- --
>William M. Fitzgerald,
>PhD Student,
>Telecommunications Software & Systems Group,
>ArcLabs Research and Innovation Centre,
>Waterford Institute of Technology,
>WIT West Campus,
>Carriganore,
>Waterford.
>Office Ph: +353 51 302937
>Mobile Ph: +353 87 9527083
>Web: www.williamfitzgerald.org
>
>
>
>-----BEGIN PGP SIGNATURE-----
>Version: GnuPG v1.4.6 (GNU/Linux)
>Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
>
>iD8DBQFGgiOAIcwlebz1MmwRAg5PAJ4wt48cd9Xta62sBwqP9nkVuwWlIQCfW2du
>mp1YRYMqTWNG91Nb+S7lEHw=
>=lhHC
>-----END PGP SIGNATURE-----
>_______________________________________________
>protege-owl mailing list
>[hidden email]
>https://mailman.stanford.edu/mailman/listinfo/protege-owl
>
>Instructions for unsubscribing: http://protege.stanford.edu/doc/faq.html#01a.03 
>
>  
>

_______________________________________________
protege-owl mailing list
[hidden email]
https://mailman.stanford.edu/mailman/listinfo/protege-owl

Instructions for unsubscribing: http://protege.stanford.edu/doc/faq.html#01a.03 
Reply | Threaded
Open this post in threaded view
|

Re: Query: what are the advantages of the various methods to query an ontology?

JMiller
In reply to this post by Martin O'Connor

Martin,

I am trying to understand the timing of events.  I understand that SWRL would be used both for queries and rules.  Your example shows the rules and queries being executed at once (by bridge.infer()). Does the SWRL-based model allow the "rule SWRL" to be applied once for everyone, and then the "query SWRL" to be executed when the user requests it?  I am concerned about performance, when we have many rules that apply globally, but we don't want to rerun inferences at query time.

Jim




"Martin O'Connor" <[hidden email]>
Sent by: [hidden email]

06/26/2007 04:43 PM

Please respond to
User support for the Protege-OWL editor        <[hidden email]>

To
User support for the Protege-OWL editor <[hidden email]>
cc
Subject
Re: [protege-owl] Query: what are the advantages of the various        methods to query an ontology?






An equivalent Protege-OWL example would somewhat simpler because SWRL
rules and queries are integrated [1]:

OWLModel owlModel = ... // Create model using normal Protege-OWL mechanisms
SWRLRuleEngineBridge bridge = BridgeFactory.createBridge(owlModel); // Create rule engine
bridge.infer(); // Run the rules and queries
Result result = bridge.getQueryResult("Query-1"); // Query model

For example, if "Query-1" is:

Person(?p) ^ hasName(?p, ?name) ^ hasSalary(?p, ?salary) ->
query:select(?name, ?salary)

the query result can be processed as follows:

while (result.hasNext()) {
 DatatypeValue nameValue = result.getDatatypeValue("?name");
 DatatypeValue salaryValue = result.getDatatypeValue("?salary");
 System.out.println("Name: " + nameValue.getString());
 System.out.println("Salary: " + salaryValue.getInt());
 result.next();
} // while

The query can return both information that already existed in the model
prior to inference and information that was inferred by SWRL rules.

Martin

[1] http://protege.cim3.net/cgi-bin/wiki.pl?SWRLQueryAPI

Michael Fellmann wrote:

>Hi William,
>
>perhaps a mixture of all the different querying methods depending on the use
>case is appropriate. For my purposes, i used Jena's ability to create nested
>inference models. First, I created an OWL-inference model and then I
>attached this model to Jenas rule reasoner. At the end, I used SPARQL to
>query the ontology.
>This approach gives me the ability to use SPARQL to retrieve triples that
>have been inserted by the reasoners prior to the query execution.
>
>Below is an excerpt of the code I used with the Jena-API.
>
>// configure a rule reasoner
>Model m = ModelFactory.createDefaultModel();
>Resource config =  m.createResource();
>config.addProperty(ReasonerVocabulary.PROPruleMode, "hybrid");
>config.addProperty(ReasonerVocabulary.PROPruleSet,  
>                 "C:\\webapps-dev\\test\\src\\test\\demo.rules");
>Reasoner reasoner = GenericRuleReasonerFactory.theInstance().create(config);
>
>// load data into an inference model
>OntModelSpec s = new OntModelSpec(OntModelSpec.OWL_MEM_RULE_INF);
>OntDocumentManager mgr = new OntDocumentManager();
>mgr.setProcessImports(true);
>mgr.setCacheModels(false);
>s.setDocumentManager(mgr);
>Model data = ModelFactory.createOntologyModel(s);
>data.read("http://example.org/test.owl");
>                
>// apply the rule-reasoner on top of the inference model
>InfModel infmodel = ModelFactory.createInfModel(reasoner, data);
>
>// query this model using SPARQL
>...
>                                                  
>
>Michael.
>
>
>
>
>
>
>  
>
>>Message: 1
>>Date: Tue, 26 Jun 2007 16:06:59 +0100
>>From: william fitzgerald <[hidden email]>
>>Subject: [protege-owl] Query: what are the advantages of the various
>>                 methods to query an ontology?
>>To: User support for the Protege-OWL editor
>>                 <[hidden email]>
>>Message-ID: <[hidden email]>
>>Content-Type: text/plain; charset=ISO-8859-1
>>
>>-----BEGIN PGP SIGNED MESSAGE-----
>>Hash: SHA1
>>
>>Dear Semantic Experts:
>>
>>I have a question in relation to querying ontologies using Protege,
>>Jena, Pellet and ARQ API's. I hope it can provoke some interesting
>>conversation.
>>
>>Am I correct in saying there are 3 ways in which an ontology can be
>>queried?
>>
>>1) OWL-API or Jena API: It provides a way to get a class for example and
>>list its subclasses, restrictions, individuals and so forth. Hence, in
>>one sense, one could write and application that queries the ontologies
>>in this way. For example. a swing GUI could pass in a string to name a
>>class in return to have its super and subclasses listed etc etc.
>>
>>
>>2) Pellet (or FACT for Example): it provides "Logical Query
>>Capabilities" in the sense that "Equivalent" or "Complete" Classes can
>>be classified into an existing asserted model. One can view a "complete
>>class" as a "logical query" placed on the ontology which states
>>something along the lines of "find me all my subclasses based on my
>>constraints...". Note: I have used Protege 3.3 in this way when building
>>an OWL-DL ontology.
>>
>>3) SPARQL: via Protege's plugin or Jena's ARQ, one can pass SQL like
>>queries over an OWL ontology (OWL-DL) and have a result passed back
>>based on pattern matching.
>>
>>4) I suppose a 4th is using SWRL rules!
>>
>>Note:
>>A example Query:
>>SELECT ?subject WHERE { ?subject rdfs:subClassOf <#Vegetable> }";
>>Example Class Structure:
>>Vegetable --> Apple --> Magic Apple
>>
>>I find that in Protege that when this example is run for instance that I
>>am only returned Apple (regardless of the ontology be already
>>"classified").
>>
>>However, in Jena ,I notice that I am returned also the subclass of
>>Apple. Hence I am returned the result of "Apple" and "Magic Apple". Also
>>Jena seems to return the Vegetable class itself and the Nothing Class.
>>
>>Interesting results!!!
>>
>>Anyhow to play devils advocate:
>>
>>Why would I use SPARQL to query an ontology rather than developing an
>>application that directly uses the OWL-API (or even the Jena API)?
>>
>>Why shouldn't one just focus on Logic Querying when working solely on
>>OWL-DL models as opposed to the other two methods?
>>
>>I suppose ultimately what I am asking is: what advantages/disadvantages
>>have one over the other and why should one care about it?
>>
>>I am keen to fully understand the semantic web arena and I believe
>>answering such questions should help me ( and I presume other beginners
>>too) in developing and packaging various API's, tools etc to do
>>something useful with an ontology (OWL-DL models in my case, reasoning
>>is vital in my case).
>>
>>Its one thing to develop an ontology with an IDE like Protege, but its
>>quite another trying to maximize usage of that model in real world end
>>user applications using Jena or Protege api for example to extract the
>>usefulness of the ontology. (I am guessing Protege uses both OWL-API and
>>Jena API when programmers use it to develop applications).
>>
>>
>>Looking forward to some comments.
>>regards,
>>Will.
>>
>>
>>- --
>>William M. Fitzgerald,
>>PhD Student,
>>Telecommunications Software & Systems Group,
>>ArcLabs Research and Innovation Centre,
>>Waterford Institute of Technology,
>>WIT West Campus,
>>Carriganore,
>>Waterford.
>>Office Ph: +353 51 302937
>>Mobile Ph: +353 87 9527083
>>Web: www.williamfitzgerald.org
>>
>>
>>
>>-----BEGIN PGP SIGNATURE-----
>>Version: GnuPG v1.4.6 (GNU/Linux)
>>Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
>>
>>iD8DBQFGgSuTIcwlebz1MmwRAvr8AKDcbq8V8HOcLDULbhtpnAohv41C0ACfRANf
>>MoX8DhsnuV5HgT5R4g2SWw0=
>>=bSqF
>>-----END PGP SIGNATURE-----
>>    
>>
>
>
>
>
>
>_______________________________________________
>protege-owl mailing list
>[hidden email]
>https://mailman.stanford.edu/mailman/listinfo/protege-owl
>
>Instructions for unsubscribing: http://protege.stanford.edu/doc/faq.html#01a.03
>
>  
>

_______________________________________________
protege-owl mailing list
[hidden email]
https://mailman.stanford.edu/mailman/listinfo/protege-owl

Instructions for unsubscribing: http://protege.stanford.edu/doc/faq.html#01a.03


_______________________________________________
protege-owl mailing list
[hidden email]
https://mailman.stanford.edu/mailman/listinfo/protege-owl

Instructions for unsubscribing: http://protege.stanford.edu/doc/faq.html#01a.03 
Reply | Threaded
Open this post in threaded view
|

Re: Query: what are the advantages of the various methods to query an ontology?

Martin O'Connor

 

Rules and queries are executed in parallel because a query may return inference results. Take, for example, the following rule:

 

Person(?p) ^ has Age(?p, ?age) ^ swrlb:greaterThan(?age, 17) -> Adult(?p)

 

And the query:

 

Adult(?a) -> query:select(?a)

 

Clearly one would like the query to return adults that are inferred by the rule.

 

The current SWRLTab query implementation is certainly not a desperately efficient solution. My goal at the moment is to get the richest feature set possible and to worry about optimizations later. However, we have successfully used the query system on ontologies with 100k or so individuals. The SWRLTab also allows selective enabling and disabling of rules and queries, which provides a coarse level of optimization.

 

Martin

 

 


From: [hidden email] [mailto:[hidden email]] On Behalf Of James A Miller
Sent: Wednesday, June 27, 2007 8:18 PM
To: User support for the Protege-OWL editor
Cc: User support for the Protege-OWL editor; [hidden email]
Subject: Re: [protege-owl] Query: what are the advantages of the various methods to query an ontology?

 


Martin,

I am trying to understand the timing of events.  I understand that SWRL would be used both for queries and rules.  Your example shows the rules and queries being executed at once (by bridge.infer()). Does the SWRL-based model allow the "rule SWRL" to be applied once for everyone, and then the "query SWRL" to be executed when the user requests it?  I am concerned about performance, when we have many rules that apply globally, but we don't want to rerun inferences at query time.

Jim



"Martin O'Connor" <[hidden email]>
Sent by: [hidden email]

06/26/2007 04:43 PM

Please respond to
User support for the Protege-OWL editor        <[hidden email]>

To

User support for the Protege-OWL editor <[hidden email]>

cc

 

Subject

Re: [protege-owl] Query: what are the advantages of the various        methods to query an ontology?

 

 

 





An equivalent Protege-OWL example would somewhat simpler because SWRL
rules and queries are integrated [1]:

OWLModel owlModel = ... // Create model using normal Protege-OWL mechanisms
SWRLRuleEngineBridge bridge = BridgeFactory.createBridge(owlModel); // Create rule engine
bridge.infer(); // Run the rules and queries
Result result = bridge.getQueryResult("Query-1"); // Query model

For example, if "Query-1" is:

Person(?p) ^ hasName(?p, ?name) ^ hasSalary(?p, ?salary) ->
query:select(?name, ?salary)

the query result can be processed as follows:

while (result.hasNext()) {
 DatatypeValue nameValue = result.getDatatypeValue("?name");
 DatatypeValue salaryValue = result.getDatatypeValue("?salary");
 System.out.println("Name: " + nameValue.getString());
 System.out.println("Salary: " + salaryValue.getInt());
 result.next();
} // while

The query can return both information that already existed in the model
prior to inference and information that was inferred by SWRL rules.

Martin

[1] http://protege.cim3.net/cgi-bin/wiki.pl?SWRLQueryAPI

Michael Fellmann wrote:

>Hi William,
>
>perhaps a mixture of all the different querying methods depending on the use
>case is appropriate. For my purposes, i used Jena's ability to create nested
>inference models. First, I created an OWL-inference model and then I
>attached this model to Jenas rule reasoner. At the end, I used SPARQL to
>query the ontology.
>This approach gives me the ability to use SPARQL to retrieve triples that
>have been inserted by the reasoners prior to the query execution.
>
>Below is an excerpt of the code I used with the Jena-API.
>
>// configure a rule reasoner
>Model m = ModelFactory.createDefaultModel();
>Resource config =  m.createResource();
>config.addProperty(ReasonerVocabulary.PROPruleMode, "hybrid");
>config.addProperty(ReasonerVocabulary.PROPruleSet,  
>                 "C:\\webapps-dev\\test\\src\\test\\demo.rules");
>Reasoner reasoner = GenericRuleReasonerFactory.theInstance().create(config);
>
>// load data into an inference model
>OntModelSpec s = new OntModelSpec(OntModelSpec.OWL_MEM_RULE_INF);
>OntDocumentManager mgr = new OntDocumentManager();
>mgr.setProcessImports(true);
>mgr.setCacheModels(false);
>s.setDocumentManager(mgr);
>Model data = ModelFactory.createOntologyModel(s);
>data.read("http://example.org/test.owl");
>                
>// apply the rule-reasoner on top of the inference model
>InfModel infmodel = ModelFactory.createInfModel(reasoner, data);
>
>// query this model using SPARQL
>...
>                                                  
>
>Michael.
>
>
>
>
>
>
>  
>
>>Message: 1
>>Date: Tue, 26 Jun 2007 16:06:59 +0100
>>From: william fitzgerald <[hidden email]>
>>Subject: [protege-owl] Query: what are the advantages of the various
>>                 methods to query an ontology?
>>To: User support for the Protege-OWL editor
>>                 <[hidden email]>
>>Message-ID: <[hidden email]>
>>Content-Type: text/plain; charset=ISO-8859-1
>>
>>-----BEGIN PGP SIGNED MESSAGE-----
>>Hash: SHA1
>>
>>Dear Semantic Experts:
>>
>>I have a question in relation to querying ontologies using Protege,
>>Jena, Pellet and ARQ API's. I hope it can provoke some interesting
>>conversation.
>>
>>Am I correct in saying there are 3 ways in which an ontology can be
>>queried?
>>
>>1) OWL-API or Jena API: It provides a way to get a class for example and
>>list its subclasses, restrictions, individuals and so forth. Hence, in
>>one sense, one could write and application that queries the ontologies
>>in this way. For example. a swing GUI could pass in a string to name a
>>class in return to have its super and subclasses listed etc etc.
>>
>>
>>2) Pellet (or FACT for Example): it provides "Logical Query
>>Capabilities" in the sense that "Equivalent" or "Complete" Classes can
>>be classified into an existing asserted model. One can view a "complete
>>class" as a "logical query" placed on the ontology which states
>>something along the lines of "find me all my subclasses based on my
>>constraints...". Note: I have used Protege 3.3 in this way when building
>>an OWL-DL ontology.
>>
>>3) SPARQL: via Protege's plugin or Jena's ARQ, one can pass SQL like
>>queries over an OWL ontology (OWL-DL) and have a result passed back
>>based on pattern matching.
>>
>>4) I suppose a 4th is using SWRL rules!
>>
>>Note:
>>A example Query:
>>SELECT ?subject WHERE { ?subject rdfs:subClassOf <#Vegetable> }";
>>Example Class Structure:
>>Vegetable --> Apple --> Magic Apple
>>
>>I find that in Protege that when this example is run for instance that I
>>am only returned Apple (regardless of the ontology be already
>>"classified").
>>
>>However, in Jena ,I notice that I am returned also the subclass of
>>Apple. Hence I am returned the result of "Apple" and "Magic Apple". Also
>>Jena seems to return the Vegetable class itself and the Nothing Class.
>>
>>Interesting results!!!
>>
>>Anyhow to play devils advocate:
>>
>>Why would I use SPARQL to query an ontology rather than developing an
>>application that directly uses the OWL-API (or even the Jena API)?
>>
>>Why shouldn't one just focus on Logic Querying when working solely on
>>OWL-DL models as opposed to the other two methods?
>>
>>I suppose ultimately what I am asking is: what advantages/disadvantages
>>have one over the other and why should one care about it?
>>
>>I am keen to fully understand the semantic web arena and I believe
>>answering such questions should help me ( and I presume other beginners
>>too) in developing and packaging various API's, tools etc to do
>>something useful with an ontology (OWL-DL models in my case, reasoning
>>is vital in my case).
>>
>>Its one thing to develop an ontology with an IDE like Protege, but its
>>quite another trying to maximize usage of that model in real world end
>>user applications using Jena or Protege api for example to extract the
>>usefulness of the ontology. (I am guessing Protege uses both OWL-API and
>>Jena API when programmers use it to develop applications).
>>
>>
>>Looking forward to some comments.
>>regards,
>>Will.
>>
>>
>>- --
>>William M. Fitzgerald,
>>PhD Student,
>>Telecommunications Software & Systems Group,
>>ArcLabs Research and Innovation Centre,
>>Waterford Institute of Technology,
>>WIT West Campus,
>>Carriganore,
>>Waterford.
>>Office Ph: +353 51 302937
>>Mobile Ph: +353 87 9527083
>>Web: www.williamfitzgerald.org
>>
>>
>>
>>-----BEGIN PGP SIGNATURE-----
>>Version: GnuPG v1.4.6 (GNU/Linux)
>>Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
>>
>>iD8DBQFGgSuTIcwlebz1MmwRAvr8AKDcbq8V8HOcLDULbhtpnAohv41C0ACfRANf
>>MoX8DhsnuV5HgT5R4g2SWw0=
>>=bSqF
>>-----END PGP SIGNATURE-----
>>    
>>
>
>
>
>
>
>_______________________________________________
>protege-owl mailing list
>[hidden email]
>https://mailman.stanford.edu/mailman/listinfo/protege-owl
>
>Instructions for unsubscribing: http://protege.stanford.edu/doc/faq.html#01a.03
>
>  
>

_______________________________________________
protege-owl mailing list
[hidden email]
https://mailman.stanford.edu/mailman/listinfo/protege-owl

Instructions for unsubscribing: http://protege.stanford.edu/doc/faq.html#01a.03


_______________________________________________
protege-owl mailing list
[hidden email]
https://mailman.stanford.edu/mailman/listinfo/protege-owl

Instructions for unsubscribing: http://protege.stanford.edu/doc/faq.html#01a.03 
Reply | Threaded
Open this post in threaded view
|

Re: Query: what are the advantages of the various methods to query an ontology?

JMiller

Is it possible, using SWRL, to save the Adult(?p) from your example into a knowledge base, or does it need to be recomputed for each query?

Jim



"Martin O'Connor" <[hidden email]>
Sent by: [hidden email]

06/28/2007 12:20 AM

Please respond to
User support for the Protege-OWL editor        <[hidden email]>

To
"'User support for the Protege-OWL editor'" <[hidden email]>
cc
Subject
Re: [protege-owl] Query: what are the advantages of the        various        methods to query an ontology?





 
Rules and queries are executed in parallel because a query may return inference results. Take, for example, the following rule:
 
Person(?p) ^ has Age(?p, ?age) ^ swrlb:greaterThan(?age, 17) -> Adult(?p)
 
And the query:
 
Adult(?a) -> query:select(?a)
 
Clearly one would like the query to return adults that are inferred by the rule.
 
The current SWRLTab query implementation is certainly not a desperately efficient solution. My goal at the moment is to get the richest feature set possible and to worry about optimizations later. However, we have successfully used the query system on ontologies with 100k or so individuals. The SWRLTab also allows selective enabling and disabling of rules and queries, which provides a coarse level of optimization.
 
Martin
 
 



From: [hidden email] [mailto:[hidden email]] On Behalf Of James A Miller
Sent:
Wednesday, June 27, 2007 8:18 PM
To:
User support for the Protege-OWL editor
Cc:
User support for the Protege-OWL editor; [hidden email]
Subject:
Re: [protege-owl] Query: what are the advantages of the various methods to query an ontology?

 

Martin,


I am trying to understand the timing of events.  I understand that SWRL would be used both for queries and rules.  Your example shows the rules and queries being executed at once (by bridge.infer()). Does the SWRL-based model allow the "rule SWRL" to be applied once for everyone, and then the "query SWRL" to be executed when the user requests it?  I am concerned about performance, when we have many rules that apply globally, but we don't want to rerun inferences at query time.


Jim



"Martin O'Connor" <[hidden email]>
Sent by: [hidden email]

06/26/2007 04:43 PM


Please respond to
User support for the Protege-OWL editor        <[hidden email]>


To
User support for the Protege-OWL editor <[hidden email]>
cc
 
Subject
Re: [protege-owl] Query: what are the advantages of the various        methods to query an ontology?

 


   






An equivalent Protege-OWL example would somewhat simpler because SWRL
rules and queries are integrated [1]:

OWLModel owlModel = ... // Create model using normal Protege-OWL mechanisms
SWRLRuleEngineBridge bridge = BridgeFactory.createBridge(owlModel); // Create rule engine
bridge.infer(); // Run the rules and queries
Result result = bridge.getQueryResult("Query-1"); // Query model

For example, if "Query-1" is:

Person(?p) ^ hasName(?p, ?name) ^ hasSalary(?p, ?salary) ->
query:select(?name, ?salary)

the query result can be processed as follows:

while (result.hasNext()) {
DatatypeValue nameValue = result.getDatatypeValue("?name");
DatatypeValue salaryValue = result.getDatatypeValue("?salary");
System.out.println("Name: " + nameValue.getString());
System.out.println("Salary: " + salaryValue.getInt());
result.next();
} // while

The query can return both information that already existed in the model
prior to inference and information that was inferred by SWRL rules.

Martin

[1] http://protege.cim3.net/cgi-bin/wiki.pl?SWRLQueryAPI

Michael Fellmann wrote:

>Hi William,
>
>perhaps a mixture of all the different querying methods depending on the use
>case is appropriate. For my purposes, i used Jena's ability to create nested
>inference models. First, I created an OWL-inference model and then I
>attached this model to Jenas rule reasoner. At the end, I used SPARQL to
>query the ontology.
>This approach gives me the ability to use SPARQL to retrieve triples that
>have been inserted by the reasoners prior to the query execution.
>
>Below is an excerpt of the code I used with the Jena-API.
>
>// configure a rule reasoner
>Model m = ModelFactory.createDefaultModel();
>Resource config =  m.createResource();
>config.addProperty(ReasonerVocabulary.PROPruleMode, "hybrid");
>config.addProperty(ReasonerVocabulary.PROPruleSet,  
>                 "C:\\webapps-dev\\test\\src\\test\\demo.rules");
>Reasoner reasoner = GenericRuleReasonerFactory.theInstance().create(config);
>
>// load data into an inference model
>OntModelSpec s = new OntModelSpec(OntModelSpec.OWL_MEM_RULE_INF);
>OntDocumentManager mgr = new OntDocumentManager();
>mgr.setProcessImports(true);
>mgr.setCacheModels(false);
>s.setDocumentManager(mgr);
>Model data = ModelFactory.createOntologyModel(s);
>data.read("http://example.org/test.owl");
>                
>// apply the rule-reasoner on top of the inference model
>InfModel infmodel = ModelFactory.createInfModel(reasoner, data);
>
>// query this model using SPARQL
>...
>                                                  
>
>Michael.
>
>
>
>
>
>
>  
>
>>Message: 1
>>Date: Tue, 26 Jun 2007 16:06:59 +0100
>>From: william fitzgerald <[hidden email]>
>>Subject: [protege-owl] Query: what are the advantages of the various
>>                 methods to query an ontology?
>>To: User support for the Protege-OWL editor
>>                 <[hidden email]>
>>Message-ID: <[hidden email]>
>>Content-Type: text/plain; charset=ISO-8859-1
>>
>>-----BEGIN PGP SIGNED MESSAGE-----
>>Hash: SHA1
>>
>>Dear Semantic Experts:
>>
>>I have a question in relation to querying ontologies using Protege,
>>Jena, Pellet and ARQ API's. I hope it can provoke some interesting
>>conversation.
>>
>>Am I correct in saying there are 3 ways in which an ontology can be
>>queried?
>>
>>1) OWL-API or Jena API: It provides a way to get a class for example and
>>list its subclasses, restrictions, individuals and so forth. Hence, in
>>one sense, one could write and application that queries the ontologies
>>in this way. For example. a swing GUI could pass in a string to name a
>>class in return to have its super and subclasses listed etc etc.
>>
>>
>>2) Pellet (or FACT for Example): it provides "Logical Query
>>Capabilities" in the sense that "Equivalent" or "Complete" Classes can
>>be classified into an existing asserted model. One can view a "complete
>>class" as a "logical query" placed on the ontology which states
>>something along the lines of "find me all my subclasses based on my
>>constraints...". Note: I have used Protege 3.3 in this way when building
>>an OWL-DL ontology.
>>
>>3) SPARQL: via Protege's plugin or Jena's ARQ, one can pass SQL like
>>queries over an OWL ontology (OWL-DL) and have a result passed back
>>based on pattern matching.
>>
>>4) I suppose a 4th is using SWRL rules!
>>
>>Note:
>>A example Query:
>>SELECT ?subject WHERE { ?subject rdfs:subClassOf <#Vegetable> }";
>>Example Class Structure:
>>Vegetable --> Apple --> Magic Apple
>>
>>I find that in Protege that when this example is run for instance that I
>>am only returned Apple (regardless of the ontology be already
>>"classified").
>>
>>However, in Jena ,I notice that I am returned also the subclass of
>>Apple. Hence I am returned the result of "Apple" and "Magic Apple". Also
>>Jena seems to return the Vegetable class itself and the Nothing Class.
>>
>>Interesting results!!!
>>
>>Anyhow to play devils advocate:
>>
>>Why would I use SPARQL to query an ontology rather than developing an
>>application that directly uses the OWL-API (or even the Jena API)?
>>
>>Why shouldn't one just focus on Logic Querying when working solely on
>>OWL-DL models as opposed to the other two methods?
>>
>>I suppose ultimately what I am asking is: what advantages/disadvantages
>>have one over the other and why should one care about it?
>>
>>I am keen to fully understand the semantic web arena and I believe
>>answering such questions should help me ( and I presume other beginners
>>too) in developing and packaging various API's, tools etc to do
>>something useful with an ontology (OWL-DL models in my case, reasoning
>>is vital in my case).
>>
>>Its one thing to develop an ontology with an IDE like Protege, but its
>>quite another trying to maximize usage of that model in real world end
>>user applications using Jena or Protege api for example to extract the
>>usefulness of the ontology. (I am guessing Protege uses both OWL-API and
>>Jena API when programmers use it to develop applications).
>>
>>
>>Looking forward to some comments.
>>regards,
>>Will.
>>
>>
>>- --
>>William M. Fitzgerald,
>>PhD Student,
>>Telecommunications Software & Systems Group,
>>ArcLabs Research and Innovation Centre,
>>Waterford Institute of Technology,
>>WIT West Campus,
>>Carriganore,
>>Waterford.
>>Office Ph: +353 51 302937
>>Mobile Ph: +353 87 9527083
>>Web: www.williamfitzgerald.org
>>
>>
>>
>>-----BEGIN PGP SIGNATURE-----
>>Version: GnuPG v1.4.6 (GNU/Linux)
>>Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
>>
>>iD8DBQFGgSuTIcwlebz1MmwRAvr8AKDcbq8V8HOcLDULbhtpnAohv41C0ACfRANf
>>MoX8DhsnuV5HgT5R4g2SWw0=
>>=bSqF
>>-----END PGP SIGNATURE-----
>>    
>>
>
>
>
>
>
>_______________________________________________
>protege-owl mailing list
>[hidden email]
>https://mailman.stanford.edu/mailman/listinfo/protege-owl
>
>Instructions for unsubscribing: http://protege.stanford.edu/doc/faq.html#01a.03
>
>  
>

_______________________________________________
protege-owl mailing list
[hidden email]
https://mailman.stanford.edu/mailman/listinfo/protege-owl

Instructions for unsubscribing: http://protege.stanford.edu/doc/faq.html#01a.03
_______________________________________________
protege-owl mailing list
[hidden email]
https://mailman.stanford.edu/mailman/listinfo/protege-owl

Instructions for unsubscribing: http://protege.stanford.edu/doc/faq.html#01a.03


_______________________________________________
protege-owl mailing list
[hidden email]
https://mailman.stanford.edu/mailman/listinfo/protege-owl

Instructions for unsubscribing: http://protege.stanford.edu/doc/faq.html#01a.03 
Reply | Threaded
Open this post in threaded view
|

Re: Query: what are the advantages of the various methods to query an ontology?

William Fitzgerald-2
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi All,

I wonder should the specific SWRL related stuff be directed to a new
thread and keep this thread focused on various methods of querying an
ontology and why one should be chosen over an other.

Cheers,
Will.


James A Miller wrote:

>
> Is it possible, using SWRL, to save the Adult(?p) from your example into
> a knowledge base, or does it need to be recomputed for each query?
>
> Jim
>
>
>
> *"Martin O'Connor" <[hidden email]>*
> Sent by: [hidden email]
>
> 06/28/2007 12:20 AM
> Please respond to
> User support for the Protege-OWL editor      
>  <[hidden email]>
>
>
>
> To
> "'User support for the Protege-OWL editor'"
> <[hidden email]>
> cc
>
> Subject
> Re: [protege-owl] Query: what are the advantages of the        various
>        methods to query an ontology?
>
>
>
>
>
>
>
>
>  
> Rules and queries are executed in parallel because a query may return
> inference results. Take, for example, the following rule:
>  
> Person(?p) ^ has Age(?p, ?age) ^ swrlb:greaterThan(?age, 17) -> Adult(?p)
>  
> And the query:
>  
> Adult(?a) -> query:select(?a)
>  
> Clearly one would like the query to return adults that are inferred by
> the rule.
>  
> The current SWRLTab query implementation is certainly not a desperately
> efficient solution. My goal at the moment is to get the richest feature
> set possible and to worry about optimizations later. However, we have
> successfully used the query system on ontologies with 100k or so
> individuals. The SWRLTab also allows selective enabling and disabling of
> rules and queries, which provides a coarse level of optimization.
>  
> Martin
>  
>  
>
> ------------------------------------------------------------------------
>
> *From:* [hidden email]
> [mailto:[hidden email]] *On Behalf Of *James A
> Miller*
> Sent:* Wednesday, June 27, 2007 8:18 PM*
> To:* User support for the Protege-OWL editor*
> Cc:* User support for the Protege-OWL editor;
> [hidden email]*
> Subject:* Re: [protege-owl] Query: what are the advantages of the
> various methods to query an ontology?
>  
>
> Martin,
>
> I am trying to understand the timing of events.  I understand that SWRL
> would be used both for queries and rules.  Your example shows the rules
> and queries being executed at once (by bridge.infer()). Does the
> SWRL-based model allow the "rule SWRL" to be applied once for everyone,
> and then the "query SWRL" to be executed when the user requests it?  I
> am concerned about performance, when we have many rules that apply
> globally, but we don't want to rerun inferences at query time.
>
> Jim
>
>
> *"Martin O'Connor" <[hidden email]>*
> Sent by: [hidden email]
>
> 06/26/2007 04:43 PM
>
>
> Please respond to
> User support for the Protege-OWL editor      
>  <[hidden email]>
>
>
>
> To
> User support for the Protege-OWL editor <[hidden email]>
> cc
>
> Subject
> Re: [protege-owl] Query: what are the advantages of the various      
>  methods to query an ontology?
>
>
>  
>
>
>  
>
>
>
>
>
>
>
> An equivalent Protege-OWL example would somewhat simpler because SWRL
> rules and queries are integrated [1]:
>
> OWLModel owlModel = ... // Create model using normal Protege-OWL mechanisms
> SWRLRuleEngineBridge bridge = BridgeFactory.createBridge(owlModel); //
> Create rule engine
> bridge.infer(); // Run the rules and queries
> Result result = bridge.getQueryResult("Query-1"); // Query model
>
> For example, if "Query-1" is:
>
> Person(?p) ^ hasName(?p, ?name) ^ hasSalary(?p, ?salary) ->
> query:select(?name, ?salary)
>
> the query result can be processed as follows:
>
> while (result.hasNext()) {
> DatatypeValue nameValue = result.getDatatypeValue("?name");
> DatatypeValue salaryValue = result.getDatatypeValue("?salary");
> System.out.println("Name: " + nameValue.getString());
> System.out.println("Salary: " + salaryValue.getInt());
> result.next();
> } // while
>
> The query can return both information that already existed in the model
> prior to inference and information that was inferred by SWRL rules.
>
> Martin
>
> [1] http://protege.cim3.net/cgi-bin/wiki.pl?SWRLQueryAPI
>
> Michael Fellmann wrote:
>
>>Hi William,
>>
>>perhaps a mixture of all the different querying methods depending on
> the use
>>case is appropriate. For my purposes, i used Jena's ability to create
> nested
>>inference models. First, I created an OWL-inference model and then I
>>attached this model to Jenas rule reasoner. At the end, I used SPARQL to
>>query the ontology.
>>This approach gives me the ability to use SPARQL to retrieve triples that
>>have been inserted by the reasoners prior to the query execution.
>>
>>Below is an excerpt of the code I used with the Jena-API.
>>
>>// configure a rule reasoner
>>Model m = ModelFactory.createDefaultModel();
>>Resource config =  m.createResource();
>>config.addProperty(ReasonerVocabulary.PROPruleMode, "hybrid");
>>config.addProperty(ReasonerVocabulary.PROPruleSet,  
>>                 "C:\\webapps-dev\\test\\src\\test\\demo.rules");
>>Reasoner reasoner =
> GenericRuleReasonerFactory.theInstance().create(config);
>>
>>// load data into an inference model
>>OntModelSpec s = new OntModelSpec(OntModelSpec.OWL_MEM_RULE_INF);
>>OntDocumentManager mgr = new OntDocumentManager();
>>mgr.setProcessImports(true);
>>mgr.setCacheModels(false);
>>s.setDocumentManager(mgr);
>>Model data = ModelFactory.createOntologyModel(s);
>>data.read("http://example.org/test.owl");
>>                
>>// apply the rule-reasoner on top of the inference model
>>InfModel infmodel = ModelFactory.createInfModel(reasoner, data);
>>
>>// query this model using SPARQL
>>...
>>                                                  
>>
>>Michael.
>>
>>
>>
>>
>>
>>
>>  
>>
>>>Message: 1
>>>Date: Tue, 26 Jun 2007 16:06:59 +0100
>>>From: william fitzgerald <[hidden email]>
>>>Subject: [protege-owl] Query: what are the advantages of the various
>>>                 methods to query an ontology?
>>>To: User support for the Protege-OWL editor
>>>                 <[hidden email]>
>>>Message-ID: <[hidden email]>
>>>Content-Type: text/plain; charset=ISO-8859-1
>>>
> Dear Semantic Experts:
>
> I have a question in relation to querying ontologies using Protege,
> Jena, Pellet and ARQ API's. I hope it can provoke some interesting
> conversation.
>
> Am I correct in saying there are 3 ways in which an ontology can be
> queried?
>
> 1) OWL-API or Jena API: It provides a way to get a class for example and
> list its subclasses, restrictions, individuals and so forth. Hence, in
> one sense, one could write and application that queries the ontologies
> in this way. For example. a swing GUI could pass in a string to name a
> class in return to have its super and subclasses listed etc etc.
>
>
> 2) Pellet (or FACT for Example): it provides "Logical Query
> Capabilities" in the sense that "Equivalent" or "Complete" Classes can
> be classified into an existing asserted model. One can view a "complete
> class" as a "logical query" placed on the ontology which states
> something along the lines of "find me all my subclasses based on my
> constraints...". Note: I have used Protege 3.3 in this way when building
> an OWL-DL ontology.
>
> 3) SPARQL: via Protege's plugin or Jena's ARQ, one can pass SQL like
> queries over an OWL ontology (OWL-DL) and have a result passed back
> based on pattern matching.
>
> 4) I suppose a 4th is using SWRL rules!
>
> Note:
> A example Query:
> SELECT ?subject WHERE { ?subject rdfs:subClassOf <#Vegetable> }";
> Example Class Structure:
> Vegetable --> Apple --> Magic Apple
>
> I find that in Protege that when this example is run for instance that I
> am only returned Apple (regardless of the ontology be already
> "classified").
>
> However, in Jena ,I notice that I am returned also the subclass of
> Apple. Hence I am returned the result of "Apple" and "Magic Apple". Also
> Jena seems to return the Vegetable class itself and the Nothing Class.
>
> Interesting results!!!
>
> Anyhow to play devils advocate:
>
> Why would I use SPARQL to query an ontology rather than developing an
> application that directly uses the OWL-API (or even the Jena API)?
>
> Why shouldn't one just focus on Logic Querying when working solely on
> OWL-DL models as opposed to the other two methods?
>
> I suppose ultimately what I am asking is: what advantages/disadvantages
> have one over the other and why should one care about it?
>
> I am keen to fully understand the semantic web arena and I believe
> answering such questions should help me ( and I presume other beginners
> too) in developing and packaging various API's, tools etc to do
> something useful with an ontology (OWL-DL models in my case, reasoning
> is vital in my case).
>
> Its one thing to develop an ontology with an IDE like Protege, but its
> quite another trying to maximize usage of that model in real world end
> user applications using Jena or Protege api for example to extract the
> usefulness of the ontology. (I am guessing Protege uses both OWL-API and
> Jena API when programmers use it to develop applications).
>
>
> Looking forward to some comments.
> regards,
> Will.
>
>

>>
>>
>>
>>
>>
>>_______________________________________________
>>protege-owl mailing list
>>[hidden email]
>>https://mailman.stanford.edu/mailman/listinfo/protege-owl
>>
>>Instructions for unsubscribing:
> http://protege.stanford.edu/doc/faq.html#01a.03
>>
>>  
>>

> _______________________________________________
> protege-owl mailing list
> [hidden email]
> https://mailman.stanford.edu/mailman/listinfo/protege-owl

> Instructions for unsubscribing:
> http://protege.stanford.edu/doc/faq.html#01a.03
> _______________________________________________
> protege-owl mailing list
> [hidden email]
> https://mailman.stanford.edu/mailman/listinfo/protege-owl

> Instructions for unsubscribing:
> http://protege.stanford.edu/doc/faq.html#01a.03


> ------------------------------------------------------------------------

> _______________________________________________
> protege-owl mailing list
> [hidden email]
> https://mailman.stanford.edu/mailman/listinfo/protege-owl

> Instructions for unsubscribing: http://protege.stanford.edu/doc/faq.html#01a.03 

- --
William M. Fitzgerald,
PhD Student,
Telecommunications Software & Systems Group,
ArcLabs Research and Innovation Centre,
Waterford Institute of Technology,
WIT West Campus,
Carriganore,
Waterford.
Office Ph: +353 51 302937
Mobile Ph: +353 87 9527083
Web: www.williamfitzgerald.org



-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFGg9qoIcwlebz1MmwRAhj4AJwJGtIY0mFhteODTSq2DUIHdZZ2cwCgld7s
IC3QDT2F6b4+QnT73J2sdhQ=
=mt91
-----END PGP SIGNATURE-----
_______________________________________________
protege-owl mailing list
[hidden email]
https://mailman.stanford.edu/mailman/listinfo/protege-owl

Instructions for unsubscribing: http://protege.stanford.edu/doc/faq.html#01a.03 
Reply | Threaded
Open this post in threaded view
|

Re: Query: what are the advantages of the various methods to query an ontology?

JMiller

I apologize; I thought that understanding how SWRL works would help demonstrate the advantages and disadvantages of its use, and to help decide whether to choose it over another.

Jim




william fitzgerald <[hidden email]>
Sent by: [hidden email]

06/28/2007 10:58 AM

Please respond to
[hidden email]; Please respond to
User support for the Protege-OWL editor        <[hidden email]>

To
User support for the Protege-OWL editor <[hidden email]>
cc
[hidden email]
Subject
Re: [protege-owl] Query: what are the advantages of the        various        methods to query an ontology?





-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi All,

I wonder should the specific SWRL related stuff be directed to a new
thread and keep this thread focused on various methods of querying an
ontology and why one should be chosen over an other.

Cheers,
Will.


James A Miller wrote:
>
> Is it possible, using SWRL, to save the Adult(?p) from your example into
> a knowledge base, or does it need to be recomputed for each query?
>
> Jim
>
>
>
> *"Martin O'Connor" <[hidden email]>*
> Sent by: [hidden email]
>
> 06/28/2007 12:20 AM
> Please respond to
> User support for the Protege-OWL editor      
>  <[hidden email]>
>
>
>                  
> To
>                  "'User support for the Protege-OWL editor'"
> <[hidden email]>
> cc
>                  
> Subject
>                  Re: [protege-owl] Query: what are the advantages of the        various
>        methods to query an ontology?
>
>
>                  
>
>
>
>
>
>  
> Rules and queries are executed in parallel because a query may return
> inference results. Take, for example, the following rule:
>  
> Person(?p) ^ has Age(?p, ?age) ^ swrlb:greaterThan(?age, 17) -> Adult(?p)
>  
> And the query:
>  
> Adult(?a) -> query:select(?a)
>  
> Clearly one would like the query to return adults that are inferred by
> the rule.
>  
> The current SWRLTab query implementation is certainly not a desperately
> efficient solution. My goal at the moment is to get the richest feature
> set possible and to worry about optimizations later. However, we have
> successfully used the query system on ontologies with 100k or so
> individuals. The SWRLTab also allows selective enabling and disabling of
> rules and queries, which provides a coarse level of optimization.
>  
> Martin
>  
>  
>
> ------------------------------------------------------------------------
>
> *From:* [hidden email]
> [mailto:[hidden email]] *On Behalf Of *James A
> Miller*
> Sent:* Wednesday, June 27, 2007 8:18 PM*
> To:* User support for the Protege-OWL editor*
> Cc:* User support for the Protege-OWL editor;
> [hidden email]*
> Subject:* Re: [protege-owl] Query: what are the advantages of the
> various methods to query an ontology?
>  
>
> Martin,
>
> I am trying to understand the timing of events.  I understand that SWRL
> would be used both for queries and rules.  Your example shows the rules
> and queries being executed at once (by bridge.infer()). Does the
> SWRL-based model allow the "rule SWRL" to be applied once for everyone,
> and then the "query SWRL" to be executed when the user requests it?  I
> am concerned about performance, when we have many rules that apply
> globally, but we don't want to rerun inferences at query time.
>
> Jim
>
>
> *"Martin O'Connor" <[hidden email]>*
> Sent by: [hidden email]
>
> 06/26/2007 04:43 PM
>
>
> Please respond to
> User support for the Protege-OWL editor      
>  <[hidden email]>
>
>
>                  
> To
>                  User support for the Protege-OWL editor <[hidden email]>
> cc
>                  
> Subject
>                  Re: [protege-owl] Query: what are the advantages of the various      
>  methods to query an ontology?
>
>
>  
>
>
>                    
>
>
>
>
>
>
>
> An equivalent Protege-OWL example would somewhat simpler because SWRL
> rules and queries are integrated [1]:
>
> OWLModel owlModel = ... // Create model using normal Protege-OWL mechanisms
> SWRLRuleEngineBridge bridge = BridgeFactory.createBridge(owlModel); //
> Create rule engine
> bridge.infer(); // Run the rules and queries
> Result result = bridge.getQueryResult("Query-1"); // Query model
>
> For example, if "Query-1" is:
>
> Person(?p) ^ hasName(?p, ?name) ^ hasSalary(?p, ?salary) ->
> query:select(?name, ?salary)
>
> the query result can be processed as follows:
>
> while (result.hasNext()) {
> DatatypeValue nameValue = result.getDatatypeValue("?name");
> DatatypeValue salaryValue = result.getDatatypeValue("?salary");
> System.out.println("Name: " + nameValue.getString());
> System.out.println("Salary: " + salaryValue.getInt());
> result.next();
> } // while
>
> The query can return both information that already existed in the model
> prior to inference and information that was inferred by SWRL rules.
>
> Martin
>
> [1] http://protege.cim3.net/cgi-bin/wiki.pl?SWRLQueryAPI
>
> Michael Fellmann wrote:
>
>>Hi William,
>>
>>perhaps a mixture of all the different querying methods depending on
> the use
>>case is appropriate. For my purposes, i used Jena's ability to create
> nested
>>inference models. First, I created an OWL-inference model and then I
>>attached this model to Jenas rule reasoner. At the end, I used SPARQL to
>>query the ontology.
>>This approach gives me the ability to use SPARQL to retrieve triples that
>>have been inserted by the reasoners prior to the query execution.
>>
>>Below is an excerpt of the code I used with the Jena-API.
>>
>>// configure a rule reasoner
>>Model m = ModelFactory.createDefaultModel();
>>Resource config =  m.createResource();
>>config.addProperty(ReasonerVocabulary.PROPruleMode, "hybrid");
>>config.addProperty(ReasonerVocabulary.PROPruleSet,  
>>                 "C:\\webapps-dev\\test\\src\\test\\demo.rules");
>>Reasoner reasoner =
> GenericRuleReasonerFactory.theInstance().create(config);
>>
>>// load data into an inference model
>>OntModelSpec s = new OntModelSpec(OntModelSpec.OWL_MEM_RULE_INF);
>>OntDocumentManager mgr = new OntDocumentManager();
>>mgr.setProcessImports(true);
>>mgr.setCacheModels(false);
>>s.setDocumentManager(mgr);
>>Model data = ModelFactory.createOntologyModel(s);
>>data.read("http://example.org/test.owl");
>>                
>>// apply the rule-reasoner on top of the inference model
>>InfModel infmodel = ModelFactory.createInfModel(reasoner, data);
>>
>>// query this model using SPARQL
>>...
>>                                                  
>>
>>Michael.
>>
>>
>>
>>
>>
>>
>>  
>>
>>>Message: 1
>>>Date: Tue, 26 Jun 2007 16:06:59 +0100
>>>From: william fitzgerald <[hidden email]>
>>>Subject: [protege-owl] Query: what are the advantages of the various
>>>                 methods to query an ontology?
>>>To: User support for the Protege-OWL editor
>>>                 <[hidden email]>
>>>Message-ID: <[hidden email]>
>>>Content-Type: text/plain; charset=ISO-8859-1
>>>
> Dear Semantic Experts:
>
> I have a question in relation to querying ontologies using Protege,
> Jena, Pellet and ARQ API's. I hope it can provoke some interesting
> conversation.
>
> Am I correct in saying there are 3 ways in which an ontology can be
> queried?
>
> 1) OWL-API or Jena API: It provides a way to get a class for example and
> list its subclasses, restrictions, individuals and so forth. Hence, in
> one sense, one could write and application that queries the ontologies
> in this way. For example. a swing GUI could pass in a string to name a
> class in return to have its super and subclasses listed etc etc.
>
>
> 2) Pellet (or FACT for Example): it provides "Logical Query
> Capabilities" in the sense that "Equivalent" or "Complete" Classes can
> be classified into an existing asserted model. One can view a "complete
> class" as a "logical query" placed on the ontology which states
> something along the lines of "find me all my subclasses based on my
> constraints...". Note: I have used Protege 3.3 in this way when building
> an OWL-DL ontology.
>
> 3) SPARQL: via Protege's plugin or Jena's ARQ, one can pass SQL like
> queries over an OWL ontology (OWL-DL) and have a result passed back
> based on pattern matching.
>
> 4) I suppose a 4th is using SWRL rules!
>
> Note:
> A example Query:
> SELECT ?subject WHERE { ?subject rdfs:subClassOf <#Vegetable> }";
> Example Class Structure:
> Vegetable --> Apple --> Magic Apple
>
> I find that in Protege that when this example is run for instance that I
> am only returned Apple (regardless of the ontology be already
> "classified").
>
> However, in Jena ,I notice that I am returned also the subclass of
> Apple. Hence I am returned the result of "Apple" and "Magic Apple". Also
> Jena seems to return the Vegetable class itself and the Nothing Class.
>
> Interesting results!!!
>
> Anyhow to play devils advocate:
>
> Why would I use SPARQL to query an ontology rather than developing an
> application that directly uses the OWL-API (or even the Jena API)?
>
> Why shouldn't one just focus on Logic Querying when working solely on
> OWL-DL models as opposed to the other two methods?
>
> I suppose ultimately what I am asking is: what advantages/disadvantages
> have one over the other and why should one care about it?
>
> I am keen to fully understand the semantic web arena and I believe
> answering such questions should help me ( and I presume other beginners
> too) in developing and packaging various API's, tools etc to do
> something useful with an ontology (OWL-DL models in my case, reasoning
> is vital in my case).
>
> Its one thing to develop an ontology with an IDE like Protege, but its
> quite another trying to maximize usage of that model in real world end
> user applications using Jena or Protege api for example to extract the
> usefulness of the ontology. (I am guessing Protege uses both OWL-API and
> Jena API when programmers use it to develop applications).
>
>
> Looking forward to some comments.
> regards,
> Will.
>
>

>>
>>
>>
>>
>>
>>_______________________________________________
>>protege-owl mailing list
>>[hidden email]
>>https://mailman.stanford.edu/mailman/listinfo/protege-owl
>>
>>Instructions for unsubscribing:
> http://protege.stanford.edu/doc/faq.html#01a.03
>>
>>  
>>

> _______________________________________________
> protege-owl mailing list
> [hidden email]
> https://mailman.stanford.edu/mailman/listinfo/protege-owl

> Instructions for unsubscribing:
> http://protege.stanford.edu/doc/faq.html#01a.03
> _______________________________________________
> protege-owl mailing list
> [hidden email]
> https://mailman.stanford.edu/mailman/listinfo/protege-owl

> Instructions for unsubscribing:
> http://protege.stanford.edu/doc/faq.html#01a.03


> ------------------------------------------------------------------------

> _______________________________________________
> protege-owl mailing list
> [hidden email]
> https://mailman.stanford.edu/mailman/listinfo/protege-owl

> Instructions for unsubscribing: http://protege.stanford.edu/doc/faq.html#01a.03

- --
William M. Fitzgerald,
PhD Student,
Telecommunications Software & Systems Group,
ArcLabs Research and Innovation Centre,
Waterford Institute of Technology,
WIT West Campus,
Carriganore,
Waterford.
Office Ph: +353 51 302937
Mobile Ph: +353 87 9527083
Web: www.williamfitzgerald.org



-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFGg9qoIcwlebz1MmwRAhj4AJwJGtIY0mFhteODTSq2DUIHdZZ2cwCgld7s
IC3QDT2F6b4+QnT73J2sdhQ=
=mt91
-----END PGP SIGNATURE-----
_______________________________________________
protege-owl mailing list
[hidden email]
https://mailman.stanford.edu/mailman/listinfo/protege-owl

Instructions for unsubscribing: http://protege.stanford.edu/doc/faq.html#01a.03


_______________________________________________
protege-owl mailing list
[hidden email]
https://mailman.stanford.edu/mailman/listinfo/protege-owl

Instructions for unsubscribing: http://protege.stanford.edu/doc/faq.html#01a.03 
Reply | Threaded
Open this post in threaded view
|

Re: Query: what are the advantages of the various methods to query an ontology?

Martin O'Connor

Actually, the interaction between inference and querying very important
to ontology knowledge extraction. The question of whether a query should
return only ground facts or ground facts with inferred knowledge is
pretty crucial. SPARQL is typically decoupled from OWL reasoning
processes so there is usually a complete separation here; SWRL querying
and inference operate in parallel; other approaches have varying degrees
of coupling.

To answer the original question, any SWRL inferences can be saved using
the normal Protege-OWL file saving mechanism.

Martin

James A Miller wrote:

>
> I apologize; I thought that understanding how SWRL works would help
> demonstrate the advantages and disadvantages of its use, and to help
> decide whether to choose it over another.
>
> Jim
>
>
>
>
> *william fitzgerald <[hidden email]>*
> Sent by: [hidden email]
>
> 06/28/2007 10:58 AM
> Please respond to
> [hidden email]; Please respond to
> User support for the Protege-OWL editor      
>  <[hidden email]>
>
>
>
> To
> User support for the Protege-OWL editor
> <[hidden email]>
> cc
> [hidden email]
> Subject
> Re: [protege-owl] Query: what are the advantages of the      
>  various        methods to query an ontology?
>
>
>
>
>
>
>
>
>
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> Hi All,
>
> I wonder should the specific SWRL related stuff be directed to a new
> thread and keep this thread focused on various methods of querying an
> ontology and why one should be chosen over an other.
>
> Cheers,
> Will.
>
>
> James A Miller wrote:
> >
> > Is it possible, using SWRL, to save the Adult(?p) from your example into
> > a knowledge base, or does it need to be recomputed for each query?
> >
> > Jim
> >
> >
> >
> > *"Martin O'Connor" <[hidden email]>*
> > Sent by: [hidden email]
> >
> > 06/28/2007 12:20 AM
> > Please respond to
> > User support for the Protege-OWL editor      
> >  <[hidden email]>
> >
> >
> >                  
> > To
> >                  "'User support for the Protege-OWL editor'"
> > <[hidden email]>
> > cc
> >                  
> > Subject
> >                  Re: [protege-owl] Query: what are the advantages of
> the        various
> >        methods to query an ontology?
> >
> >
> >                  
> >
> >
> >
> >
> >
> >  
> > Rules and queries are executed in parallel because a query may return
> > inference results. Take, for example, the following rule:
> >  
> > Person(?p) ^ has Age(?p, ?age) ^ swrlb:greaterThan(?age, 17) ->
> Adult(?p)
> >  
> > And the query:
> >  
> > Adult(?a) -> query:select(?a)
> >  
> > Clearly one would like the query to return adults that are inferred by
> > the rule.
> >  
> > The current SWRLTab query implementation is certainly not a desperately
> > efficient solution. My goal at the moment is to get the richest feature
> > set possible and to worry about optimizations later. However, we have
> > successfully used the query system on ontologies with 100k or so
> > individuals. The SWRLTab also allows selective enabling and disabling of
> > rules and queries, which provides a coarse level of optimization.
> >  
> > Martin
> >  
> >  
> >
> > ------------------------------------------------------------------------
> >
> > *From:* [hidden email]
> > [mailto:[hidden email]] *On Behalf Of *James A
> > Miller*
> > Sent:* Wednesday, June 27, 2007 8:18 PM*
> > To:* User support for the Protege-OWL editor*
> > Cc:* User support for the Protege-OWL editor;
> > [hidden email]*
> > Subject:* Re: [protege-owl] Query: what are the advantages of the
> > various methods to query an ontology?
> >  
> >
> > Martin,
> >
> > I am trying to understand the timing of events.  I understand that SWRL
> > would be used both for queries and rules.  Your example shows the rules
> > and queries being executed at once (by bridge.infer()). Does the
> > SWRL-based model allow the "rule SWRL" to be applied once for everyone,
> > and then the "query SWRL" to be executed when the user requests it?  I
> > am concerned about performance, when we have many rules that apply
> > globally, but we don't want to rerun inferences at query time.
> >
> > Jim
> >
> >
> > *"Martin O'Connor" <[hidden email]>*
> > Sent by: [hidden email]
> >
> > 06/26/2007 04:43 PM
> >
> >
> > Please respond to
> > User support for the Protege-OWL editor      
> >  <[hidden email]>
> >
> >
> >                  
> > To
> >                  User support for the Protege-OWL editor
> <[hidden email]>
> > cc
> >                  
> > Subject
> >                  Re: [protege-owl] Query: what are the advantages of
> the various      
> >  methods to query an ontology?
> >
> >
> >  
> >
> >
> >                    
> >
> >
> >
> >
> >
> >
> >
> > An equivalent Protege-OWL example would somewhat simpler because SWRL
> > rules and queries are integrated [1]:
> >
> > OWLModel owlModel = ... // Create model using normal Protege-OWL
> mechanisms
> > SWRLRuleEngineBridge bridge = BridgeFactory.createBridge(owlModel); //
> > Create rule engine
> > bridge.infer(); // Run the rules and queries
> > Result result = bridge.getQueryResult("Query-1"); // Query model
> >
> > For example, if "Query-1" is:
> >
> > Person(?p) ^ hasName(?p, ?name) ^ hasSalary(?p, ?salary) ->
> > query:select(?name, ?salary)
> >
> > the query result can be processed as follows:
> >
> > while (result.hasNext()) {
> > DatatypeValue nameValue = result.getDatatypeValue("?name");
> > DatatypeValue salaryValue = result.getDatatypeValue("?salary");
> > System.out.println("Name: " + nameValue.getString());
> > System.out.println("Salary: " + salaryValue.getInt());
> > result.next();
> > } // while
> >
> > The query can return both information that already existed in the model
> > prior to inference and information that was inferred by SWRL rules.
> >
> > Martin
> >
> > [1] http://protege.cim3.net/cgi-bin/wiki.pl?SWRLQueryAPI
> >
> > Michael Fellmann wrote:
> >
> >>Hi William,
> >>
> >>perhaps a mixture of all the different querying methods depending on
> > the use
> >>case is appropriate. For my purposes, i used Jena's ability to create
> > nested
> >>inference models. First, I created an OWL-inference model and then I
> >>attached this model to Jenas rule reasoner. At the end, I used SPARQL to
> >>query the ontology.
> >>This approach gives me the ability to use SPARQL to retrieve triples
> that
> >>have been inserted by the reasoners prior to the query execution.
> >>
> >>Below is an excerpt of the code I used with the Jena-API.
> >>
> >>// configure a rule reasoner
> >>Model m = ModelFactory.createDefaultModel();
> >>Resource config =  m.createResource();
> >>config.addProperty(ReasonerVocabulary.PROPruleMode, "hybrid");
> >>config.addProperty(ReasonerVocabulary.PROPruleSet,  
> >>                 "C:\\webapps-dev\\test\\src\\test\\demo.rules");
> >>Reasoner reasoner =
> > GenericRuleReasonerFactory.theInstance().create(config);
> >>
> >>// load data into an inference model
> >>OntModelSpec s = new OntModelSpec(OntModelSpec.OWL_MEM_RULE_INF);
> >>OntDocumentManager mgr = new OntDocumentManager();
> >>mgr.setProcessImports(true);
> >>mgr.setCacheModels(false);
> >>s.setDocumentManager(mgr);
> >>Model data = ModelFactory.createOntologyModel(s);
> >>data.read("http://example.org/test.owl");
> >>                
> >>// apply the rule-reasoner on top of the inference model
> >>InfModel infmodel = ModelFactory.createInfModel(reasoner, data);
> >>
> >>// query this model using SPARQL
> >>...
> >>                                                  
> >>
> >>Michael.
> >>
> >>
> >>
> >>
> >>
> >>
> >>  
> >>
> >>>Message: 1
> >>>Date: Tue, 26 Jun 2007 16:06:59 +0100
> >>>From: william fitzgerald <[hidden email]>
> >>>Subject: [protege-owl] Query: what are the advantages of the various
> >>>                 methods to query an ontology?
> >>>To: User support for the Protege-OWL editor
> >>>                 <[hidden email]>
> >>>Message-ID: <[hidden email]>
> >>>Content-Type: text/plain; charset=ISO-8859-1
> >>>
> > Dear Semantic Experts:
> >
> > I have a question in relation to querying ontologies using Protege,
> > Jena, Pellet and ARQ API's. I hope it can provoke some interesting
> > conversation.
> >
> > Am I correct in saying there are 3 ways in which an ontology can be
> > queried?
> >
> > 1) OWL-API or Jena API: It provides a way to get a class for example and
> > list its subclasses, restrictions, individuals and so forth. Hence, in
> > one sense, one could write and application that queries the ontologies
> > in this way. For example. a swing GUI could pass in a string to name a
> > class in return to have its super and subclasses listed etc etc.
> >
> >
> > 2) Pellet (or FACT for Example): it provides "Logical Query
> > Capabilities" in the sense that "Equivalent" or "Complete" Classes can
> > be classified into an existing asserted model. One can view a "complete
> > class" as a "logical query" placed on the ontology which states
> > something along the lines of "find me all my subclasses based on my
> > constraints...". Note: I have used Protege 3.3 in this way when building
> > an OWL-DL ontology.
> >
> > 3) SPARQL: via Protege's plugin or Jena's ARQ, one can pass SQL like
> > queries over an OWL ontology (OWL-DL) and have a result passed back
> > based on pattern matching.
> >
> > 4) I suppose a 4th is using SWRL rules!
> >
> > Note:
> > A example Query:
> > SELECT ?subject WHERE { ?subject rdfs:subClassOf <#Vegetable> }";
> > Example Class Structure:
> > Vegetable --> Apple --> Magic Apple
> >
> > I find that in Protege that when this example is run for instance that I
> > am only returned Apple (regardless of the ontology be already
> > "classified").
> >
> > However, in Jena ,I notice that I am returned also the subclass of
> > Apple. Hence I am returned the result of "Apple" and "Magic Apple". Also
> > Jena seems to return the Vegetable class itself and the Nothing Class.
> >
> > Interesting results!!!
> >
> > Anyhow to play devils advocate:
> >
> > Why would I use SPARQL to query an ontology rather than developing an
> > application that directly uses the OWL-API (or even the Jena API)?
> >
> > Why shouldn't one just focus on Logic Querying when working solely on
> > OWL-DL models as opposed to the other two methods?
> >
> > I suppose ultimately what I am asking is: what advantages/disadvantages
> > have one over the other and why should one care about it?
> >
> > I am keen to fully understand the semantic web arena and I believe
> > answering such questions should help me ( and I presume other beginners
> > too) in developing and packaging various API's, tools etc to do
> > something useful with an ontology (OWL-DL models in my case, reasoning
> > is vital in my case).
> >
> > Its one thing to develop an ontology with an IDE like Protege, but its
> > quite another trying to maximize usage of that model in real world end
> > user applications using Jena or Protege api for example to extract the
> > usefulness of the ontology. (I am guessing Protege uses both OWL-API and
> > Jena API when programmers use it to develop applications).
> >
> >
> > Looking forward to some comments.
> > regards,
> > Will.
> >
> >
>
> >>
> >>
> >>
> >>
> >>
> >>_______________________________________________
> >>protege-owl mailing list
> >>[hidden email]
> >>https://mailman.stanford.edu/mailman/listinfo/protege-owl
> >>
> >>Instructions for unsubscribing:
> > http://protege.stanford.edu/doc/faq.html#01a.03
> >>
> >>  
> >>
>
> > _______________________________________________
> > protege-owl mailing list
> > [hidden email]
> > https://mailman.stanford.edu/mailman/listinfo/protege-owl
>
> > Instructions for unsubscribing:
> > http://protege.stanford.edu/doc/faq.html#01a.03
> > _______________________________________________
> > protege-owl mailing list
> > [hidden email]
> > https://mailman.stanford.edu/mailman/listinfo/protege-owl
>
> > Instructions for unsubscribing:
> > http://protege.stanford.edu/doc/faq.html#01a.03
>
>
> > ------------------------------------------------------------------------
>
> > _______________________________________________
> > protege-owl mailing list
> > [hidden email]
> > https://mailman.stanford.edu/mailman/listinfo/protege-owl
>
> > Instructions for unsubscribing:
> http://protege.stanford.edu/doc/faq.html#01a.03
>
> - --
> William M. Fitzgerald,
> PhD Student,
> Telecommunications Software & Systems Group,
> ArcLabs Research and Innovation Centre,
> Waterford Institute of Technology,
> WIT West Campus,
> Carriganore,
> Waterford.
> Office Ph: +353 51 302937
> Mobile Ph: +353 87 9527083
> Web: www.williamfitzgerald.org
>
>
>
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.6 (GNU/Linux)
> Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
>
> iD8DBQFGg9qoIcwlebz1MmwRAhj4AJwJGtIY0mFhteODTSq2DUIHdZZ2cwCgld7s
> IC3QDT2F6b4+QnT73J2sdhQ=
> =mt91
> -----END PGP SIGNATURE-----
> _______________________________________________
> protege-owl mailing list
> [hidden email]
> https://mailman.stanford.edu/mailman/listinfo/protege-owl
>
> Instructions for unsubscribing:
> http://protege.stanford.edu/doc/faq.html#01a.03
>
>------------------------------------------------------------------------
>
>_______________________________________________
>protege-owl mailing list
>[hidden email]
>https://mailman.stanford.edu/mailman/listinfo/protege-owl
>
>Instructions for unsubscribing: http://protege.stanford.edu/doc/faq.html#01a.03 
>  
>

_______________________________________________
protege-owl mailing list
[hidden email]
https://mailman.stanford.edu/mailman/listinfo/protege-owl

Instructions for unsubscribing: http://protege.stanford.edu/doc/faq.html#01a.03 
Reply | Threaded
Open this post in threaded view
|

Re: Query: what are the advantages of the various methods to query an ontology?

William Fitzgerald-2
In reply to this post by JMiller
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

James you are right. I apologise. please carry on.

James A Miller wrote:

>
> I apologize; I thought that understanding how SWRL works would help
> demonstrate the advantages and disadvantages of its use, and to help
> decide whether to choose it over another.
>
> Jim
>
>
>
>
> *william fitzgerald <[hidden email]>*
> Sent by: [hidden email]
>
> 06/28/2007 10:58 AM
> Please respond to
> [hidden email]; Please respond to
> User support for the Protege-OWL editor      
>  <[hidden email]>
>
>
>
> To
> User support for the Protege-OWL editor <[hidden email]>
> cc
> [hidden email]
> Subject
> Re: [protege-owl] Query: what are the advantages of the        various
>        methods to query an ontology?
>
>
>
>
>
>
>
>
> Hi All,
>
> I wonder should the specific SWRL related stuff be directed to a new
> thread and keep this thread focused on various methods of querying an
> ontology and why one should be chosen over an other.
>
> Cheers,
> Will.
>
>
> James A Miller wrote:
>
>> Is it possible, using SWRL, to save the Adult(?p) from your example into
>> a knowledge base, or does it need to be recomputed for each query?
>
>> Jim
>
>
>
>> *"Martin O'Connor" <[hidden email]>*
>> Sent by: [hidden email]
>
>> 06/28/2007 12:20 AM
>> Please respond to
>> User support for the Protege-OWL editor      
>>  <[hidden email]>
>
>
>
>> To
>>                  "'User support for the Protege-OWL editor'"
>> <[hidden email]>
>> cc
>
>> Subject
>>                  Re: [protege-owl] Query: what are the advantages of
> the        various
>>        methods to query an ontology?
>
>
>
>
>
>
>
>
>
>> Rules and queries are executed in parallel because a query may return
>> inference results. Take, for example, the following rule:
>
>> Person(?p) ^ has Age(?p, ?age) ^ swrlb:greaterThan(?age, 17) -> Adult(?p)
>
>> And the query:
>
>> Adult(?a) -> query:select(?a)
>
>> Clearly one would like the query to return adults that are inferred by
>> the rule.
>
>> The current SWRLTab query implementation is certainly not a desperately
>> efficient solution. My goal at the moment is to get the richest feature
>> set possible and to worry about optimizations later. However, we have
>> successfully used the query system on ontologies with 100k or so
>> individuals. The SWRLTab also allows selective enabling and disabling of
>> rules and queries, which provides a coarse level of optimization.
>
>> Martin
>
>
>
>> ------------------------------------------------------------------------
>
>> *From:* [hidden email]
>> [mailto:[hidden email]] *On Behalf Of *James A
>> Miller*
>> Sent:* Wednesday, June 27, 2007 8:18 PM*
>> To:* User support for the Protege-OWL editor*
>> Cc:* User support for the Protege-OWL editor;
>> [hidden email]*
>> Subject:* Re: [protege-owl] Query: what are the advantages of the
>> various methods to query an ontology?
>
>
>> Martin,
>
>> I am trying to understand the timing of events.  I understand that SWRL
>> would be used both for queries and rules.  Your example shows the rules
>> and queries being executed at once (by bridge.infer()). Does the
>> SWRL-based model allow the "rule SWRL" to be applied once for everyone,
>> and then the "query SWRL" to be executed when the user requests it?  I
>> am concerned about performance, when we have many rules that apply
>> globally, but we don't want to rerun inferences at query time.
>
>> Jim
>
>
>> *"Martin O'Connor" <[hidden email]>*
>> Sent by: [hidden email]
>
>> 06/26/2007 04:43 PM
>
>
>> Please respond to
>> User support for the Protege-OWL editor      
>>  <[hidden email]>
>
>
>
>> To
>>                  User support for the Protege-OWL editor
> <[hidden email]>
>> cc
>
>> Subject
>>                  Re: [protege-owl] Query: what are the advantages of
> the various      
>>  methods to query an ontology?
>
>
>
>
>
>
>
>
>
>
>
>
>
>> An equivalent Protege-OWL example would somewhat simpler because SWRL
>> rules and queries are integrated [1]:
>
>> OWLModel owlModel = ... // Create model using normal Protege-OWL
> mechanisms
>> SWRLRuleEngineBridge bridge = BridgeFactory.createBridge(owlModel); //
>> Create rule engine
>> bridge.infer(); // Run the rules and queries
>> Result result = bridge.getQueryResult("Query-1"); // Query model
>
>> For example, if "Query-1" is:
>
>> Person(?p) ^ hasName(?p, ?name) ^ hasSalary(?p, ?salary) ->
>> query:select(?name, ?salary)
>
>> the query result can be processed as follows:
>
>> while (result.hasNext()) {
>> DatatypeValue nameValue = result.getDatatypeValue("?name");
>> DatatypeValue salaryValue = result.getDatatypeValue("?salary");
>> System.out.println("Name: " + nameValue.getString());
>> System.out.println("Salary: " + salaryValue.getInt());
>> result.next();
>> } // while
>
>> The query can return both information that already existed in the model
>> prior to inference and information that was inferred by SWRL rules.
>
>> Martin
>
>> [1] http://protege.cim3.net/cgi-bin/wiki.pl?SWRLQueryAPI
>
>> Michael Fellmann wrote:
>
>>>Hi William,
>>>
>>>perhaps a mixture of all the different querying methods depending on
>> the use
>>>case is appropriate. For my purposes, i used Jena's ability to create
>> nested
>>>inference models. First, I created an OWL-inference model and then I
>>>attached this model to Jenas rule reasoner. At the end, I used SPARQL to
>>>query the ontology.
>>>This approach gives me the ability to use SPARQL to retrieve triples that
>>>have been inserted by the reasoners prior to the query execution.
>>>
>>>Below is an excerpt of the code I used with the Jena-API.
>>>
>>>// configure a rule reasoner
>>>Model m = ModelFactory.createDefaultModel();
>>>Resource config =  m.createResource();
>>>config.addProperty(ReasonerVocabulary.PROPruleMode, "hybrid");
>>>config.addProperty(ReasonerVocabulary.PROPruleSet,  
>>>                 "C:\\webapps-dev\\test\\src\\test\\demo.rules");
>>>Reasoner reasoner =
>> GenericRuleReasonerFactory.theInstance().create(config);
>>>
>>>// load data into an inference model
>>>OntModelSpec s = new OntModelSpec(OntModelSpec.OWL_MEM_RULE_INF);
>>>OntDocumentManager mgr = new OntDocumentManager();
>>>mgr.setProcessImports(true);
>>>mgr.setCacheModels(false);
>>>s.setDocumentManager(mgr);
>>>Model data = ModelFactory.createOntologyModel(s);
>>>data.read("http://example.org/test.owl");
>>>                
>>>// apply the rule-reasoner on top of the inference model
>>>InfModel infmodel = ModelFactory.createInfModel(reasoner, data);
>>>
>>>// query this model using SPARQL
>>>...
>>>                                                  
>>>
>>>Michael.
>>>
>>>
>>>
>>>
>>>
>>>
>>>  
>>>
>>>>Message: 1
>>>>Date: Tue, 26 Jun 2007 16:06:59 +0100
>>>>From: william fitzgerald <[hidden email]>
>>>>Subject: [protege-owl] Query: what are the advantages of the various
>>>>                 methods to query an ontology?
>>>>To: User support for the Protege-OWL editor
>>>>                 <[hidden email]>
>>>>Message-ID: <[hidden email]>
>>>>Content-Type: text/plain; charset=ISO-8859-1
>>>>
>> Dear Semantic Experts:
>
>> I have a question in relation to querying ontologies using Protege,
>> Jena, Pellet and ARQ API's. I hope it can provoke some interesting
>> conversation.
>
>> Am I correct in saying there are 3 ways in which an ontology can be
>> queried?
>
>> 1) OWL-API or Jena API: It provides a way to get a class for example and
>> list its subclasses, restrictions, individuals and so forth. Hence, in
>> one sense, one could write and application that queries the ontologies
>> in this way. For example. a swing GUI could pass in a string to name a
>> class in return to have its super and subclasses listed etc etc.
>
>
>> 2) Pellet (or FACT for Example): it provides "Logical Query
>> Capabilities" in the sense that "Equivalent" or "Complete" Classes can
>> be classified into an existing asserted model. One can view a "complete
>> class" as a "logical query" placed on the ontology which states
>> something along the lines of "find me all my subclasses based on my
>> constraints...". Note: I have used Protege 3.3 in this way when building
>> an OWL-DL ontology.
>
>> 3) SPARQL: via Protege's plugin or Jena's ARQ, one can pass SQL like
>> queries over an OWL ontology (OWL-DL) and have a result passed back
>> based on pattern matching.
>
>> 4) I suppose a 4th is using SWRL rules!
>
>> Note:
>> A example Query:
>> SELECT ?subject WHERE { ?subject rdfs:subClassOf <#Vegetable> }";
>> Example Class Structure:
>> Vegetable --> Apple --> Magic Apple
>
>> I find that in Protege that when this example is run for instance that I
>> am only returned Apple (regardless of the ontology be already
>> "classified").
>
>> However, in Jena ,I notice that I am returned also the subclass of
>> Apple. Hence I am returned the result of "Apple" and "Magic Apple". Also
>> Jena seems to return the Vegetable class itself and the Nothing Class.
>
>> Interesting results!!!
>
>> Anyhow to play devils advocate:
>
>> Why would I use SPARQL to query an ontology rather than developing an
>> application that directly uses the OWL-API (or even the Jena API)?
>
>> Why shouldn't one just focus on Logic Querying when working solely on
>> OWL-DL models as opposed to the other two methods?
>
>> I suppose ultimately what I am asking is: what advantages/disadvantages
>> have one over the other and why should one care about it?
>
>> I am keen to fully understand the semantic web arena and I believe
>> answering such questions should help me ( and I presume other beginners
>> too) in developing and packaging various API's, tools etc to do
>> something useful with an ontology (OWL-DL models in my case, reasoning
>> is vital in my case).
>
>> Its one thing to develop an ontology with an IDE like Protege, but its
>> quite another trying to maximize usage of that model in real world end
>> user applications using Jena or Protege api for example to extract the
>> usefulness of the ontology. (I am guessing Protege uses both OWL-API and
>> Jena API when programmers use it to develop applications).
>
>
>> Looking forward to some comments.
>> regards,
>> Will.
>
>
>
>>>
>>>
>>>
>>>
>>>
>>>_______________________________________________
>>>protege-owl mailing list
>>>[hidden email]
>>>https://mailman.stanford.edu/mailman/listinfo/protege-owl
>>>
>>>Instructions for unsubscribing:
>> http://protege.stanford.edu/doc/faq.html#01a.03
>>>
>>>  
>>>
>
>> _______________________________________________
>> protege-owl mailing list
>> [hidden email]
>> https://mailman.stanford.edu/mailman/listinfo/protege-owl
>
>> Instructions for unsubscribing:
>> http://protege.stanford.edu/doc/faq.html#01a.03
>> _______________________________________________
>> protege-owl mailing list
>> [hidden email]
>> https://mailman.stanford.edu/mailman/listinfo/protege-owl
>
>> Instructions for unsubscribing:
>> http://protege.stanford.edu/doc/faq.html#01a.03
>
>
>> ------------------------------------------------------------------------
>
>> _______________________________________________
>> protege-owl mailing list
>> [hidden email]
>> https://mailman.stanford.edu/mailman/listinfo/protege-owl
>
>> Instructions for unsubscribing:
> http://protege.stanford.edu/doc/faq.html#01a.03
>
_______________________________________________
protege-owl mailing list
[hidden email]
https://mailman.stanford.edu/mailman/listinfo/protege-owl

Instructions for unsubscribing:
http://protege.stanford.edu/doc/faq.html#01a.03


- --
William M. Fitzgerald,
PhD Student,
Telecommunications Software & Systems Group,
ArcLabs Research and Innovation Centre,
Waterford Institute of Technology,
WIT West Campus,
Carriganore,
Waterford.
Office Ph: +353 51 302937
Mobile Ph: +353 87 9527083
Web: www.williamfitzgerald.org



-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFGhL13Icwlebz1MmwRAozIAJ9zsdhkAeS1YB6DnnlK2eHcJYI42gCfarPE
dq4Gxk5uYBQAGL0q8e0bESA=
=rQAc
-----END PGP SIGNATURE-----
_______________________________________________
protege-owl mailing list
[hidden email]
https://mailman.stanford.edu/mailman/listinfo/protege-owl

Instructions for unsubscribing: http://protege.stanford.edu/doc/faq.html#01a.03