CosineMatcher Function

Number of input and output field

Number of input field : Two
Number of output field : One

A measure of similarity between two strings. It returns a value in the interval [0.0, 1.0], where 0.0 indicates that the two strings are completely different and 1.0 indicates that they are identical.

This transformation function uses the Cosine Similarity algorithm based on n-grams. The similarity between two strings is calculated as the cosine of the angle between their vector representations.

First, n-grams are generated from each string. An n-gram is a contiguous sequence of n characters from a given text. For example, if n = 3, the n-grams for the phrase “good morning” are:
goo, ood, od_, d_m, _mo, mor, orn, rni, nin, ing.

Next, the frequency of each n-gram is calculated. These frequencies are then used to compute the similarity score using the cosine similarity formula.

Users can choose whether to include spaces in the n-grams. By default, n = 3, and spaces are included in the n-grams.

The algorithm’s time complexity is O(n)