source

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Mar 22, 2018 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package source defines interfaces to be implemented by dictionary sources and common structures and operations for those implementations to use.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ValidateHTTPResponse

func ValidateHTTPResponse(httpResponse *http.Response, validContentTypes []string, validStatusCodes []int) error

ValidateHTTPResponse validates an HTTP response and returns an error if the response is invalid

func ValidateResult

func ValidateResult(result Result) error

ValidateResult validates the result and returns an error if invalid

Types

type AuthenticationError

type AuthenticationError struct {
}

AuthenticationError represents an error caused by an authentication problem

func (*AuthenticationError) Error

func (e *AuthenticationError) Error() string

type ComprehensiveDictionaryEntry

type ComprehensiveDictionaryEntry interface {
	DictionaryEntry
	EtymologyEntry
}

ComprehensiveDictionaryEntry defines a composite interface for a comprehensive dictionary entry of a word

type DictionaryEntry

type DictionaryEntry interface {
	Pronunciation() string
	Senses() []Sense
}

DictionaryEntry defines an interface for a dictionary entry of a word

type DictionaryEntryValue

type DictionaryEntryValue struct {
	PronunciationVal string
	SenseVals        []SenseValue
}

A DictionaryEntryValue contains the common attributes of a dictionary entry of a word

func (DictionaryEntryValue) Pronunciation

func (e DictionaryEntryValue) Pronunciation() string

Pronunciation returns the entry's pronunciation representation

func (DictionaryEntryValue) Senses

func (e DictionaryEntryValue) Senses() []Sense

Senses returns the entry's senses

type EmptyResultError

type EmptyResultError struct {
	Word string
}

EmptyResultError represents an error caused by an empty result

func (*EmptyResultError) Error

func (e *EmptyResultError) Error() string

type Entry

Entry defines a composite interface for the complete account of a word

type EntryValue

An EntryValue contains the common attributes of a complete account of a particular word

type EtymologyEntry

type EtymologyEntry interface {
	Etymologies() []string
}

EtymologyEntry defines an interface for an etymological entry of a word

type EtymologyEntryValue

type EtymologyEntryValue struct {
	EtymologyVals []string
}

An EtymologyEntryValue contains the common attributes of an etymological entry of a word

func (EtymologyEntryValue) Etymologies

func (e EtymologyEntryValue) Etymologies() []string

Etymologies returns the entry's etymology strings

type InvalidResponseError

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

InvalidResponseError represents an error caused by an invalid response

func (*InvalidResponseError) Error

func (e *InvalidResponseError) Error() string

type Result

type Result interface {
	Headword() string
	Language() string
	Entries() []DictionaryEntry
}

Result defines an interface for the results of a dictionary lookup

func ValidateAndReturnResult

func ValidateAndReturnResult(result Result) (Result, error)

ValidateAndReturnResult validates the result and returns the result and a nil error if valid. If invalid, it'll return a nil result and an error.

type ResultValue

type ResultValue struct {
	Head      string
	Lang      string
	EntryVals []interface{}
}

A ResultValue contains the common attributes of a dictionary lookup result

func (ResultValue) Entries

func (r ResultValue) Entries() []DictionaryEntry

Entries returns the result's entries

func (ResultValue) Headword

func (r ResultValue) Headword() string

Headword returns the result's headword

func (ResultValue) Language

func (r ResultValue) Language() string

Language returns the result's language

type Sense

type Sense interface {
	Definitions() []string
	Examples() []string
	Notes() []string

	Subsenses() []Sense
}

Sense defines an interface for the different meanings of a word

type SenseValue

type SenseValue struct {
	DefinitionVals []string
	ExampleVals    []string
	NoteVals       []string

	SubsenseVals []SenseValue
}

A SenseValue contains the common attributes of a word's meanings

func (SenseValue) Definitions

func (s SenseValue) Definitions() []string

Definitions returns the sense's definitions

func (SenseValue) Examples

func (s SenseValue) Examples() []string

Examples returns the sense's examples

func (SenseValue) Notes

func (s SenseValue) Notes() []string

Notes returns the sense's notes

func (SenseValue) Subsenses

func (s SenseValue) Subsenses() []Sense

Subsenses returns the sense's subsenses

type Source

type Source interface {
	Name() string

	Define(word string) (Result, error)
}

Source defines an interface for interacting with different dictionaries

type ThesaurusEntry

type ThesaurusEntry interface {
	Synonyms() []string
	Antonyms() []string
}

ThesaurusEntry defines an interface for a thesaurus entry of a word

type ThesaurusEntryValue

type ThesaurusEntryValue struct {
	SynonymVals []string
	AntonymVals []string
}

A ThesaurusEntryValue contains the common attributes of a thesaurus entry of a word

func (ThesaurusEntryValue) Antonyms

func (e ThesaurusEntryValue) Antonyms() []string

Antonyms returns the entry's antonyms

func (ThesaurusEntryValue) Synonyms

func (e ThesaurusEntryValue) Synonyms() []string

Synonyms returns the entry's synonyms

type VersatileDictionaryEntry

type VersatileDictionaryEntry interface {
	DictionaryEntry
	ThesaurusEntry
}

VersatileDictionaryEntry defines a composite interface for a versatile dictionary entry of a word

type WordEntry

type WordEntry interface {
	Word() string
	Category() string
}

WordEntry defines an interface for an entry of a specific word

type WordEntryValue

type WordEntryValue struct {
	WordVal     string
	CategoryVal string
}

A WordEntryValue is a specific word entry representation

func (WordEntryValue) Category

func (e WordEntryValue) Category() string

Category returns the entry's lexical category

func (WordEntryValue) Word

func (e WordEntryValue) Word() string

Word returns the entry's word

Directories

Path Synopsis
Package glosbe provides a dictionary source via the Glosbe API
Package glosbe provides a dictionary source via the Glosbe API
Package oxford provides a dictionary source via the Oxford Dictionaries API
Package oxford provides a dictionary source via the Oxford Dictionaries API
Package webster provides a dictionary source via the Webster Dictionaries API
Package webster provides a dictionary source via the Webster Dictionaries API

Jump to

Keyboard shortcuts

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