tokenizers

package
v0.0.0-...-e06318d Latest Latest
Warning

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

Go to latest
Published: Sep 12, 2024 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DeleteTokenizer

func DeleteTokenizer(name string)

DeleteTokenizer deletes a tokenizer from the store

func SetTokenizer

func SetTokenizer(name string, tokenizer Tokenizer)

SetTokenizer sets a tokenizer in the store will overwrite if it already exists

Types

type NGram

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

func NewNGram

func NewNGram(min, max int) *NGram

NewNGram returns a new NGram tokenizer

func (*NGram) Process

func (n *NGram) Process(val string) error

Process takes a string value, generates n-grams, and fills out the index

func (*NGram) Search

func (n *NGram) Search(vals []string) (bool, error)

Search checks if all specified n-grams exist in the index

func (*NGram) ToSearch

func (n *NGram) ToSearch(val string) ([]string, error)

Tokenize generates all possible n-grams from the input string

type Tokenizer

type Tokenizer interface {
	// Process will take in a string value and
	// use it to fill out the struct fields
	Process(val string) error

	// ToSearch will take in a string value and
	// return a slice of strings that can be used
	// to search
	ToSearch(val string) ([]string, error)

	Search(val []string) (bool, error)
}

func GetTokenizer

func GetTokenizer(name string, config map[string]any) (Tokenizer, error)

GetTokenizer returns a tokenizer from the store and initializes it with the given config

type Words

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

func NewWords

func NewWords() *Words

NewWords will remove accents, lowercase and make it searchable via words

func (*Words) Process

func (w *Words) Process(str string) error

Process will take in an any value and use it to fill out the struct fields

func (*Words) Search

func (w *Words) Search(val []string) (bool, error)

Search checks if the provided words appear in order within the Words struct's words slice.

func (*Words) ToSearch

func (w *Words) ToSearch(str string) ([]string, error)

ToSearchBytes will return the bytes to search

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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