phillord / tawny-owl

Build OWL Ontologies in a Programmatic Environment
GNU Lesser General Public License v3.0
251 stars 54 forks source link

Usage of query functions #33

Closed timur-han closed 9 years ago

timur-han commented 9 years ago

Hi again,

I'm trying to use the functions in the query namespace, however I'm not sure how to execute the queries and what the queries look like. For instance we have (frameo entity query frame), here I assume frame is like :fact and I'm not sure abuot query but it's should be a map? And entity can be anything like individual, class, etc. It checks recursively all elements, and when it finds the specfic frame it executes the query (?) and returns if all matching values. However, whenever I execute it what I get a function. I'm not sure how to use them really correctly.

phillord commented 9 years ago

Sorry the documentation for the query functionality is rather sucky (i.e. there isn't any). It certainly assumes knowledge of the clojure core.logic functions.

What happens is that tawny converts OWL into clojure data structures, which you can then map with core.logic.

So something like:

(l/run* [q](l/fresh [y] %28q/supero MYOWLCLASS y%29
%28l/== [:iri q] y%29))

Will return all superclass IRIs of MYOWLCLASS.

Query is still a bit experimental at the moment! It does need more work.

Phil

timur87 notifications@github.com writes:

I'm trying to use the functions in the query namespace, however I'm not sure how to execute the queries and what the queries look like. For instance we have (frameo entity query frame), here I assume frame is like :fact and I'm not sure abuot query but it's should be a map? And entity can be anything like individual, class, etc. It checks recursively all elements, and when it finds the specfic frame it executes the query (?) and returns if all matching values. However, whenever I execute it what I get a function. I'm not sure how to use them really correctly.


Reply to this email directly or view it on GitHub: https://github.com/phillord/tawny-owl/issues/33

Phillip Lord, Phone: +44 (0) 191 208 7827 Lecturer in Bioinformatics, Email: phillip.lord@newcastle.ac.uk School of Computing Science, http://homepages.cs.ncl.ac.uk/phillip.lord Room 914 Claremont Tower, skype: russet_apples Newcastle University, twitter: phillord NE1 7RU

timur-han commented 9 years ago

Thanks for the explanation and example.

The example did not work in my case. I may ask the question the other way around: What would be the right way of obtaining facts of an individual? Using the OWL API methods of the class OWLIndividual, Query functions, or some other functions that I'm not aware of.

On Wed, Feb 25, 2015 at 1:33 PM, Phil Lord notifications@github.com wrote:

Sorry the documentation for the query functionality is rather sucky (i.e. there isn't any). It certainly assumes knowledge of the clojure core.logic functions.

What happens is that tawny converts OWL into clojure data structures, which you can then map with core.logic.

So something like:

(l/run* [q](l/fresh [y] %28q/supero MYOWLCLASS y%29 %28l/== [:iri q] y%29))

Will return all superclass IRIs of MYOWLCLASS.

Query is still a bit experimental at the moment! It does need more work.

Phil

timur87 notifications@github.com writes:

I'm trying to use the functions in the query namespace, however I'm not sure how to execute the queries and what the queries look like. For instance we have (frameo entity query frame), here I assume frame is like :fact and I'm not sure abuot query but it's should be a map? And entity can be anything like individual, class, etc. It checks recursively all elements, and when it finds the specfic frame it executes the query (?) and returns if all matching values. However, whenever I execute it what I get a function. I'm not sure how to use them really correctly.


Reply to this email directly or view it on GitHub: https://github.com/phillord/tawny-owl/issues/33

Phillip Lord, Phone: +44 (0) 191 208 7827 Lecturer in Bioinformatics, Email: phillip.lord@newcastle.ac.uk School of Computing Science, http://homepages.cs.ncl.ac.uk/phillip.lord Room 914 Claremont Tower, skype: russet_apples Newcastle University, twitter: phillord NE1 7RU

— Reply to this email directly or view it on GitHub https://github.com/phillord/tawny-owl/issues/33#issuecomment-75952387.

phillord commented 9 years ago

You can use the core OWL API functions for sure. So using my owl-primer port as an example (at https://github.com/phillord/owl-primer) you can do...

 (.getNegativeDataPropertyValues Jack family)

Which returns negative data facts. Or you can do...

(clojure.core/get (into-map Jack) :fact)

which returns

((:fact-not hasAge (:literal "53" :type :XSD_INTEGER)))

I think my interface is rather simpler, but YMMV.