VLC 4.0.0-dev
jaro_winkler.c File Reference
Include dependency graph for jaro_winkler.c:

Macros

#define MAX(a, b)   ( ((a) > (b)) ? (a) : (b) )
 
#define MIN(a, b)   ( ((a) < (b)) ? (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. More...
 
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. More...
 
int vlc_jaro_winkler (const char *a, const char *b, float *res)
 Calculate a “Jaro Winkler” metric. More...
 

Macro Definition Documentation

◆ MAX

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

◆ MIN

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

Function Documentation

◆ jaro_inner()

static 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()

static 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 on 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().