Rabbinatix
Sign inGet started
Store

Word similarity

FreeLogic
@rabbinatix/word-similarity by Rabbinatixupdated Oct 4, 2026

How alike two words are, from 0 to 1, e.g. to suggest "did you mean…?".

Sign in to add

The edit distance (Levenshtein) is a nested loop over two strings, which is short in code and long as a graph, so it is a Custom Code node. The rest stays a graph: similarity is 1 − distance / longer length.

Exported code calls deps.code.levenshtein({ a, b }); implement it in your app, for example in TypeScript:

levenshtein: async ({ a, b }) => {
  let prev = Array.from({ length: b.length + 1 }, (_, j) => j);
  for (let i = 1; i <= a.length; i++) {
    const cur = [i];
    for (let j = 1; j <= b.length; j++) cur[j] = Math.min(prev[j] + 1, cur[j - 1] + 1, prev[j - 1] + (a[i - 1] === b[j - 1] ? 0 : 1));
    prev = cur;
  }
  return prev[b.length];
}

In Python, rapidfuzz.distance.Levenshtein.distance(a, b) gives the same number; in C#, Fastenshtein's Levenshtein.Distance(a, b); in Java, Apache Commons Text's LevenshteinDistance.getDefaultInstance().apply(a, b).

Shows: Custom Code, Maximum, Divide.

How to use it

Add it to your logic, then add a Call Function step in any logic and pick Word similarity. It belongs to no system, so every system can use it. Or download the TypeScript and call it from your own code.

Inputs
a: Text
b: Text
Outputs
similarity: Number
distance: Whole number
Previewdrag the steps around; scroll to zoom
Function Entry, Input / output. 0 inputs, 3 outputs. step 1 of 10
Word similarity
a
b
Custom Code, Functions. 2 inputs, 1 output. step 2 of 10
levenshtein()
a
b
result
String Length, String. 1 input, 1 output. step 3 of 10
String Length
text
length
String Length, String. 1 input, 1 output. step 4 of 10
String Length
text
length
Maximum, Math. 2 inputs, 1 output. step 5 of 10
Maximum
a
b
result
Maximum, Math. 2 inputs, 1 output. step 6 of 10
Maximum
a
b
result
Divide, Operators. 2 inputs, 1 output. step 7 of 10
/
A
B
result
Subtract, Operators. 2 inputs, 1 output. step 8 of 10
-
A
B
result
Round, Math. 2 inputs, 1 output. step 9 of 10
Round
value
decimals
result
Return, Input / output. 3 inputs, 0 outputs. step 10 of 10
Return
similarity
distance

Arrow keys: next or previous step in flow order. Alt with arrows: nearest step in that direction. Enter: open. Shift F10: more actions.

100%
Examplesrun live against the logic · 0/0 pass
PassedExampleInputOutput
Try it
Versions
In this package
Word similarity (entry)