util

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Dec 17, 2019 License: MIT Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CommonPrefix

func CommonPrefix(first, second string) string

CommonPrefix returns the common prefix of the specified strings. An empty string is returned if the parameters have no prefix in common.

func Max

func Max(args ...int) int

Max returns the value of the largest argument.

func Maxf

func Maxf(args ...float64) float64

Maxf returns the value of the largest argument.

func Min

func Min(args ...int) int

Min returns the value of the smallest argument.

func Minf

func Minf(args ...float64) float64

Minf returns the value of the smallest argument.

func NgramIntersection added in v0.2.0

func NgramIntersection(a, b []rune, size int) (map[string]int, int, int, int)

NgramIntersection returns a map of the n-grams of the specified size found in both terms, along with their frequency. The function also returns the number of common n-grams (the sum of all the values in the output map), the total number of n-grams in the first term and the total number of n-grams in the second term. An n-gram size of 1 is used if the provided size is less than or equal to 0.

func NgramMap added in v0.2.0

func NgramMap(runes []rune, size int) (map[string]int, int)

NgramMap returns a map of all n-grams of the specified size for the provided term, along with their frequency. The function also returns the total number of n-grams, which is the sum of all the values in the output map. An n-gram size of 1 is used if the provided size is less than or equal to 0.

func Ngrams added in v0.2.0

func Ngrams(runes []rune, size int) []string

Ngrams returns all the n-grams of the specified size for the provided term. The n-grams in the output slice are in the order in which they occur in the input term. An n-gram size of 1 is used if the provided size is less than or equal to 0.

func SliceContains

func SliceContains(terms []string, q string) bool

SliceContains returns true if terms contains q, or false otherwise.

func UniqueSlice

func UniqueSlice(items []string) []string

UniqueSlice returns a slice containing the unique items from the specified string slice. The items in the output slice are in the order in which they occur in the input slice.

Types

This section is empty.

Jump to

Keyboard shortcuts

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