Skip to main content
Deno 2 is finally here 🎉️
Learn more
Module

std/text/mod.ts>compareSimilarity

Deno standard library
Go to Latest
The Standard Library has been moved to JSR. See the blog post for details.
function compareSimilarity
import { compareSimilarity } from "https://deno.land/std@0.211.0/text/mod.ts";

Sort based on word similarity

Examples

Example 1

import { compareSimilarity } from "https://deno.land/std@0.211.0/text/compare_similarity.ts";
const words = ["hi", "hello", "help"];

// words most-similar to "hep" will be at the front
words.sort(compareSimilarity("hep"));

Parameters

givenWord: string
optional
options: { caseSensitive?: boolean; }

Returns

(a: string, b: string) => number