mpylab.tools.levenshtein module

Compatibility wrapper for fuzzy string comparison helpers.

New code should import from mpylab.tools.compare.

mpylab.tools.levenshtein.fstrcmp(a, possibilities, cutoff=0.0, ignorecase=True, use_rmcp=True)

fstrcmp function.

mpylab.tools.levenshtein.fstrcmp_scpi(a, possibilities, cutoff=0.0, ignorecase=True)

Token-based fuzzy matcher for SCPI commands.

The command is split at ‘:’ and each token is compared separately. Ranking prefers: 1. exact token matches 2. token prefix matches 3. token substring matches 4. best fuzzy token similarity

Example

fstrcmp_scpi(“BAND”, [“SENS:FREQ:START”, “SENS:BAND:RES”]) -> [“SENS:BAND:RES”, “SENS:FREQ:START”]

mpylab.tools.levenshtein.relative(a, b, first_must_match=True)

Computes a relative distance between two strings. It’s in the range (0-1] where 1 means total equality. @type a: string @param a: arg one @type b: string @param b: arg two @rtype: float @return: the distance

mpylab.tools.levenshtein.rmcp(seq, ignorecase=True)

remove common prefix from sequence elements