Fuzzy Matching

This page describes the parameters for the Fuzzy Matching method as part of AI libs.

.ai.fuzzy.dist

The .ai.fuzzy.dist function calculates the fuzzy distance between parameters.

Parameters

Name

Type(s)

Description

data

string | string[] | enum

The strings to search against

q

string | string[]

The query string(s)

metric

symbol

The distance type, one of .ai.fuzzy.utils.fuzzyDistances

Returns

Type

Description

float

The fuzzy distance between x and y

Example

q

Copy
 genString:{[length] length?.Q.an," "};
 batch:genString each 5 + 10?10;
 q:genString[5 + rand[10]];
 .ai.fuzzy.dist[batch;q;`levenshtein];
 14 12 12 14 13 14 14 14 14 13f

.ai.fuzzy.search

The .ai.fuzzy.search function returns k best matches for q from data.

Parameters

Name

Type(s)

Description

data

string[] | symbol[]

The list of strings/symbols to search from

q

string | string[] | symbol | symbol[]

The pattern to search for

k

int | long

The number of best matches to return

metric

symbol

The distance type, one of .ai.fuzzy.utils.fuzzyDistances

Returns

Type

Description

(float[]; int[]; (char | string | symbol)[])

A list of triples containing distance, index and match value

Example

q

Copy
 genString:{[length] length?.Q.an," "};
 batch:genString each 5 + 10?10;
 q:genString[5 + rand[10]];
 .ai.fuzzy.search[batch;q;3;`levenshtein];
 12               12       13         
 2                1        4          
 "6SmcKLSCuEI9n8" "ynEr5x" "TtNEiYH_c"