pub struct KnowledgeBase { /* private fields */ }Expand description
Default knowledge base implementation
Implementations§
Source§impl KnowledgeBase
impl KnowledgeBase
Sourcepub fn resolve_query(&mut self, query: &mut OutputQuery) -> Result<(), String>
pub fn resolve_query(&mut self, query: &mut OutputQuery) -> Result<(), String>
Sourcepub fn add_word(
&mut self,
input_word: &Word,
output_word: &Word,
) -> Result<(), String>
pub fn add_word( &mut self, input_word: &Word, output_word: &Word, ) -> Result<(), String>
Examples found in repository?
examples/memory_kb.rs (line 80)
75 fn resolve_query(&mut self, query: &mut OutputQuery) -> Result<(), String> {
76 match self.base.resolve_query(query) {
77 Ok(_) => Ok(()),
78 Err(_) => {
79 let output = self.submit_word_to_target(&query.input_word)?;
80 self.base.add_word(&query.input_word, &output)?;
81 query.set_result(output);
82 Ok(())
83 }
84 }
85 }
86
87 fn add_word(&mut self, input_word: &Word, output_word: &Word) -> Result<(), String> {
88 self.base.add_word(input_word, output_word)
89 }Sourcepub fn stats(&self) -> &KnowledgeBaseStats
pub fn stats(&self) -> &KnowledgeBaseStats
pub fn stats_mut(&mut self) -> &mut KnowledgeBaseStats
Trait Implementations§
Source§impl Default for KnowledgeBase
impl Default for KnowledgeBase
Source§impl KnowledgeBaseTrait for KnowledgeBase
impl KnowledgeBaseTrait for KnowledgeBase
Auto Trait Implementations§
impl Freeze for KnowledgeBase
impl RefUnwindSafe for KnowledgeBase
impl Send for KnowledgeBase
impl Sync for KnowledgeBase
impl Unpin for KnowledgeBase
impl UnsafeUnpin for KnowledgeBase
impl UnwindSafe for KnowledgeBase
Blanket Implementations§
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
Mutably borrows from an owned value. Read more
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>
Converts
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>
Converts
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