stringindex

package
v0.0.0-...-bc5a6c4 Latest Latest
Warning

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

Go to latest
Published: Jun 19, 2023 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Substrings

func Substrings(str string, size int) []string

Substrings produces the list of all contiguous substrings of the given size.

Types

type Index

type Index struct {
	Matches map[string][]Match
}

Index is a simple search index. It does not store values, only the value's ID provided by the consumer of this package. The IDs of all matching values are returned as the result of a search.

func NewIndex

func NewIndex() *Index

NewIndex creates a new index.

func (*Index) Insert

func (idx *Index) Insert(id int, confidence int, strs ...string)

Insert stores the relationship with the given ID and strings (queries). It also requires a confidence to be associated with the relationship, which is used to order results.

func (*Index) Search

func (idx *Index) Search(query string) []Match

Search searches for indexed values matching the query. Results are ordered by descending order of confidence.

type Match

type Match struct {
	ID         int
	Confidence float64
}

Match stores the confidence that a result with the id is a match.

Jump to

Keyboard shortcuts

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