render_example_test.gno
1.50 Kb · 33 lines
1package levenshteindemo
2
3// ExampleRender pins the realm's Render output as a gno testable example.
4func ExampleRender() {
5 print(Render(""))
6 // Output:
7 // # Levenshtein edit distance
8 //
9 // Demo of the [`p/moul/x/daily/levenshtein`](/p/nym-moultest123/x/daily/levenshtein/v0) library. The **Levenshtein distance** between two strings is the minimum number of single-character edits — *insertions*, *deletions*, or *substitutions* — needed to turn one string into the other. The library implements the classic dynamic-programming algorithm (à la Go's `agext/levenshtein`) fully rune-aware and on-chain.
10 //
11 // ## Try it
12 //
13 // Append two words as `/<a>/<b>`:
14 //
15 // - [`/kitten/sitting`](/r/nym-moultest123/x/daily/levenshteindemo/v0:kitten/sitting) → distance **3**
16 // - [`/flaw/lawn`](/r/nym-moultest123/x/daily/levenshteindemo/v0:flaw/lawn) → distance **2**
17 // - [`/sunday/saturday`](/r/nym-moultest123/x/daily/levenshteindemo/v0:sunday/saturday) → distance **3**
18 // - [`/gno/gnoland`](/r/nym-moultest123/x/daily/levenshteindemo/v0:gno/gnoland) → distance **4**
19 //
20 // ## The classic example
21 //
22 // `kitten` → `sitting` = **3**:
23 //
24 // 1. `kitten` → `sitten` (substitute *k* → *s*)
25 // 2. `sitten` → `sittin` (substitute *e* → *i*)
26 // 3. `sittin` → `sitting` (insert *g* at the end)
27 //
28 // ## API
29 //
30 // - `Distance(a, b string) int` — the edit distance.
31 // - `Matrix(a, b string) [][]int` — the full DP matrix.
32 // - `Similarity(a, b string) int` — a 0..100 similarity percentage.
33}