Table of Contents
Description
This module provides functions for performing fuzzy matching on strings.
Basic Usage
JavaScript Reference
fuzzyMatch(str1, str2)
Performs a fuzzy match between two strings and returns a score between 0 and 10.
import { fuzzyMatch } from './src/utils/fuzzyMatch.js';
const score = fuzzyMatch('example', 'exampel');
console.log(score); // Outputs a score between 0 and 10
Parameters:
str1
(string): The first string to match against.str2
(string): The second string to match.
Returns: (number): A score between 0 and 10 indicating the strength of the match.
fuzzyMatchArray(array, targetString)
Calculates the average non-zero fuzzy match score of a target string against an array of strings.
import { fuzzyMatchArray } from './src/utils/fuzzyMatch.js';
const averageScore = fuzzyMatchArray(['example', 'sample', 'exampel'], 'exampel');
console.log(averageScore); // Outputs the average non-zero score
Parameters:
array
(Array<string>): An array of strings to match against.targetString
(string): The string to match.
Returns: (number): The average non-zero match score.