Documentation ¶
Overview ¶
Package source defines interfaces to be implemented by dictionary sources and common structures and operations for those implementations to use.
Index ¶
- func ValidateHTTPResponse(httpResponse *http.Response, validContentTypes []string, ...) error
- func ValidateResult(result Result) error
- type AuthenticationError
- type ComprehensiveDictionaryEntry
- type DictionaryEntry
- type DictionaryEntryValue
- type EmptyResultError
- type Entry
- type EntryValue
- type EtymologyEntry
- type EtymologyEntryValue
- type InvalidResponseError
- type Result
- type ResultValue
- type Sense
- type SenseValue
- type Source
- type ThesaurusEntry
- type ThesaurusEntryValue
- type VersatileDictionaryEntry
- type WordEntry
- type WordEntryValue
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 ¶
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 ¶
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 ¶
type Entry interface { WordEntry DictionaryEntry EtymologyEntry ThesaurusEntry }
Entry defines a composite interface for the complete account of a word
type EntryValue ¶
type EntryValue struct { WordEntryValue DictionaryEntryValue EtymologyEntryValue ThesaurusEntryValue }
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 ¶
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 ¶
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) Subsenses ¶
func (s SenseValue) Subsenses() []Sense
Subsenses returns the sense's subsenses
type ThesaurusEntry ¶
ThesaurusEntry defines an interface for a thesaurus entry of a word
type ThesaurusEntryValue ¶
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 WordEntryValue ¶
A WordEntryValue is a specific word entry representation
func (WordEntryValue) Category ¶
func (e WordEntryValue) Category() string
Category returns the entry's lexical category
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 |