mapper

package
v0.0.0-...-608d5c4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 20, 2026 License: MIT Imports: 4 Imported by: 6

Documentation

Overview

Package mapper is used to map between different phonetic symbol sets, such as NST-SAMPA to Wikispeech-SAMPA, IPA to SAMPA, and so on. (Documentation on symbol sets can be found in the parent package 'symbolset'.)

By using each symbol set's IPA definition, it is possible to map between symbol sets that share the same list of IPA symbols (or if the left hand symbol is a subset of the right hand symbol set).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Mapper

type Mapper struct {
	Name       string
	SymbolSet1 symbolset.SymbolSet
	SymbolSet2 symbolset.SymbolSet
}

Mapper is a struct for package private usage. To create a new instance of Mapper, use LoadMapper.

func LoadMapper

func LoadMapper(s1 symbolset.SymbolSet, s2 symbolset.SymbolSet) (Mapper, error)

LoadMapper loads a symbol set mapper from two SymbolSet instances

func LoadMapperFromFile

func LoadMapperFromFile(fromName string, toName string, fName1 string, fName2 string) (Mapper, error)

LoadMapperFromFile loads two SymbolSet instances from files.

func (Mapper) MapSymbol

func (m Mapper) MapSymbol(input symbolset.Symbol) (symbolset.Symbol, error)

MapSymbol maps one input transcription symbol into the new symbol set.

func (Mapper) MapSymbolString

func (m Mapper) MapSymbolString(input string) (string, error)

MapSymbolString maps one input transcription symbol into the new symbol set.

func (Mapper) MapTranscription

func (m Mapper) MapTranscription(input string) (string, error)

MapTranscription maps one input transcription string into the new symbol set.

func (Mapper) MapTranscriptions

func (m Mapper) MapTranscriptions(input []string) ([]string, error)

MapTranscriptions maps the input transcriptions

type Service

type Service struct {
	SymbolSets map[string]symbolset.SymbolSet
	Mappers    map[string]Mapper
}

Service is a container for maintaining 'cached' mappers and their symbol sets. Please note that currently, MapperService need to be used as mutex, see lexserver/mapper.go

func (Service) Clear

func (s Service) Clear()

Clear is used to clear the cache (all loaded symbol sets and mappers)

func (Service) DeleteMapper

func (s Service) DeleteMapper(fromName string, toName string) error

DeleteMapper is used to delete a mapper the cache.

func (Service) DeleteSymbolSet

func (s Service) DeleteSymbolSet(ssName string) error

DeleteSymbolSet is used to delete a named symbol set from the cache. Deletes the named symbol set, and all mappers using this symbol set.

func (Service) GetMapTable

func (s Service) GetMapTable(fromName string, toName string) (Mapper, error)

GetMapTable is used by the server to show/get a mapping table between two symbol sets

func (Service) Load

func (s Service) Load(symbolSetFile string) error

Load is used to load a symbol set from file

func (Service) Map

func (s Service) Map(fromName string, toName string, trans string) (string, error)

Map is used by the server to map a transcription from one symbol set to another

func (Service) MapperNames

func (s Service) MapperNames() []string

MapperNames lists the names for all loaded mappers

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL