libmozhi

package module
v0.0.0-...-74421e4 Latest Latest
Warning

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

Go to latest
Published: Jan 19, 2025 License: AGPL-3.0 Imports: 19 Imported by: 0

README

LibMozhi

AGPLv3 Matrix Go Reference

Library that backs Mozhi.

File Matrix

  • autodetect.go - Auto detect language from given text.
  • engines.go - Code for getting data from engines themselves
  • langlist-*.go - List of languages supported by the specific engine
  • tts.go - Get TTS data for given text
  • retrieve.go - Used to get new langlist data
  • libmozhi.go - Main functions that wrap around the others to make the thing usable

Documentation

Overview

Autogenerated by retrieve.go. DO NOT EDIT.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func TTS

func TTS(engine string, lang string, text string) ([]byte, error)

Types

type ImgOut

type ImgOut struct {
	SourceB64            string
	TranslatedImgB64     string
	SourceLang           string
	TargetLang           string
	SourceTextParsed     string
	TranslatedTextParsed string
}

func ImageGoogle

func ImageGoogle(to string, from string, imgB64 string) (ImgOut, error)

type LangOut

type LangOut struct {
	Engine                     string              `json:"engine"`
	AutoDetect                 string              `json:"detected"`
	OutputText                 string              `json:"translated-text"`
	SourceLang                 string              `json:"source_language"`
	TargetLang                 string              `json:"target_language"`
	WordChoices                []WordChoices       `json:"word_choices"`
	SourceTransliteration      string              `json:"source_transliteration"`
	TargetTransliteration      string              `json:"target_transliteration"`
	SourceSynonyms             []string            `json:"source_synonyms"`
	TargetSynonyms             []string            `json:"target_synonyms"`
	SourceAntonyms             []string            `json:"source_antonyms"`
	TargetAntonyms             []string            `json:"target_antonyms"`
	SourceEquivalentTargetLang map[string][]string `json:"source_equivalent_target_lang"`
	TargetEquivalentSourceLang map[string][]string `json:"target_equivalent_source_lang"`
}

func Translate

func Translate(engine string, to string, from string, text string) (LangOut, error)

General function to translate stuff so there is no need for a huge if-block everywhere

func TranslateAll

func TranslateAll(to string, from string, query string) []LangOut

func TranslateSome

func TranslateSome(engines []string, to string, from string, query string) ([]LangOut, error)

type List

type List struct {
	Name string
	Id   string
}

func LangList

func LangList(engine string, listType string) ([]List, error)

type WordChoices

type WordChoices struct {
	Word       string `json:"word"`
	Definition string `json:"definition"`
	// Example is for google alone; since it does not have a linked example for source & target
	Example        string   `json:"example"`
	ExamplesSource []string `json:"examples_source"`
	ExamplesTarget []string `json:"examples_target"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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