A segment is a part of a recognition context (or a phrase) which is defined by an intent.
public struct Segment: Hashable, Identifiable
e.g. a phrase "book a restaurant and send an invitation to John" contains two intents, "book" and "send an invitation". Thus, the phrase will also contain two segments, "book a restaurant" and "send an invitation to John". A segment has to have exactly one intent that defines it, but it's allowed to have any number of entities and transcripts.
A segment can be final or tentative. Final segments are guaranteed to only contain final intent, entities and transcripts. Tentative segments can have a mix of final and tentative parts.
Comparable
, Hashable
, Identifiable
Creates a new tentative segment with empty intent, entities and transcripts.
public init(segmentId: Int, contextId: String)
- segmentId: The identifier of the segment within a
SpeechContext
. - contextId: The identifier of the
SpeechContext
that this segment belongs to.
Creates a new segment with provided parameters.
public init(segmentId: Int, contextId: String, isFinal: Bool, intent: Intent, entities: [Entity], transcripts: [Transcript])
- segmentId: The identifier of the segment within a
SpeechContext
. - contextId: The identifier of the
SpeechContext
that this segment belongs to. - isFinal: Indicates whether the segment is final or tentative.
- intent: The intent of the segment.
- entities: The entities belonging to the segment.
- transcripts: The transcripts belonging to the segment.
A unique identifier of the segment.
let id: String
The identifier of the segment, which is unique when combined with contextId
.
let segmentId: Int
A unique identifier of the SpeechContext
that the segment belongs to
let contextId: String
The status of the segment. true
when the segment is finalised, false
otherwise.
var isFinal: Bool = false
The intent of the segment. Returns an empty tentative intent by default.
var intent: Intent = Intent.Empty
The entities belonging to the segment.
var entities: [Entity]
The transcripts belonging to the segment.
var transcripts: [Transcript]
public static func <(lhs: Segment, rhs: Segment) -> Bool
public static func <=(lhs: Segment, rhs: Segment) -> Bool
public static func >=(lhs: Segment, rhs: Segment) -> Bool
public static func >(lhs: Segment, rhs: Segment) -> Bool