llm
Download
47 lines 1.2 KiBGroffModified 2026-08-31 raw
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
'\" t
.\" Copyright (c) 2026 Bruce Hill
.\" All rights reserved.
.\"
.TH Text.distance 3 2026-08-30 "Tomo man-pages"
.SH NAME
Text.distance \- distance between two texts
.SH LIBRARY
Tomo Standard Library
.SH SYNOPSIS
.nf
.BI Text.distance\ :\ func(a:\ Text,\ b:\ Text\ ->\ Num)
.fi
.SH DESCRIPTION
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.


.SH ARGUMENTS

.TS
allbox;
lb lb lbx
l l l.
Name	Type	Description
a	Text	The first text to compare. 
b	Text	The second text to compare. 
.TE
.SH RETURN
The distance between the two texts (larger means more dissimilar).

.SH NOTES
The exact distance algorithm is not specified and may be subject to change over time.

.SH EXAMPLES
.EX
assert "hello".distance("hello") == 0
texts := &["goodbye", "hello", "hallo"]
texts.sort(func(a,b:Text) a.distance("hello") <> b.distance("hello"))
assert texts == ["hello", "hallo", "goodbye"]
assert "kitten".distance("sitting") == 3
assert "flaw".distance("lawn") == 2
# A transposition costs one edit, even when the texts differ in length:
assert "ab".distance("ba") == 1
assert "xab".distance("ba") == 2
.EE
.SH SEE ALSO
.BR Tomo-Text (3)