thesaurus

package module
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Nov 19, 2019 License: MIT Imports: 9 Imported by: 0

README

thesaurus

CircleCI GitHub release GoDoc MIT License Go Report Card PRs Welcome

A command-line thesaurus app for Oxford.

Installation

If you have a working Go environment, you can install via go get:

go get github.com/jakewarren/thesaurus/...

Configuration

Uses the configuration scheme used by Rican7/define.

Configuration file

A configuration file can be stored at ~/.define.conf.json and thesaurus will automatically load the values specified there.

Environment variables

Some configuration values can also be specified via environment variables. This is especially useful for API keys of different sources.

The following environment variables are read by thesaurus's sources:

  • OXFORD_DICTIONARY_APP_ID
  • OXFORD_DICTIONARY_APP_KEY

Acknowledgements

Very heavily based on:

Obtaining API keys

The following are links to register for API keys for the different sources:

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Filter

func Filter(input []string, f func(string) bool) []string

Filter filters an array of strings based on a predicate function

func Ints

func Ints(input []int) []int

Ints returns a list of unique integers from a set of inputs.

func Min

func Min(input []int) int

Min returns the minimum value of an array of integers.

Types

type Client

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

Client bundles things needed to access the API

func New

func New(httpClient http.Client, appID, appKey string) *Client

New returns a new Oxford API dictionary source

func (*Client) Define

func (g *Client) Define(word string) (*Results, error)

Define takes a word string and returns a dictionary source.Result

type Entry

type Entry struct {
	Senses []Sense `json:"senses"`
}

type Example

type Example struct {
	Text string `json:"text"`
}

func (Example) Render

func (ex Example) Render() string

type Language

type Language string

type LexicalCategory

type LexicalCategory struct {
	ID   string `json:"id"`
	Text string `json:"text"`
}

type LexicalEntry

type LexicalEntry struct {
	Entries         []Entry         `json:"entries"`
	Language        string          `json:"language"`
	LexicalCategory LexicalCategory `json:"lexicalCategory"`
	Text            string          `json:"text"`
}

func (*LexicalEntry) RenderLexicalCategory

func (entry *LexicalEntry) RenderLexicalCategory() string

type Metadata

type Metadata struct {
	Operation string `json:"operation"`
	Provider  string `json:"provider"`
	Schema    string `json:"schema"`
}

type Onym

type Onym struct {
	ID       *string  `json:"id,omitempty"`
	Language Language `json:"language"`
	Text     string   `json:"text"`
}

type Result

type Result struct {
	ID             string         `json:"id"`
	Language       string         `json:"language"`
	LexicalEntries []LexicalEntry `json:"lexicalEntries"`
	Type           string         `json:"type"`
	Word           string         `json:"word"`
}

type Results

type Results struct {
	ID       string   `json:"id"`
	Metadata Metadata `json:"metadata"`
	Results  []Result `json:"results"`
	Word     string   `json:"word"`
}

type Sense

type Sense struct {
	Antonyms  []Onym            `json:"antonyms"`
	Examples  []Example         `json:"examples"`
	ID        string            `json:"id"`
	Registers []LexicalCategory `json:"registers"`
	Subsenses []Subsense        `json:"subsenses"`
	Synonyms  []Onym            `json:"synonyms"`
}

func (Sense) HasAntonyms

func (s Sense) HasAntonyms() bool

func (Sense) HasSynonyms

func (s Sense) HasSynonyms() bool

func (*Sense) RenderAntonyms

func (s *Sense) RenderAntonyms() string

func (Sense) RenderExamples

func (s Sense) RenderExamples() string

func (*Sense) RenderSynonyms

func (s *Sense) RenderSynonyms() string

func (Sense) RenderTags

func (s Sense) RenderTags() string

type Subsense

type Subsense struct {
	ID        string            `json:"id"`
	Synonyms  []Onym            `json:"synonyms"`
	Registers []LexicalCategory `json:"registers"`
	Regions   []LexicalCategory `json:"regions"`
}

func (Subsense) HasSynonyms

func (s Subsense) HasSynonyms() bool

func (*Subsense) RenderSynonyms

func (s *Subsense) RenderSynonyms() string

func (Subsense) RenderTags

func (s Subsense) RenderTags() string

Directories

Path Synopsis
cmd
thesaurus
nolint:whitespace,errcheck
nolint:whitespace,errcheck

Jump to

Keyboard shortcuts

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