stringMatch {MiscPsycho}R Documentation

Implementation of the Levenshtein Algorithm

Description

Function to compare the similarity of two different character strings

Usage

stringMatch(string.1, string.2, normalize = c("YES", "NO"), penalty = 1, case.sensitive = FALSE)

Arguments

string.1 The first character string
string.2 The second character string
normalize a character string indicating which method to use; if normalize = 'YES', then the edit distance is normalized to fall in the interval [0,1]
penalty The edit cost
case.sensitive logical; if TRUE, then a penalty occurs for differences in case of a character

Value

a numeric value. If normalize = 'YES", then the edit distance is normalized to fall in the interval [0,1]. Else, the Levenshtein edit distance is returned.

Author(s)

Harold C. Doram

References

http://en.wikipedia.org/wiki/Levenshtein_distance

Examples

## Return edit distance
stringMatch('William Clinton', 'Bill Clinton', normalize='NO')

## Return normalized edit distance
stringMatch('William Clinton', 'Bill Clinton', normalize='YES')

## Ignore differences in case
stringMatch('Bill Clinton', 'bill Clinton', normalize='YES', case.sensitive = FALSE)

## Do not ignore differences in case
stringMatch('Bill Clinton', 'bill Clinton', normalize='YES', case.sensitive = TRUE)

[Package MiscPsycho version 1.3 Index]