Skip to content

Latest commit

 

History

History
137 lines (88 loc) · 2.91 KB

Segment.md

File metadata and controls

137 lines (88 loc) · 2.91 KB

Segment

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.

Inheritance

Comparable, Hashable, Identifiable

Initializers

init(segmentId:contextId:)

Creates a new tentative segment with empty intent, entities and transcripts.

public init(segmentId: Int, contextId: String)

Parameters

  • segmentId: The identifier of the segment within a SpeechContext.
  • contextId: The identifier of the SpeechContext that this segment belongs to.

init(segmentId:contextId:isFinal:intent:entities:transcripts:)

Creates a new segment with provided parameters.

public init(segmentId: Int, contextId: String, isFinal: Bool, intent: Intent, entities: [Entity], transcripts: [Transcript])

Parameters

  • 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.

Properties

id

A unique identifier of the segment.

let id: String

segmentId

The identifier of the segment, which is unique when combined with contextId.

let segmentId: Int

contextId

A unique identifier of the SpeechContext that the segment belongs to

let contextId: String

isFinal

The status of the segment. true when the segment is finalised, false otherwise.

var isFinal: Bool = false

intent

The intent of the segment. Returns an empty tentative intent by default.

var intent: Intent = Intent.Empty

entities

The entities belonging to the segment.

var entities: [Entity]

transcripts

The transcripts belonging to the segment.

var transcripts: [Transcript]

Methods

<(lhs:rhs:)

public static func <(lhs: Segment, rhs: Segment) -> Bool

<=(lhs:rhs:)

public static func <=(lhs: Segment, rhs: Segment) -> Bool

>=(lhs:rhs:)

public static func >=(lhs: Segment, rhs: Segment) -> Bool

>(lhs:rhs:)

public static func >(lhs: Segment, rhs: Segment) -> Bool