lexicon

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Nov 28, 2023 License: Apache-2.0 Imports: 12 Imported by: 0

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.

func VerifyDB added in v1.1.0

func VerifyDB(cfg *configs.Configs)

VerifyDB verifies connection to the provided database and performs required migrations. Works for MySQL & libSQL. If DB connection or migration 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.

Jump to

Keyboard shortcuts

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