pub struct ProbabilisticLogicNetwork { /* private fields */ }Expand description
Probabilistic Logic Network engine.
Maintains a hypergraph of atoms and links, executes PLN inference rules, and provides chain-search utilities.
Implementations§
Source§impl ProbabilisticLogicNetwork
impl ProbabilisticLogicNetwork
Sourcepub fn add_atom(&mut self, atom: PlnAtom) -> Result<(), PlnError>
pub fn add_atom(&mut self, atom: PlnAtom) -> Result<(), PlnError>
Add an atom to the network.
Returns Err(PlnError::MaxAtomsExceeded) when the atom limit is reached.
Silently replaces any existing atom with the same ID.
Sourcepub fn add_link(&mut self, link: PlnLink) -> Result<(), PlnError>
pub fn add_link(&mut self, link: PlnLink) -> Result<(), PlnError>
Add a link to the network.
The link is also registered as an atom so its TV can be queried via
get_tv. All source_ids must already exist as atoms or links.
Sourcepub fn get_tv(&self, id: &str) -> Result<TruthValue, PlnError>
pub fn get_tv(&self, id: &str) -> Result<TruthValue, PlnError>
Return the truth value of an atom or link by ID.
Sourcepub fn infer(
&mut self,
rule: PlnInferenceRule,
premise_ids: Vec<String>,
) -> Result<PlnInferenceResult, PlnError>
pub fn infer( &mut self, rule: PlnInferenceRule, premise_ids: Vec<String>, ) -> Result<PlnInferenceResult, PlnError>
Apply an inference rule to the given premises.
Validates that the premises exist and that the rule can be applied,
then returns a PlnInferenceResult describing the conclusion. The
caller decides whether to materialise the conclusion via
apply_inference.
Sourcepub fn apply_inference(
&mut self,
result: PlnInferenceResult,
) -> Result<(), PlnError>
pub fn apply_inference( &mut self, result: PlnInferenceResult, ) -> Result<(), PlnError>
Materialise an inference result.
- If the conclusion atom does not exist, it is created.
- If it exists and
enable_revisionistrue, its TV is revised. - If it exists and
enable_revisionisfalse, its TV is replaced.
Sourcepub fn find_chains(
&self,
from: &str,
to: &str,
max_depth: u8,
) -> Result<Vec<Vec<String>>, PlnError>
pub fn find_chains( &self, from: &str, to: &str, max_depth: u8, ) -> Result<Vec<Vec<String>>, PlnError>
Find all inference chains from from to to up to max_depth hops.
Returns a list of paths, where each path is a sequence of atom/link IDs
starting at from and ending at to.
Sourcepub fn most_confident(&self, n: usize) -> Vec<PlnAtom>
pub fn most_confident(&self, n: usize) -> Vec<PlnAtom>
Return the top n atoms sorted descending by confidence.
Sourcepub fn uncertain_atoms(&self, threshold: f64) -> Vec<PlnAtom>
pub fn uncertain_atoms(&self, threshold: f64) -> Vec<PlnAtom>
Return all atoms whose confidence is strictly below threshold.
Auto Trait Implementations§
impl Freeze for ProbabilisticLogicNetwork
impl RefUnwindSafe for ProbabilisticLogicNetwork
impl Send for ProbabilisticLogicNetwork
impl Sync for ProbabilisticLogicNetwork
impl Unpin for ProbabilisticLogicNetwork
impl UnsafeUnpin for ProbabilisticLogicNetwork
impl UnwindSafe for ProbabilisticLogicNetwork
Blanket Implementations§
impl<T> Allocation for T
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more