strutil

package
v0.1.6 Latest Latest
Warning

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

Go to latest
Published: Mar 5, 2023 License: BSD-3-Clause Imports: 5 Imported by: 0

Documentation

Overview

Package strutil contains string-related utility functions.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Normalize

func Normalize(orig string) string

Normalize normalizes characters using NFKD form. Unicode characters are decomposed (runes are broken into their components) and replaced for compatibility equivalence (characters that represent the same characters but have different visual representations, e.g. '9' and '⁹', are equal). Characters are also de-accented. TODO: Maybe go farther and e.g. replace smart quotes with dumb quotes?

Types

type Edits

type Edits struct{ Ins, Dels, Subs int }

Edits holds information about edits needed to transform one string into another.

func Levenshtein

func Levenshtein(as, bs string) Edits

Levenshtein computes the Levenshtein distance between a and b using the Wagner–Fischer algorithm. It's based on pseudocode from https://en.wikipedia.org/wiki/Wagner%E2%80%93Fischer_algorithm.

func (Edits) Dist

func (e Edits) Dist() int

Dist returns the Levenshtein distance (i.e. total number of edits).

Jump to

Keyboard shortcuts

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