fuzzy

package module
v0.0.0-...-08c5a58 Latest Latest
Warning

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

Go to latest
Published: Nov 9, 2024 License: GPL-3.0 Imports: 2 Imported by: 1 module, 1 package

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.

README

Fuzzy

Fuzzy is a Go library for performing fuzzy matching on strings. The primary function provided by this library is Match(), which compares a target string against a list of candidate strings and returns matches sorted by their similarity to the target string.

Features

  • Compute similarity scores for string matches.
  • Return matches sorted by similarity score.
  • Provide detailed information for each match, including:
    • The original string from the list.
    • The similarity score.
    • The number of insertions, deletions, and substitutions needed.
    • The position of the match in the provided list.

Usage

package main

import (
    "fmt"
    "github.com/stevegt/fuzzy"
)

func main() {
    target := "example"
    candidates := []string{"samples", "examples", "simple", "examine"}
    
    matches := fuzzy.Match(target, candidates)
    
    for _, match := range matches {
        fmt.Printf("String: %s, Score: %f, Insertions: %d, Deletions: %d, Substitutions: %d, Position: %d\n",
            match.Original, match.Score, match.Insertions, match.Deletions, match.Substitutions, match.Position)
    }
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type MatchResult

type MatchResult struct {
	Original      string
	Score         float64
	Insertions    int
	Deletions     int
	Substitutions int
	Position      int
}

MatchResult represents a single match, including similarity details.

func Match

func Match(target string, candidates []string) []MatchResult

Match takes a target string and a list of candidate strings and returns all matches sorted by their similarity score.

Jump to

Keyboard shortcuts

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