snowberry

package module
v0.1.4 Latest Latest
Warning

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

Go to latest
Published: Oct 3, 2024 License: MIT Imports: 3 Imported by: 0

README

Snowberry

A package that groups strings by similarity derived from levenshtein distance. Backed by a tree-like index.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AssignDebug

type AssignDebug struct {
	Input, MaskedInput         string
	Rejected                   bool
	BestMatch, BestMatchMasked string
	BestMatchScore             float32
	BestMatchAccepted          bool
}

AssignDebug contains details about every match processed

type Counter

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

Counter accepts strings and groups similar strings together, based on input parameters

func NewCounter

func NewCounter(step int, scoreThreshold float32) *Counter

NewCounter a new Counter. `step` represents the size of substrings used when building the tree-like index. `scoreThreshold` is a value between 0.0 and 1.0, where 1.0 represents a perfect match. A match must have a score above the threshold to be matched. The match with the highest score in the candidate set is always chosen.

func (*Counter) Assign

func (c *Counter) Assign(input string)

Assign assigns input to a category.

func (*Counter) Close

func (c *Counter) Close()

Close closes the debug channel, no-op if not set

func (*Counter) Counts

func (c *Counter) Counts() map[string]int

Counts returns the original, unmasked map of categories and counts

func (*Counter) WithDebugChannel added in v0.1.1

func (c *Counter) WithDebugChannel(debugChannel chan *AssignDebug) *Counter

WithDebugChannel returns a Counter which will pass AssignDebug to the passed in channel for debug/tuning purposes

func (*Counter) WithIgnoreAssign added in v0.1.1

func (c *Counter) WithIgnoreAssign(r []*regexp.Regexp) *Counter

WithIgnoreAssign returns a Counter which will ignore the targeted contents of assignments matching all regex

func (*Counter) WithRejectAssign added in v0.1.1

func (c *Counter) WithRejectAssign(r []*regexp.Regexp) *Counter

WithRejectAssign returns a Counter which will reject assignments matching one or more regex

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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