dictionary

package module
v1.0.0 Latest Latest
Warning

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

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

README

define

CircleCI GitHub release GoDoc MIT License Go Report Card PRs Welcome

A command-line dictionary app for Oxford.

This program is a hard fork of Rican7/define which only provides support for the v2 Oxford API.

Installation

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

go get github.com/jakewarren/define/...

Configuration

Uses the configuration scheme used by Rican7/define.

Example ~/.define.conf.json:

{
    "OxfordDictionary": {
        "AppID": "abc",
        "AppKey": "abc123"
    },
}
Configuration file

A configuration file can be stored at ~/.define.conf.json and define 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

This section is empty.

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 {
	Etymologies     []string `json:"etymologies"`
	HomographNumber *string  `json:"homographNumber,omitempty"`
	Senses          []Sense  `json:"senses"`
}

func (Entry) HasEtymology

func (e Entry) HasEtymology() bool

func (Entry) RenderEtymology

func (e Entry) RenderEtymology() interface{}

type Example

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

func (Example) Render

func (ex Example) Render() string

type LexicalCategory

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

type LexicalEntry

type LexicalEntry struct {
	Entries         []Entry          `json:"entries"`
	Language        *string          `json:"language,omitempty"`
	LexicalCategory *LexicalCategory `json:"lexicalCategory,omitempty"`
	Pronunciations  []Pronunciation  `json:"pronunciations"`
	Text            *string          `json:"text,omitempty"`
}

func (*LexicalEntry) RenderLexicalCategory

func (entry *LexicalEntry) RenderLexicalCategory() string

type Metadata

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

type Pronunciation

type Pronunciation struct {
	AudioFile        *string  `json:"audioFile,omitempty"`
	Dialects         []string `json:"dialects"`
	PhoneticNotation *string  `json:"phoneticNotation,omitempty"`
	PhoneticSpelling *string  `json:"phoneticSpelling,omitempty"`
}

type Result

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

type Results

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

type Sense

type Sense struct {
	Definitions      []string        `json:"definitions"`
	Examples         []Example       `json:"examples"`
	ID               *string         `json:"id,omitempty"`
	ShortDefinitions []string        `json:"shortDefinitions"`
	Subsenses        []Subsense      `json:"subsenses"`
	ThesaurusLinks   []ThesaurusLink `json:"thesaurusLinks"`
}

func (Sense) HasExamples

func (s Sense) HasExamples() bool

func (Sense) RenderExamples

func (s Sense) RenderExamples() string

type Subsense

type Subsense struct {
	Definitions      []string          `json:"definitions"`
	Examples         []Example         `json:"examples"`
	ID               *string           `json:"id,omitempty"`
	Regions          []LexicalCategory `json:"regions"`
	Registers        []LexicalCategory `json:"registers"`
	ShortDefinitions []string          `json:"shortDefinitions"`
	ThesaurusLinks   []ThesaurusLink   `json:"thesaurusLinks"`
}

func (Subsense) HasExamples

func (s Subsense) HasExamples() bool

func (Subsense) RenderExamples

func (s Subsense) RenderExamples() string

func (Subsense) RenderTags

func (s Subsense) RenderTags() string
type ThesaurusLink struct {
	EntryID *string `json:"entry_id,omitempty"`
	SenseID *string `json:"sense_id,omitempty"`
}

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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