Skip to main content

ontologos_rl/
lib.rs

1//! OWL RL forward-chaining facade over [`reasonable`](https://crates.io/crates/reasonable).
2//!
3//! # Start here — load a file and saturate
4//!
5//! ```no_run
6//! use ontologos_parser::load_ontology;
7//! use ontologos_rl::RlEngine;
8//!
9//! # fn main() -> Result<(), Box<dyn std::error::Error>> {
10//! let mut ontology = load_ontology(std::path::Path::new("ontology.owl"))?;
11//! let report = RlEngine::new(1).saturate(&mut ontology)?;
12//! println!("inferred {}", report.inferred_total());
13//! # Ok(())
14//! # }
15//! ```
16
17mod engine;
18mod reasoner;
19mod report;
20
21pub use engine::RlEngine;
22pub use reasoner::{classify_reasoner, materialize_reasoner};
23pub use report::{InferenceRecord, MaterializationReport, RlRule};
24
25use ontologos_core::Error as CoreError;
26use thiserror::Error;
27
28pub type Result<T> = std::result::Result<T, Error>;
29
30#[derive(Debug, Error)]
31pub enum Error {
32    #[error("expected profile {expected:?}, got {actual:?}")]
33    WrongProfile {
34        expected: ontologos_core::Profile,
35        actual: ontologos_core::Profile,
36    },
37    #[error(transparent)]
38    Core(#[from] CoreError),
39    #[error(transparent)]
40    Bridge(#[from] ontologos_bridge::Error),
41    #[error(transparent)]
42    Reasonable(#[from] reasonable::error::ReasonableError),
43}
44
45#[cfg(test)]
46mod tests {
47    use super::*;
48
49    #[test]
50    fn try_new_rejects_invalid_parallelism() {
51        assert!(RlEngine::try_new(0).is_err());
52        assert!(RlEngine::try_new(65).is_err());
53        assert!(RlEngine::try_new(1).is_ok());
54    }
55}