pub struct DialogueTurn {
pub text: String,
pub speaker: String,
pub participant_type: ParticipantType,
pub speech_act: Option<SpeechActType>,
pub is_aside: bool,
pub triggered_cutoff: bool,
pub turn_number: usize,
pub addressee: Option<String>,
pub language: Option<String>,
pub start: usize,
pub end: usize,
}Expand description
A single turn in a dialogue.
§Why Turn-Level Metadata?
Written text is speaker-agnostic. Dialogue requires tracking:
- Who said this?
- Who were they talking to?
- Was this meant to be heard by the agent?
- Did it trigger an unwanted agent response?
§Example
use anno::discourse::dialogue::{DialogueTurn, SpeechActType, ParticipantType};
// A human says "oui" as a continuer
let turn = DialogueTurn::new("oui", "EMM")
.with_participant_type(ParticipantType::Human)
.with_speech_act(SpeechActType::Continuer)
.with_triggered_cutoff(true);
assert!(turn.is_response_token());
assert!(turn.triggered_cutoff);Fields§
§text: StringThe utterance text.
speaker: StringSpeaker identifier (e.g., “EMM”, “GPT”, “TOM”).
participant_type: ParticipantTypeType of participant (human or agent).
speech_act: Option<SpeechActType>Pragmatic function of this turn.
is_aside: boolIs this an aside (directed away from the agent)?
Aside sequences are contributions designed to exclude the agent:
- Whispered to co-participants
- Gestured/mouthed rather than spoken
- Explicitly directed at another human
triggered_cutoff: boolDid this turn trigger an agent interruption/cutoff?
Response tokens often trigger unwanted agent responses because VAD detects them as speech requiring a response.
turn_number: usizeTurn number in the dialogue (0-indexed).
addressee: Option<String>Who this turn is addressed to (if known).
language: Option<String>Language code (e.g., “fr”, “en”).
start: usizeCharacter offset in the full dialogue transcript.
end: usizeEnd character offset.
Implementations§
Source§impl DialogueTurn
impl DialogueTurn
Sourcepub fn new(text: impl Into<String>, speaker: impl Into<String>) -> DialogueTurn
pub fn new(text: impl Into<String>, speaker: impl Into<String>) -> DialogueTurn
Create a new dialogue turn.
Sourcepub fn with_participant_type(self, pt: ParticipantType) -> DialogueTurn
pub fn with_participant_type(self, pt: ParticipantType) -> DialogueTurn
Set participant type.
Sourcepub fn with_speech_act(self, act: SpeechActType) -> DialogueTurn
pub fn with_speech_act(self, act: SpeechActType) -> DialogueTurn
Set speech act type.
Sourcepub fn as_aside(self, is_aside: bool) -> DialogueTurn
pub fn as_aside(self, is_aside: bool) -> DialogueTurn
Mark as aside (not directed at agent).
Sourcepub fn with_triggered_cutoff(self, triggered: bool) -> DialogueTurn
pub fn with_triggered_cutoff(self, triggered: bool) -> DialogueTurn
Mark whether this triggered an agent cutoff.
Sourcepub fn with_turn_number(self, n: usize) -> DialogueTurn
pub fn with_turn_number(self, n: usize) -> DialogueTurn
Set turn number.
Sourcepub fn with_addressee(self, addr: impl Into<String>) -> DialogueTurn
pub fn with_addressee(self, addr: impl Into<String>) -> DialogueTurn
Set addressee.
Sourcepub fn with_language(self, lang: impl Into<String>) -> DialogueTurn
pub fn with_language(self, lang: impl Into<String>) -> DialogueTurn
Set language.
Sourcepub fn with_span(self, start: usize, end: usize) -> DialogueTurn
pub fn with_span(self, start: usize, end: usize) -> DialogueTurn
Set character span.
Sourcepub fn is_response_token(&self) -> bool
pub fn is_response_token(&self) -> bool
Is this a response token?
Trait Implementations§
Source§impl Clone for DialogueTurn
impl Clone for DialogueTurn
Source§fn clone(&self) -> DialogueTurn
fn clone(&self) -> DialogueTurn
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for DialogueTurn
impl Debug for DialogueTurn
Source§impl<'de> Deserialize<'de> for DialogueTurn
impl<'de> Deserialize<'de> for DialogueTurn
Source§fn deserialize<__D>(
__deserializer: __D,
) -> Result<DialogueTurn, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<DialogueTurn, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
Source§impl Serialize for DialogueTurn
impl Serialize for DialogueTurn
Source§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
Auto Trait Implementations§
impl Freeze for DialogueTurn
impl RefUnwindSafe for DialogueTurn
impl Send for DialogueTurn
impl Sync for DialogueTurn
impl Unpin for DialogueTurn
impl UnsafeUnpin for DialogueTurn
impl UnwindSafe for DialogueTurn
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
impl<T> ErasedDestructor for Twhere
T: 'static,
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