kifield/kifield.py
def lc_get_close_matches(lbl, possibilities, num_matches=3, cutoff=0.6):
    """Return list of closest matches to lbl from possibilities (case-insensitive)."""

    # Strip any non-strings so str.lower() doesn't crash.
    possibilities = [p for p in possibilities if isinstance(p, basestring)]

    if USING_PYTHON2:
        lc_lbl = str.lower(unicode(lbl))
        lc_possibilities = [str.lower(unicode(p)) for p in possibilities]
    else:
        lc_lbl = str.lower(lbl)
        lc_possibilities = [str.lower(p) for p in possibilities]
    lc_matches = get_close_matches(lc_lbl, lc_possibilities, num_matches, cutoff)
    return [possibilities[lc_possibilities.index(m)] for m in lc_matches]
Return list of closest matches to lbl from possibilities (case-insensitive).
Return list of closest matches to lbl from possibilities (case-insensitive).
Return list of closest matches to lbl from possibilities ( case - insensitive ) .
def lc_get_close_matches(lbl, possibilities, num_matches=3, cutoff=0.6):
    possibilities = [p for p in possibilities if isinstance(p, basestring)]
    if USING_PYTHON2:
        lc_lbl = str.lower(unicode(lbl))
        lc_possibilities = [str.lower(unicode(p)) for p in possibilities]
    else:
        lc_lbl = str.lower(lbl)
        lc_possibilities = [str.lower(p) for p in possibilities]
    lc_matches = get_close_matches(lc_lbl, lc_possibilities, num_matches, cutoff)
    return [possibilities[lc_possibilities.index(m)] for m in lc_matches]
def lc_get_close_matches ( lbl , possibilities , num_matches = 3 , cutoff = 0.6 ) : possibilities = [ p for p in possibilities if isinstance ( p , basestring ) ] if USING_PYTHON2 : lc_lbl = str . lower ( unicode ( lbl ) ) lc_possibilities = [ str . lower ( unicode ( p ) ) for p in possibilities ] else : lc_lbl = str . lower ( lbl ) lc_possibilities = [ str . lower ( p ) for p in possibilities ] lc_matches = get_close_matches ( lc_lbl , lc_possibilities , num_matches , cutoff ) return [ possibilities [ lc_possibilities . index ( m ) ] for m in lc_matches ]
Return list of closest matches to lbl from possibilities (case-insensitive).
Return list of closest matches to lbl from possibilities ( case - insensitive ) .
"""Return list of closest matches to lbl from possibilities (case-insensitive).""" # Strip any non-strings so str.lower() doesn't crash.
lbl
possibilities
num_matches
cutoff