Documentation
¶
Overview ¶
Package customize defines SpeechKit's public Words/Replacements contract.
Index ¶
- Constants
- func FoldVocabulary(words []Word, replacements []Replacement) (folded []Word, extras []Replacement)
- func MaterializeVocabulary(words []Word, extras []Replacement) (merged []Word, replacements []Replacement)
- func NormalizeAliasList(term string, aliases []string) []string
- func NormalizeLanguage(language string) string
- func ReplacementIdentityKey(replacement Replacement) string
- func StableID(prefix string, parts ...string) string
- func ValidatePack(pack Pack) error
- func ValidateReplacement(replacement Replacement) error
- func ValidateWord(word Word) error
- func WordIdentityKey(word Word) string
- type Context
- type Kind
- type Lexicon
- type ListOptions
- type Match
- type MatchType
- type Mode
- type Pack
- type ReplaceOptions
- type Replacement
- type ReplacementOutput
- type Ruleset
- type ScopeKind
- type ScopeRef
- type Stage
- type Word
Constants ¶
const PackSchemaVersion = "speechkit.customization.pack.v1"
Variables ¶
This section is empty.
Functions ¶
func FoldVocabulary ¶ added in v0.61.10
func FoldVocabulary(words []Word, replacements []Replacement) (folded []Word, extras []Replacement)
FoldVocabulary attaches synonym/substitution rewrites whose output matches a Word onto that Word's sounds_like list. Remaining replacements are extras (punctuation, regex, snippets, commands).
func MaterializeVocabulary ¶ added in v0.61.10
func MaterializeVocabulary(words []Word, extras []Replacement) (merged []Word, replacements []Replacement)
MaterializeVocabulary merges Words and rebuilds alias replacements from sounds_like. extras must already be non-alias rules; derived aliases that also appear in extras are dropped so Words stay the source of truth.
func NormalizeAliasList ¶ added in v0.61.9
NormalizeAliasList trims, drops empties, drops the canonical term, and de-duplicates case-insensitively while keeping first-seen spelling.
func NormalizeLanguage ¶
func ReplacementIdentityKey ¶ added in v0.61.9
func ReplacementIdentityKey(replacement Replacement) string
ReplacementIdentityKey is the authoring identity for a Replacement. Output is intentionally not part of the key: many spoken forms may rewrite to the same canonical word.
func ValidatePack ¶
func ValidateReplacement ¶
func ValidateReplacement(replacement Replacement) error
func ValidateWord ¶
func WordIdentityKey ¶ added in v0.61.9
WordIdentityKey is the authoring identity for a Word: language + term.
Types ¶
type Context ¶
type Context struct {
Mode Mode `json:"mode,omitempty"`
Language string `json:"language,omitempty"`
Stage Stage `json:"stage,omitempty"`
Tags []string `json:"tags,omitempty"`
Persona string `json:"persona,omitempty"`
ActiveTemplateIDs []string `json:"active_template_ids,omitempty"`
ScopeOrder []ScopeRef `json:"scope_order,omitempty"`
}
type Lexicon ¶
type Lexicon struct {
ID string `json:"id"`
Name string `json:"name"`
Description string `json:"description,omitempty"`
Language string `json:"language,omitempty"`
WordIDs []string `json:"word_ids,omitempty"`
Tags []string `json:"tags,omitempty"`
Source string `json:"source,omitempty"`
Scope *ScopeRef `json:"scope,omitempty"`
Enabled bool `json:"enabled"`
CreatedAt time.Time `json:"created_at,omitempty"`
UpdatedAt time.Time `json:"updated_at,omitempty"`
}
type ListOptions ¶
type Mode ¶
type Mode string
func NormalizeMode ¶
func WordSynonymModes ¶ added in v0.61.10
func WordSynonymModes() []Mode
WordSynonymModes is the mode set for aliases derived from a Word.
type Pack ¶
type Pack struct {
SchemaVersion string `json:"schema_version"`
ID string `json:"id,omitempty"`
Name string `json:"name,omitempty"`
Description string `json:"description,omitempty"`
Words []Word `json:"words,omitempty"`
Replacements []Replacement `json:"replacements,omitempty"`
Lexicons []Lexicon `json:"lexicons,omitempty"`
Rulesets []Ruleset `json:"rulesets,omitempty"`
Attachments json.RawMessage `json:"attachments,omitempty"`
CreatedAt time.Time `json:"created_at,omitempty"`
}
type ReplaceOptions ¶
type Replacement ¶
type Replacement struct {
ID string `json:"id"`
Kind Kind `json:"kind"`
Match Match `json:"match"`
Output ReplacementOutput `json:"output"`
Language string `json:"language,omitempty"`
Modes []Mode `json:"modes,omitempty"`
Stage Stage `json:"stage"`
Priority int `json:"priority,omitempty"`
Tags []string `json:"tags,omitempty"`
Source string `json:"source,omitempty"`
Scope *ScopeRef `json:"scope,omitempty"`
Enabled bool `json:"enabled"`
UsageCount int `json:"usage_count,omitempty"`
CreatedAt time.Time `json:"created_at,omitempty"`
UpdatedAt time.Time `json:"updated_at,omitempty"`
}
func MergeReplacements ¶ added in v0.61.9
func MergeReplacements(replacements []Replacement) []Replacement
MergeReplacements collapses exact identity duplicates. Distinct match patterns that rewrite to the same output are kept.
func SynonymReplacement ¶ added in v0.61.9
func SynonymReplacement(term, alias, language, source string) Replacement
SynonymReplacement builds the derived rewrite for a Word alias.
func WithDefaultsReplacement ¶
func WithDefaultsReplacement(replacement Replacement) Replacement
type ReplacementOutput ¶
type Ruleset ¶
type Ruleset struct {
ID string `json:"id"`
Name string `json:"name"`
Description string `json:"description,omitempty"`
Language string `json:"language,omitempty"`
ReplacementIDs []string `json:"replacement_ids,omitempty"`
Tags []string `json:"tags,omitempty"`
Source string `json:"source,omitempty"`
Scope *ScopeRef `json:"scope,omitempty"`
Enabled bool `json:"enabled"`
CreatedAt time.Time `json:"created_at,omitempty"`
UpdatedAt time.Time `json:"updated_at,omitempty"`
}
type ScopeRef ¶
func DefaultDeviceScopeOrder ¶
func DefaultDeviceScopeOrder() []ScopeRef
func DefaultServerScopeOrder ¶
func DefaultServerScopeOrder() []ScopeRef
func NormalizeScopeRef ¶
type Word ¶
type Word struct {
ID string `json:"id"`
Term string `json:"term"`
SoundsLike []string `json:"sounds_like,omitempty"`
Language string `json:"language,omitempty"`
Weight float64 `json:"weight,omitempty"`
Tags []string `json:"tags,omitempty"`
Scope *ScopeRef `json:"scope,omitempty"`
Source string `json:"source,omitempty"`
Enabled bool `json:"enabled"`
UsageCount int `json:"usage_count,omitempty"`
CreatedAt time.Time `json:"created_at,omitempty"`
UpdatedAt time.Time `json:"updated_at,omitempty"`
}
func MergeWords ¶ added in v0.61.9
MergeWords collapses duplicate terms in the same language. sounds_like and tags are unioned. Duplicate rows are a settings/migration defect, not a supported authoring state.