VLC 4.0.0-dev
Loading...
Searching...
No Matches
jaro_winkler.c File Reference
Include dependency graph for jaro_winkler.c:

Macros

#define MAX(a, b)
#define MIN(a, b)

Functions

static size_t split_on_common_prefix (const char *a, const char *b)
 Checks both strings for a common prefix, returning the number of matching bytes.
static int jaro_inner (const char *a, const char *b, size_t *ret_prefix_cc, float *res)
 This is the inner Jaro algorithm, with a parameter for passing back the length of the prefix common to both strings, used for efficiency of the Jaro-Winkler implementation.
int vlc_jaro_winkler (const char *a, const char *b, float *res)
 Calculate a “Jaro Winkler” metric.

Macro Definition Documentation

◆ MAX

#define MAX ( a,
b )
Value:
( ((a) > (b)) ? (a) : (b) )

Referenced by jaro_inner(), and vlc_select().

◆ MIN

#define MIN ( a,
b )
Value:
( ((a) < (b)) ? (a) : (b) )

Referenced by jaro_inner().

Function Documentation

◆ jaro_inner()

int jaro_inner ( const char * a,
const char * b,
size_t * ret_prefix_cc,
float * res )
inlinestatic

This is the inner Jaro algorithm, with a parameter for passing back the length of the prefix common to both strings, used for efficiency of the Jaro-Winkler implementation.

References MAX, MIN, and split_on_common_prefix().

Referenced by vlc_jaro_winkler().

◆ split_on_common_prefix()

size_t split_on_common_prefix ( const char * a,
const char * b )
inlinestatic

Checks both strings for a common prefix, returning the number of matching bytes.

Referenced by jaro_inner().

◆ vlc_jaro_winkler()

int vlc_jaro_winkler ( const char * a,
const char * b,
float * res )

Calculate a “Jaro Winkler” metric.

Algorithm: http://en.wikipedia.org/wiki/Jaro%E2%80%93Winkler_distance

Like “Jaro” but gives a boost to strings that have a common prefix.

Note
: This implementation does not place a limit the common prefix length adjusted for.
Parameters
astring A
bstring B
res[OUT] a pointer to a float to receive the result
Returns
-1 on memory allocation failure, otherwise 0

References jaro_inner().

Referenced by config_LoadCmdLine().