Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

trigram-similarity

StephanGeorg98.3kMIT1.0.7

Determining the similarity of alphanumeric text based on trigram matching

trigram, trigrams, trigram similarity, text similarity, similarity matching, ngram, n-grams

readme

trigram-similarity npm version

The trigram-similarity module provides functions and operators for determining the similarity of alphanumeric text based on trigram matching. This is the JavaScript implementation of Postgres pg_trgm and returns a number that indicates how similar the two arguments are.

The range of the result is zero (indicating that the two strings are completely dissimilar) to one (indicating that the two strings are identical).

If you want to learn more about the concept see this post.

Installation

npm i trigram-similarity

Usage

import trigramSimilarity from 'trigram-similarity';
const similarity = trigramSimilarity('Chateau blanc', 'chateau cheval blanc');
// 0.7368421052631579