pub struct DialogState {
pub context: Vec<String>,
pub entities: HashMap<String, String>,
pub slots: HashMap<String, String>,
pub current_act: Option<DialogAct>,
pub turn_count: usize,
}Expand description
Complete state of an ongoing dialogue.
Carries the raw utterance history, a map of extracted entities, and a map of domain-specific slot values filled so far.
§Example
use scirs2_text::dialog::{DialogState, DialogAct};
let mut state = DialogState::new();
state.add_utterance("Hello, I want to book a flight to Paris.");
state.set_slot("destination", "Paris");
assert_eq!(state.get_slot("destination"), Some("Paris"));Fields§
§context: Vec<String>Raw utterance history (user turns only).
entities: HashMap<String, String>Named entities extracted so far. Maps entity type label → value.
slots: HashMap<String, String>Domain-specific slot values.
current_act: Option<DialogAct>Current dialog act (last recognised).
turn_count: usizeNumber of turns completed.
Implementations§
Source§impl DialogState
impl DialogState
Sourcepub fn add_utterance(&mut self, utterance: &str)
pub fn add_utterance(&mut self, utterance: &str)
Append a user utterance to the context history.
Sourcepub fn set_entity(&mut self, entity_type: &str, value: &str)
pub fn set_entity(&mut self, entity_type: &str, value: &str)
Set an entity value.
Sourcepub fn get_entity(&self, entity_type: &str) -> Option<&str>
pub fn get_entity(&self, entity_type: &str) -> Option<&str>
Get an entity value by type label.
Sourcepub fn last_utterance(&self) -> Option<&str>
pub fn last_utterance(&self) -> Option<&str>
Return the last utterance, or None if the context is empty.
Sourcepub fn slots_filled(&self, required: &[&str]) -> bool
pub fn slots_filled(&self, required: &[&str]) -> bool
Return true if the required slots are all filled.
Trait Implementations§
Source§impl Clone for DialogState
impl Clone for DialogState
Source§fn clone(&self) -> DialogState
fn clone(&self) -> DialogState
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for DialogState
impl Debug for DialogState
Source§impl Default for DialogState
impl Default for DialogState
Source§fn default() -> DialogState
fn default() -> DialogState
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Freeze for DialogState
impl RefUnwindSafe for DialogState
impl Send for DialogState
impl Sync for DialogState
impl Unpin for DialogState
impl UnsafeUnpin for DialogState
impl UnwindSafe for DialogState
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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 moreSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
The inverse inclusion map: attempts to construct
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
Checks if
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
Use with care! Same as
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
The inclusion map: converts
self to the equivalent element of its superset.