dictionary

package
v0.0.0-...-64e351a Latest Latest
Warning

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

Go to latest
Published: Sep 6, 2022 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

Functions

This section is empty.

Types

type DefaultGetDefinition

type DefaultGetDefinition struct {
	// contains filtered or unexported fields
}

func NewDefaultGetDefinition

func NewDefaultGetDefinition(key string) *DefaultGetDefinition

NewDefaultGetDefinition constructor for standard API access

func (DefaultGetDefinition) Get

func (d DefaultGetDefinition) Get(text string) ([]byte, error)

Get fulfills Definitioner interface

type Definition

type Definition struct {
	Meta struct {
		Id   string `json:"id"`
		Uuid string `json:"uuid"`
		//Sort      string   `json:"sort"`
		//Src       string   `json:"src"`
		//Section   string   `json:"section"`
		//Stems     []string `json:"stems"`
		Offensive bool `json:"offensive"`
	} `json:"meta"`
	Hwi struct {
		Hw  string `json:"hw"`
		Prs []struct {
			Mw    string `json:"mw"`
			Sound struct {
				Audio string `json:"audio"`
				Ref   string `json:"ref"`
				Stat  string `json:"stat"`
			} `json:"sound"`
		} `json:"prs"`
	} `json:"hwi"`
	Fl string `json:"fl"`
	//Def []struct {
	//	Sseq [][][]interface{} `json:"sseq"`
	//} `json:"def"`
	//Uros []struct {
	//	Ure string `json:"ure"`
	//	Fl  string `json:"fl"`
	//} `json:"uros"`
	//Et     [][]string `json:"et"`
	//Date   string     `json:"date"`
	//LdLink struct {
	//	LinkHw string `json:"link_hw"`
	//	LinkFl string `json:"link_fl"`
	//} `json:"ld_link"`
	Suppl struct {
		Examples []struct {
			T string `json:"t"`
		} `json:"examples"`
	} `json:"suppl"`
	Shortdef []string `json:"shortdef"`
}

Definition - structured json, which is received from MerriamWebster, see https://www.dictionaryapi.com/products/json#sec-2 Deliberately, there are a lot of tags commented - they are not needed by package, however left them as maybe required someday

func (*Definition) Audio

func (w *Definition) Audio() []Pronunciation

Audio returns possible pronunciations for word

func (*Definition) Definition

func (w *Definition) Definition() []string

Definition simplified access to definition of certain word

func (*Definition) Examples

func (w *Definition) Examples() []string

Examples returns slice of strings with usage of certain word

func (*Definition) Function

func (w *Definition) Function() string

Function returns the word functions in a sentence, e.x. noun, adj etc

func (*Definition) IsOffensive

func (w *Definition) IsOffensive() bool

IsOffensive returns true, whether word is considered as offensive

func (*Definition) Text

func (w *Definition) Text() string

Text returns word, which translation belongs to

type Definitioner

type Definitioner interface {
	Get(text string) ([]byte, error)
}

type Dictionary

type Dictionary struct {
	Definitioner
}

func NewDictDefault

func NewDictDefault(key string) *Dictionary

func NewDictionary

func NewDictionary(getDefinition Definitioner) *Dictionary

func (Dictionary) Definition

func (d Dictionary) Definition(text string) (data []*Definition, suggestions *Suggestions, err error)

Definition return possible slice of Definition for passed argument. If it couldn't find exact Definition, function may returned slice with Suggestions - if there is a typo in word. Otherwise error

type Pronunciation

type Pronunciation struct {
	PhoneticNotation string
	Url              string
}

type Suggestions

type Suggestions struct {
	Suggestions []string
}

Jump to

Keyboard shortcuts

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