Documentation ¶
Overview ¶
Package lexicon defines an Lexicon interface.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetInstance ¶
func GetInstance(cfg *configs.Configs) *lexicon.LexiconSQL
GetInstance returns an instance of Lexicon object configured as per the configs. If configs are nil or invalid then this function will panic. If internal system connection fails then the function will panic.
Types ¶
type Lexicon ¶
type Lexicon interface { // Lookup checks existence of the given words. // It returns array of strings of all the words that exists within the lexicon. // If any error occurs then it is returned; nil or empty words will return error. Lookup(words ...string) (*[]string, error) // GetAllWordsStartingWith will search given 'substrings' strings and return an array of all the words that start with the string. // Words are returned in lexicographical order (case insensitive). // Return value is a map where key is the 'substrings' string and value is array of matching words. // If any error occurs then it is returned; nil or empty words will return error. GetAllWordsStartingWith(substrings ...string) (*map[string][]string, error) // GetAllWordsEndingWith will search given 'substrings' strings and return an array of all the words that end with the string. // Words are returned in lexicographical order (case insensitive). // Return value is a map where key is the 'substrings' string and value is array of matching words. // If any error occurs then it is returned; nil or empty words will return error. GetAllWordsEndingWith(substrings ...string) (*map[string][]string, error) // Add adds the given array of words/string to current lexicon. // If failure occurs then error is returned; nil or empty words will return error. Add(words ...string) error // Close will close the lexicon. // Just like a book which is closed after usage. Close() }
A Lexicon is an collection of words. Unlike dictionary, lexicon only stores words/string and no value (meaning). Like dictionary, various operation such as search or add can be performed on a Lexicon. A word is just a string in golang terms.
Click to show internal directories.
Click to hide internal directories.