models

package
v0.0.0-...-8eb1a3c Latest Latest
Warning

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

Go to latest
Published: Aug 30, 2021 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Manager

type Manager struct {
	// contains filtered or unexported fields
}

Manager allows easy handling of multiple translation models.

func NewManager

func NewManager(config *configuration.Config, logger zerolog.Logger) *Manager

NewManager creates a new Manager.

func (*Manager) GetModel

func (mng *Manager) GetModel(source, target string) (*Model, bool)

GetModel returns a Model for translating texts from the given source language to the given target language. It also reports whether a model for that pair or languages is present (previously loaded).

func (*Manager) LoadModels

func (mng *Manager) LoadModels() error

LoadModels loads all models according to the configuration. If a model path is not found, automatic download and conversion are performed using spaGO huggingface Downloader and Converter.

func (*Manager) Translate

func (mng *Manager) Translate(source, target, text string) (string, error)

Translate is a convenience method to get a model and perform translation in a single step.

type Model

type Model struct {
	// contains filtered or unexported fields
}

Model provides high-level functionalities for loading spaGO models and performing automatic translation.

func NewModel

func NewModel(config *configuration.Config, name string, logger zerolog.Logger) *Model

NewModel creates a new Model.

func (*Model) Load

func (m *Model) Load() error

Load loads the underlying spaGO model. If the model path is not found, automatic download and conversion are performed using spaGO huggingface Downloader and Converter.

func (*Model) Translate

func (m *Model) Translate(text string) string

Translate performs automatic translation of the given text.

Jump to

Keyboard shortcuts

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