code / tomo

Lines41.3K C23.7K Markdown9.7K YAML5.0K Tomo2.3K
7 others 763
Python231 Shell230 make212 INI47 Text21 SVG16 Lua6
(43 lines)
1 '\" t
2 .\" Copyright (c) 2026 Bruce Hill
3 .\" All rights reserved.
4 .\"
5 .TH Text.distance 3 2026-02-08 "Tomo man-pages"
6 .SH NAME
7 Text.distance \- distance between two texts
8 .SH LIBRARY
9 Tomo Standard Library
10 .SH SYNOPSIS
11 .nf
12 .BI Text.distance\ :\ func(a:\ Text,\ b:\ Text,\ language:\ Text\ =\ "C"\ ->\ Num)
13 .fi
14 .SH DESCRIPTION
15 Get an approximate distance between two texts, such that when the distance is small, the texts are similar and when the distance is large, the texts are dissimilar.
18 .SH ARGUMENTS
20 .TS
21 allbox;
22 lb lb lbx lb
23 l l l l.
24 Name Type Description Default
25 a Text The first text to compare. -
26 b Text The second text to compare. -
27 language Text The ISO 639 language code for which character width to use. "C"
28 .TE
29 .SH RETURN
30 The distance between the two texts (larger means more dissimilar).
32 .SH NOTES
33 The exact distance algorithm is not specified and may be subject to change over time.
35 .SH EXAMPLES
36 .EX
37 assert "hello".distance("hello") == 0
38 texts := &["goodbye", "hello", "hallo"]
39 texts.sort(func(a,b:&Text) a.distance("hello") <> b.distance("hello"))
40 assert texts == ["hello", "hallo", "goodbye"]
41 .EE
42 .SH SEE ALSO
43 .BR Tomo-Text (3)