dict

package
v0.0.0-...-91672d7 Latest Latest
Warning

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

Go to latest
Published: Apr 2, 2024 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	BucketRawwords = []byte("rawwords")
	BucketWords    = []byte("words")
	BucketMedia    = []byte("media")
)

Functions

This section is empty.

Types

type Bing

type Bing struct {
	Client *http.Client
}

func (Bing) Search

func (bing Bing) Search(ctx context.Context, rawword string) (*Word, error)

type Cache

type Cache struct {
	Dictionary
	DB *bolt.DB
}

func (Cache) Media

func (d Cache) Media(ctx context.Context, url string) ([]byte, error)

TODO: enable ctx

func (Cache) Search

func (d Cache) Search(ctx context.Context, rawword string) (*Word, error)

type Def

type Def struct {
	PartOfSpeech string `json:"pos"`
	Def          string `json:"def"`
	Language     language.Tag
}

type Dictionary

type Dictionary interface {
	Search(ctx context.Context, word string) (*Word, error)
}

type Pronunciation

type Pronunciation struct {
	US        string `json:"us"`
	US_MP3URL string `json:"us_mp3url"`
	UK        string `json:"uk"`
	UK_MP3URL string `json:"uk_mp3url"`
}

type SampleSentence

type SampleSentence struct {
	English string `json:"en"`
	Chinese string `json:"ch"`
	MP3URL  string `json:"mp3url"`
}

type Word

type Word struct {
	Word            string           `json:"word"`
	Pronunciation   Pronunciation    `json:"pronunciation"`
	Defs            []Def            `json:"defs"`
	SampleSentences []SampleSentence `json:"sample_sentences"`
}

Jump to

Keyboard shortcuts

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