Class: Trigram

Trigram()

Represents a Trigram algorithm for string comparison.

Constructor

new Trigram()

Source:

Methods

(static) generateTrigrams(inputString) → {array}

Generates a list of trigrams (3-character subsequences) from the given input string.

Parameters:
Name Type Description
inputString string

The input string to generate trigrams from.

Source:
Returns:
  • An array of trigrams extracted from the input string.
Type
array

(static) similarity(string1, string2) → {float}

Calculates the similarity between two strings based on the Jaccard similarity coefficient of their trigram sets.

Parameters:
Name Type Description
string1 string

The first string for comparison.

string2 string

The second string for comparison.

Source:
Returns:
  • The Jaccard similarity coefficient between the trigram sets of the two strings, ranging from 0.0 (no similarity) to 1.0 (perfect similarity).
Type
float