similar
Graded comparison as a generalization of exact equality: where = returns a boolean, the core ~ operator returns a score in [0,1] plus evidence, and a decision policy maps the score to :match / :review / :no-match bands. This module owns the operator's backing — the predicate constructor, string/phonetic/token/numeric/temporal scorers, and normalizers delegated to ft's tokenization pipeline. Constructs go graded by being handed a predicate: join, distinct, group-by, contains, sort, and validate accept one in their options map; a [similar …] result reads truthy in a boolean position iff band=:match. Thresholds are caller-supplied and never baked in.
similar:predicate
[$similar:predicate] -> element — Build a similarity-predicate value from an options map: scorer, normalizers, per-field weights, decision cuts, tolerance/scale, and known-verdict resolutions.
[?lib 'cx-stdlib/similar']
[$similar:score-of [~ "acme corp" "corp acme" [$similar:predicate {score: :token-set}]]]
1.0
similar:score
[$similar:score] -> float — Apply one named scorer directly to a pair of values and return the raw score in [0,1], with no banding.
[?lib 'cx-stdlib/similar']
[$similar:score :levenshtein "flaw" "lawn"]
0.5
similar:similarity-to
[$similar:similarity-to] -> element — Build the sort key spec that ranks values by nearness to a reference — similarity is relational, so sort requires one (nearest first).
[?lib 'cx-stdlib/similar']
[$sort ("acme corp", "globex", "acme inc") {by: [$similar:similarity-to "acme"]}]
('acme inc', 'acme corp', 'globex')
similar:score-of
[$similar:score-of] -> float — Read the score off a [similar …] comparison report.
[?lib 'cx-stdlib/similar']
[$similar:score-of [~ "acme" "acme"]]
1.0
similar:band-of
[$similar:band-of] -> any — Read the decision band off a [similar …] comparison report — :match, :review, or :no-match (absent for a predicate built with no decide policy).
[?lib 'cx-stdlib/similar']
[$similar:band-of [~ "acme" "acme"]]
:match