model

package
v0.0.0-...-6fa4a1e Latest Latest
Warning

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

Go to latest
Published: Jul 29, 2023 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	GOOGLE    string = "google"
	MOJO      string = "mojo"
	BING      string = "bing"
	CAMBRIDGE string = "cambridge"

	EN string = "en"
	JA string = "ja"
	ZH string = "zh"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Cambridge

type Cambridge struct {
	Engine
}

func (*Cambridge) Translate

func (c *Cambridge) Translate(query string) (Record, error)

type Dict

type Dict struct {
	LangType        string
	FilePath        string
	WordRecords     map[string]WordRecord
	SentenceRecords map[string]SentenceRecord
}

func InitDict

func InitDict(langType string) (*Dict, error)

func (*Dict) AddRecord

func (d *Dict) AddRecord(record interface{}) error

func (*Dict) DeleteRecordByQuery

func (d *Dict) DeleteRecordByQuery(query string) error

func (*Dict) GetRecordByLine

func (d *Dict) GetRecordByLine(line int) (Record, error)

type Engine

type Engine struct {
	Params       map[string]string
	SupportModel string
	ApiUrl       string
}

type Google

type Google struct {
	Engine
}

func (*Google) Translate

func (g *Google) Translate(query string) (Record, error)

type Mojo

type Mojo struct {
	Engine
}

func (*Mojo) Translate

func (m *Mojo) Translate(query string) (Record, error)

type Record

type Record interface {
	ColorPrint()
}

func Translate

func Translate(query string, langType string, sentence bool, trans string) (Record, error)

type Response

type Response struct {
	Result struct {
		Code    int `json:"code"`
		Results struct {
			SearchAll struct {
				Code   int `json:"code"`
				Result struct {
					Word struct {
						SearchResult []SearchResult `json:"searchResult"`
					} `json:"word"`
					Grammar struct {
						SearchResult []SearchResult `json:"searchResult"`
					} `json:"grammar"`
					Example struct {
						SearchResult []SearchResult `json:"searchResult"`
					} `json:"example"`
				} `json:"result"`
			} `json:"search-all"`
		} `json:"results"`
	} `json:"result"`
}

type SearchResult

type SearchResult struct {
	Title   string `json:"title"`
	Excerpt string `json:"excerpt"`
}

type SentenceRecord

type SentenceRecord struct {
	Sentence     string
	Translation1 string
	Translation2 string
}

func (SentenceRecord) ColorPrint

func (r SentenceRecord) ColorPrint()

type Translator

type Translator interface {
	Translate(query string) (Record, error)
}

type WordRecord

type WordRecord struct {
	Word          string
	Pronunciation string
	Translation   string
	Example       string
}

func (WordRecord) ColorPrint

func (r WordRecord) ColorPrint()

Jump to

Keyboard shortcuts

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