pub struct QueryPattern {
pub id: String,
pub question_type: QuestionType,
pub template: String,
pub required_types: Vec<EntityType>,
pub success_count: u32,
pub failure_count: u32,
pub avg_results: f32,
pub created_at: i64,
pub last_used_at: i64,
}Expand description
A learned query pattern
Fields§
§id: StringUnique pattern ID
question_type: QuestionTypeQuestion type this pattern applies to
template: StringTemplate for the query (with placeholders)
required_types: Vec<EntityType>Required entity types
success_count: u32Number of successful uses
failure_count: u32Number of failed uses
avg_results: f32Average number of results
created_at: i64When this pattern was created
last_used_at: i64When this pattern was last used
Implementations§
Source§impl QueryPattern
impl QueryPattern
Sourcepub fn new(
question_type: QuestionType,
template: String,
required_types: Vec<EntityType>,
) -> QueryPattern
pub fn new( question_type: QuestionType, template: String, required_types: Vec<EntityType>, ) -> QueryPattern
Create a new query pattern
Sourcepub fn reliability(&self) -> f32
pub fn reliability(&self) -> f32
Compute reliability score (0.0 - 1.0)
Sourcepub fn record_success(&mut self, result_count: usize)
pub fn record_success(&mut self, result_count: usize)
Record a successful use
Sourcepub fn record_failure(&mut self)
pub fn record_failure(&mut self)
Record a failed use
Sourcepub fn matches_types(&self, types: &[EntityType]) -> bool
pub fn matches_types(&self, types: &[EntityType]) -> bool
Check if this pattern matches the given entity types
Trait Implementations§
Source§impl Clone for QueryPattern
impl Clone for QueryPattern
Source§fn clone(&self) -> QueryPattern
fn clone(&self) -> QueryPattern
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for QueryPattern
impl RefUnwindSafe for QueryPattern
impl Send for QueryPattern
impl Sync for QueryPattern
impl Unpin for QueryPattern
impl UnsafeUnpin for QueryPattern
impl UnwindSafe for QueryPattern
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