Search Apps Documentation Source Content File Folder Download Copy Actions Download State String Boolean Number Struct Map Slice Pointer Function Closure Reference Nil Package Type Interface Unknown

levenshtein package

Overview

Package levenshtein ports the classic Levenshtein edit-distance algorithm (as found in Go libraries like agext/levenshtein) to a gno.land realm.

The core is the textbook dynamic-programming matrix: the minimum number of single-character insertions, deletions, or substitutions to turn string a into string b. It is fully rune-aware and pure (deterministic), so it runs happily on-chain.

Function

Similarity

func Similarity(a, b string) int

Similarity returns a 0..100 percentage of how similar a and b are, defined as (1 - distance/maxLen) * 100 rounded to the nearest integer. Two empty strings are considered 100% similar.

Params

Command

gnokey query vm/qeval -remote "https://rpc.topaz.testnets.gno.land" -data "gno.land/r/g12cs4cehujpffpjpywmkqj43m6u5ya53nj69sjz/levenshtein.Similarity(,)"

Result