dictionary

package
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: Jan 26, 2024 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Cache

type Cache interface {
	Lookup(word string) ([]Definition, error)
	Contains(word string) (bool, error)
	Save(word string, defs []Definition) error
}

type CachedDefiner

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

func NewCachedDefiner

func NewCachedDefiner(c Cache, d Definer) *CachedDefiner

func (*CachedDefiner) Define

func (d *CachedDefiner) Define(word string) ([]Definition, error)

type Definer

type Definer interface {
	Define(word string) ([]Definition, error)
}

type Definition

type Definition struct {
	PartOfSpeech string
	Meaning      string
}

Definition is a single dictionary entry for a word

type FileCache

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

func NewFileCache

func NewFileCache(dir string) (*FileCache, error)

NewFileCache returns a new file-based dictionary cache. A default is supplied if no dir is passed

func (*FileCache) Contains

func (c *FileCache) Contains(word string) (bool, error)

func (*FileCache) Lookup

func (c *FileCache) Lookup(word string) ([]Definition, error)

func (*FileCache) Save

func (c *FileCache) Save(word string, defs []Definition) error

type WebAPI

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

WebAPI lets you interact with a dictionary API

func NewDefaultWebAPI

func NewDefaultWebAPI() WebAPI

NewDefaultWebAPI creates a new instance for connecting to a dictionary API

func (WebAPI) Define

func (api WebAPI) Define(word string) ([]Definition, error)

Jump to

Keyboard shortcuts

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