-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Provide equivalent to OWL Reasoner API #16
Comments
To my mind this is something that we should do at a rust level. Plugging in whelk-rs should be simple to do, although doing it in a performant way might be more challenging. I don't know enough about the APIs to other reasoners (other than via the OWL API interface) to know how easy a generic interface would be. My own inclination, following on from the general approach I have taken with horned would be to plug in whelk first and then worry about making a more general interface when and if it is needed. That has worked quite well. |
I created a first draft of an interface (b-gehrke/horned-owl @cmungall @phillord @balhoff What do you think of it? I would be happy if you could try it out and share your thoughts and opinions. With this design, reasoners only work with immutable ontologies, while the OWL API supports incremental reasoning. I'm not sure on how to realize this concept in Rust, but I came up with a few approaches:
What are your thoughts on this problem and the approaches? |
[like] Phillip Lord reacted to your message:
…________________________________
From: Björn ***@***.***>
Sent: Wednesday, March 20, 2024 1:42:00 PM
To: jannahastings/py-horned-owl ***@***.***>
Cc: Phil Lord ***@***.***>; Mention ***@***.***>
Subject: Re: [jannahastings/py-horned-owl] Provide equivalent to OWL Reasoner API (Issue #16)
⚠ External sender. Take care when opening links or attachments. Do not provide your login details.
I created a first draft of an interface (b-gehrke/horned-owl src/reasoner.rs<https://github.com/b-gehrke/horned-owl/blob/devel/src/reasoner.rs>), implemented it for whelk (b-gehrke/whelk-rs src/whelk/reasoner.rs<https://github.com/b-gehrke/whelk-rs/blob/master/src/whelk/reasoner.rs#L717>), and integrated it in py-horned-owl (branch reasoner src/reasoner.rs<https://github.com/jannahastings/py-horned-owl/blob/reasoner/src/reasoner.rs>). The file test/reasoner.py<https://github.com/jannahastings/py-horned-owl/blob/reasoner/test/reasoner.py> contains an example on how to use it from python.
@cmungall<https://github.com/cmungall> @phillord<https://github.com/phillord> @balhoff<https://github.com/balhoff> What do you think of it? I would be happy if you could try it out and share your thoughts and opinions.
With this design, reasoners only work with immutable ontologies, while the OWL API supports incremental reasoning. I'm not sure on how to realize this concept in Rust, but I came up with a few approaches:
* We could follow the OWL API design and have ontologies emit events when they change. Reasoners would then subscribe to these events and react accordingly. But events seem rather complicated in Rust and appear to be mostly replaced by other structures.
* We make reasoners own an ontology. Any updates to the ontology must be made through the reasoner (e.g. reasoner.insert_axiom(...)). With this we'd have a 1:1 mapping of reasoners to ontologies which might be not be ideal.
* We make ontologies own reasoners. A reasoner can be instantiated and can be added to an ontology (e.g. ontology.add_reasoner(r)). The ontology would then have to update its reasoners whenever they change.
What are your thoughts on this problem and the approaches?
—
Reply to this email directly, view it on GitHub<#16 (comment)>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/AAAWJ6VOYONQ4WNST2545Z3YZGG2RAVCNFSM6AAAAABAGRELQ6VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDAMBZGU4TKOBTGA>.
You are receiving this because you were mentioned.Message ID: ***@***.***>
|
This looks good and it is great to see a reasoner interface added to horned-owl.
In practice, I think, I would not use any of your options, but rather an amalgam of 1 and 3. My idea would be to simply plug reasoners into ontologies through the existing OntologyIndex system. This would, effectively, signal events to the reasoner; the reasoner instance would be fully owned by the ontology; and we already have all the mechanisms we need to get access to the putative `WhelkReasonerIndex` into and out from an ontology. `WhelkReasonerIndex` could implement both `OntologyIndex` and your `Reasoner`. The `Reasoner` trait could simply drop the `for_ontology` method. If it is possible, I would move `infered_axiom` to return an iterator.
We could add a convenience method or two that returns an object implementing Reasoner while owning any ontology; that could be easily implemented over this interface.
Thoughts? Also, would you want this to go into horned-owl directly, or into a sub-crate?
Phil
…________________________________
From: Björn ***@***.***>
Sent: 20 March 2024 13:42
To: jannahastings/py-horned-owl ***@***.***>
Cc: Phil Lord ***@***.***>; Mention ***@***.***>
Subject: Re: [jannahastings/py-horned-owl] Provide equivalent to OWL Reasoner API (Issue #16)
⚠ External sender. Take care when opening links or attachments. Do not provide your login details.
I created a first draft of an interface (b-gehrke/horned-owl src/reasoner.rs<https://github.com/b-gehrke/horned-owl/blob/devel/src/reasoner.rs>), implemented it for whelk (b-gehrke/whelk-rs src/whelk/reasoner.rs<https://github.com/b-gehrke/whelk-rs/blob/master/src/whelk/reasoner.rs#L717>), and integrated it in py-horned-owl (branch reasoner src/reasoner.rs<https://github.com/jannahastings/py-horned-owl/blob/reasoner/src/reasoner.rs>). The file test/reasoner.py<https://github.com/jannahastings/py-horned-owl/blob/reasoner/test/reasoner.py> contains an example on how to use it from python.
@cmungall<https://github.com/cmungall> @phillord<https://github.com/phillord> @balhoff<https://github.com/balhoff> What do you think of it? I would be happy if you could try it out and share your thoughts and opinions.
With this design, reasoners only work with immutable ontologies, while the OWL API supports incremental reasoning. I'm not sure on how to realize this concept in Rust, but I came up with a few approaches:
* We could follow the OWL API design and have ontologies emit events when they change. Reasoners would then subscribe to these events and react accordingly. But events seem rather complicated in Rust and appear to be mostly replaced by other structures.
* We make reasoners own an ontology. Any updates to the ontology must be made through the reasoner (e.g. reasoner.insert_axiom(...)). With this we'd have a 1:1 mapping of reasoners to ontologies which might be not be ideal.
* We make ontologies own reasoners. A reasoner can be instantiated and can be added to an ontology (e.g. ontology.add_reasoner(r)). The ontology would then have to update its reasoners whenever they change.
What are your thoughts on this problem and the approaches?
—
Reply to this email directly, view it on GitHub<#16 (comment)>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/AAAWJ6VOYONQ4WNST2545Z3YZGG2RAVCNFSM6AAAAABAGRELQ6VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDAMBZGU4TKOBTGA>.
You are receiving this because you were mentioned.Message ID: ***@***.***>
|
Thank you for your feedback. I've been looking in the What is the relation of How would we add additional (reasoner-) indexes to an ontology instance? Regarding your other points:
Thank you |
I've updated the horned-owl and whelk-rs forks to represent the changes and make Whelk an ontology index. But trying to use it, I run into problems. In py-horned-owl I would do something like type WhelkIndexedOntology = TwoIndexedOntology<
ArcStr,
Arc<AnnotatedComponent<ArcStr>>,
SetIndex<ArcStr, Arc<AnnotatedComponent<ArcStr>>>,
Whelk<ArcStr>>;
#[pyclass(unsendable)]
pub struct PyWhelk(WhelkIndexedOntology); and build expose all rust methods and additional convenience methods on this python-mapped |
The reason that we don't do this at the moment is that this would give an easy way to make the two indexes inconsistent; so it could be added, but with some appropriately scary documentation to say if you do change thing don't expect the other indexes to work. Another possibility would be to allow the |
Motivation: I would like to use the Rust version of @balhoff's Whelk, whelk.rs
Previously I was thinking the way to go would be to write a pyo3 wrapper onto whelk.rs. However, it may make more sense to have a generic wrapper for reasoners, with py-horned-owl providing the interface, just as there is one reasoner API for the OWLAPI
(it might be nice to have some features the owlapi ones lack though, that give access to some of the neater features of whelk)
The text was updated successfully, but these errors were encountered: