similarity

package
v0.4.11 Latest Latest
Warning

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

Go to latest
Published: May 20, 2024 License: GPL-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Closest

func Closest(sentence string, list []string) string

Closest returns the closest string to the given string

func Tokenize

func Tokenize(sentence string) []string

Tokenize extracts inforamtion from the input

Types

type Filter

type Filter struct {
	// Min is the minimum similarity to return
	Min float64
	// TopN is the number of top matches to return
	TopN int
}

Filter are the filters to apply to similarity

func (*Filter) IsEmpty

func (f *Filter) IsEmpty() bool

IsEmpty returns true if the filter is empty

type Score

type Score struct {
	// Input is the sentence we are comparing against
	Input string
	// Similarity is the probability of the sentence being similar
	Similarity float64
	// Words is the word count against the input
	Words map[string]int
}

Score is similarity score

func (*Score) Matches

func (h *Score) Matches() int

Matches returns the number of matches

type Similarity

type Similarity struct {
	// Input is the input sentence
	Input string
	// Scores is a list of scores
	Scores []Score
	// Tokens is the tokens of the sentence
	Tokens []string
}

Similarity are the scores

func Closeness

func Closeness(sentence string, list []string, filter Filter) Similarity

Closeness returns the closest string to the given string

func (*Similarity) Hightest

func (h *Similarity) Hightest() Score

Hightest returns the highest score

type WordCount

type WordCount struct {
	// Word is the token we found
	Word string
	// Occurrences is the number of times the word was found
	Occurrences int
}

WordCount is the word count against the input

Jump to

Keyboard shortcuts

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