minhash

package module
v0.0.0-...-2b68fc3 Latest Latest
Warning

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

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

README

minhash

golang Minhash实现

使用方式

a := "flying fish flew by the space station"
b := "we will not allow you to bring your pet armadillo along"
c := "he figured a few sticks of dynamite were easier than a fishing pole to catch fish"
h := minhash.New(32)
sa := h.Add(a)
sb := h.Add(b)
sc := h.Add(c)
ha := h.Hash(sa)
hb := h.Hash(sb)
hc := h.Hash(sc)
fmt.Println(minhash.Jaccard(ha, hb))
fmt.Println(minhash.Jaccard(ha, hc))

数值越大表示两句句子越接近

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Jaccard

func Jaccard(a, b Hash) float64

Types

type Hash

type Hash []int

type MinHash

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

func New

func New(hashSize int) *MinHash

func (*MinHash) Add

func (h *MinHash) Add(str string) ShingleSet

func (*MinHash) Hash

func (h *MinHash) Hash(ss ShingleSet) Hash

type ShingleSet

type ShingleSet map[shingle]int

func (ShingleSet) Intersection

func (ss ShingleSet) Intersection(other ShingleSet) ShingleSet

func (ShingleSet) Union

func (ss ShingleSet) Union(other ShingleSet) ShingleSet

Jump to

Keyboard shortcuts

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