similarity

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Mar 7, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package similarity provides text similarity and clustering utilities.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ClusterObservations

func ClusterObservations(observations []*models.Observation, similarityThreshold float64) []*models.Observation

ClusterObservations groups similar observations and returns only one representative per cluster. Uses Jaccard similarity on extracted terms from title, narrative, and facts. Observations should be sorted by preference (e.g., recency) - first one in each cluster is kept.

func ExtractObservationTerms

func ExtractObservationTerms(obs *models.Observation) map[string]bool

ExtractObservationTerms extracts meaningful terms from an observation for similarity comparison.

func IsSimilarToAny

func IsSimilarToAny(newObs *models.Observation, existing []*models.Observation, similarityThreshold float64) bool

IsSimilarToAny checks if a new observation is similar to any existing observation. Returns true if similarity to any existing observation exceeds the threshold.

func JaccardSimilarity

func JaccardSimilarity(set1, set2 map[string]bool) float64

JaccardSimilarity calculates the Jaccard similarity between two term sets. Returns a value between 0 (no overlap) and 1 (identical).

Types

This section is empty.

Jump to

Keyboard shortcuts

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