How to use the pylev.levenshtein function in pylev

To help you get started, we’ve selected a few pylev examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github toastdriven / pylev / tests.py View on Github external
def test_empty(self):
        self.assertEqual(pylev.levenshtein('', ''), 0)
github toastdriven / pylev / tests.py View on Github external
def test_same(self):
        self.assertEqual(pylev.levenshtein('kitten', 'kitten'), 0)
github toastdriven / pylev / tests.py View on Github external
def test_painful(self):
        # This is much faster than the above.
        self.assertEqual(pylev.levenshtein('CUNsperrICY', 'conspiracy'), 8)
github toastdriven / pylev / tests.py View on Github external
def test_classic(self):
        self.assertEqual(pylev.levenshtein('kitten', 'sitting'), 3)
github mharnold / spiderosm / spiderosm / cannames.py View on Github external
def levenshtein_ratio(s1, s2):
    assert len(s1) > 0 and len(s2) > 0
    return pylev.levenshtein(s1, s2) / float(max(len(s1),len(s2)))
github allenai / propara / propara / evaluation / evalQA.py View on Github external
def compare_to_gold_labels(participants, system_participants):
    ret = []
    found = False
    for p in participants:
        p = p.lower()
        if p in system_participants:
            ret.append(p)
            continue
        for g in system_participants:
            if (pylev.levenshtein(p,g) < 3):
                #print (p, "===", g)
                ret.append(g)
                found = True
        if not found:
            if p in manual_participant_map:
                ret.append(manual_participant_map[p])
            #else:
            #    print("cannot find", p, system_participants)
    return ret

pylev

A pure Python Levenshtein implementation that's not freaking GPL'd.

BSD-2-Clause
Latest version published 3 years ago

Package Health Score

67 / 100
Full package analysis