reverso_api

package module
v0.0.0-...-49b93c3 Latest Latest
Warning

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

Go to latest
Published: May 22, 2022 License: MIT Imports: 1 Imported by: 0

README

Reverso Go API

logotype

This API is not official! It allows you to manipulate with your text in different ways. Currently supported: context, translation

Navigation

Installing

go get -u https://github.com/kulishA/reverso-api

Usage

r := reverso_api.NewReversoApi()
req := reverso_api.TranslationRequest{...}
t, err := r.Translation.Translate(&req)

Examples

Transalation
r := reverso_api.NewReversoApi()

req := reverso_api.TranslationRequest{
    Format: "text",
    From:   reverso_api.ENG,
    To:     reverso_api.RU,
    Input:  "Hello world!",
    Options: reverso_api.Options{
        SentenceSplitter:  true,
        Origin:            "translation.web",
        ContextResults:    false,
        LanguageDetection: false,
    },
}

t, err := r.Translation.Translate(&req)
if err != nil {
    fmt.Println(err.Error())
    return
}

fmt.Println(t)

Documentation

Index

Constants

View Source
const (
	RU  = "rus"
	ENG = "eng"
	ARA = "ara"
	DUT = "dut"
	HEB = "heb"
	SPA = "spa"
	ITA = "ita"
	CHI = "chi"
	KOR = "kor"
	GER = "ger"
	POL = "pol"
	POR = "por"
	RUM = "rum"
	TUR = "tur"
	UKR = "urk"
	FRA = "fra"
	SWE = "swe"
	JPN = "jpn"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type ContextResult

type ContextResult struct {
	RudeWords             bool     `json:"rudeWords"`
	Colloquialisms        bool     `json:"colloquialisms"`
	RiskyWords            bool     `json:"riskyWords"`
	Results               []Result `json:"results"`
	TotalContextCallsMade int      `json:"totalContextCallsMade"`
	TimeTakenContext      int      `json:"timeTakenContext"`
}

type LanguageDetection

type LanguageDetection struct {
	DetectedLanguage                string `json:"detectedLanguage"`
	IsDirectionChanged              bool   `json:"isDirectionChanged"`
	OriginalDirection               string `json:"originalDirection"`
	OriginalDirectionContextMatches int    `json:"originalDirectionContextMatches"`
	ChangedDirectionContextMatches  int    `json:"changedDirectionContextMatches"`
	TimeTaken                       int    `json:"timeTaken"`
}

type Options

type Options struct {
	SentenceSplitter  bool   `json:"sentenceSplitter"`
	Origin            string `json:"origin"`
	ContextResults    bool   `json:"contextResults"`
	LanguageDetection bool   `json:"languageDetection"`
}

type Result

type Result struct {
	Translation     string      `json:"translation"`
	SourceExamples  []string    `json:"sourceExamples"`
	TargetExamples  []string    `json:"targetExamples"`
	Rude            bool        `json:"rude"`
	Colloquial      bool        `json:"colloquial"`
	PartOfSpeech    interface{} `json:"partOfSpeech"`
	Frequency       int         `json:"frequency"`
	Vowels          interface{} `json:"vowels"`
	Transliteration interface{} `json:"transliteration"`
}

type ReversoApi

type ReversoApi struct {
	Translation TranslateInterface
}

func NewReversoApi

func NewReversoApi() *ReversoApi

type TranslateInterface

type TranslateInterface interface {
	Translate(request *TranslationRequest) (*TranslationResponse, error)
}

type TranslationRequest

type TranslationRequest struct {
	Format  string  `json:"format"`
	From    string  `json:"from"`
	To      string  `json:"to"`
	Input   string  `json:"input"`
	Options Options `json:"options"`
}

type TranslationResponse

type TranslationResponse struct {
	Id                string            `json:"id"`
	From              string            `json:"from"`
	To                string            `json:"to"`
	Input             []string          `json:"input"`
	CorrectedText     string            `json:"correctedText"`
	Translation       []string          `json:"translation"`
	Engines           []string          `json:"engines"`
	LanguageDetection LanguageDetection `json:"language_detection"`
	ContextResults    ContextResult     `json:"contextResults"`
	Truncated         bool              `json:"truncated"`
	TimeTaken         int               `json:"timeTaken"`
}

Directories

Path Synopsis
internal
api

Jump to

Keyboard shortcuts

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