setsim

package
v0.56.6 Latest Latest
Warning

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

Go to latest
Published: Nov 30, 2026 License: MIT Imports: 0 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package setsim holds set-similarity metrics shared by the layers that cluster text: preference clustering, mood's repetition detector, and lesson dedup.

It exists because the same function had been written three times, in two map shapes, and had already started to diverge — one copy had dropped a guard the others kept. A similarity metric that decides whether two things are "the same" is exactly the kind of code that should have one definition and one set of tests.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Jaccard

func Jaccard[V any](a, b map[string]V) float64

Jaccard is the intersection-over-union of two sets, in [0,1].

The value type is free so callers can keep whichever map shape they already use — map[string]bool and map[string]struct{} are both idiomatic set spellings and neither should have to convert to share this.

Two empty sets score 0, not 1: callers use this to ask "is this new thing a repeat of that one", and an empty token set carries no evidence either way. Scoring it as a perfect match would make every content-free input look like a duplicate of every other.

Types

This section is empty.

Jump to

Keyboard shortcuts

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