service

package
v0.0.0-...-273c5a8 Latest Latest
Warning

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

Go to latest
Published: Oct 16, 2022 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrAzureTranslationAlreadyExists = errors.New("azure translation already exists")
View Source
var ErrTranslationAlreadyExists = errors.New("custsomtranslation already exists")
View Source
var ErrTranslationNotFound = errors.New("translation not found")

Functions

This section is empty.

Types

type AzureTranslation

type AzureTranslation struct {
	Pos        domain.WordPos
	Target     string
	Confidence float64
}

func (*AzureTranslation) ToTranslation

func (t *AzureTranslation) ToTranslation(lang2 domain.Lang2, text string) (domain.Translation, error)

type AzureTranslationClient

type AzureTranslationClient interface {
	DictionaryLookup(ctx context.Context, text string, fromLang, toLang domain.Lang2) ([]AzureTranslation, error)
}

type AzureTranslationRepository

type AzureTranslationRepository interface {
	Add(ctx context.Context, lang2 domain.Lang2, text string, result []AzureTranslation) error

	Find(ctx context.Context, lang2 domain.Lang2, text string) ([]AzureTranslation, error)

	FindByTextAndPos(ctx context.Context, lang2 domain.Lang2, text string, pos domain.WordPos) (domain.Translation, error)

	FindByText(ctx context.Context, lang2 domain.Lang2, text string) ([]domain.Translation, error)

	FindByFirstLetter(ctx context.Context, lang2 domain.Lang2, firstLetter string) ([]domain.Translation, error)

	Contain(ctx context.Context, lang2 domain.Lang2, text string) (bool, error)
}

type CustomTranslationRepository

type CustomTranslationRepository interface {
	Add(ctx context.Context, param TranslationAddParameter) error

	Update(ctx context.Context, lang2 domain.Lang2, text string, pos domain.WordPos, param TranslationUpdateParameter) error

	Remove(ctx context.Context, lang2 domain.Lang2, text string, pos domain.WordPos) error

	FindByText(ctx context.Context, lang2 domain.Lang2, text string) ([]domain.Translation, error)

	FindByTextAndPos(ctx context.Context, lang2 domain.Lang2, text string, pos domain.WordPos) (domain.Translation, error)

	FindByFirstLetter(ctx context.Context, lang2 domain.Lang2, firstLetter string) ([]domain.Translation, error)

	Contain(ctx context.Context, lang2 domain.Lang2, text string) (bool, error)
}

type RepositoryFactory

type RepositoryFactory interface {
	NewAzureTranslationRepository(ctx context.Context) AzureTranslationRepository

	NewCustomTranslationRepository(ctx context.Context) CustomTranslationRepository
}

type TranslationAddParameter

type TranslationAddParameter interface {
	GetText() string
	GetPos() domain.WordPos
	GetLang2() domain.Lang2
	GetTranslated() string
}

func NewTransalationAddParameter

func NewTransalationAddParameter(text string, pos domain.WordPos, lang2 domain.Lang2, translated string) (TranslationAddParameter, error)

type TranslationSearchCondition

type TranslationSearchCondition struct {
	PageNo   int
	PageSize int
}

type TranslationSearchResult

type TranslationSearchResult struct {
	TotalCount int64
	Results    [][]AzureTranslation
}

type TranslationUpdateParameter

type TranslationUpdateParameter interface {
	GetTranslated() string
}

func NewTransaltionUpdateParameter

func NewTransaltionUpdateParameter(translated string) (TranslationUpdateParameter, error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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