Created
February 27, 2019 20:33
-
-
Save talfco/6ceb8413978f39d37a2ada1d3c91ce16 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
from metaphone import doublemetaphone | |
from enum import Enum | |
class Threshold(Enum): | |
WEAK = 0 | |
NORMAL = 1 | |
STRONG = 2 | |
def double_metaphone(value): | |
print(doublemetaphone(value)) | |
return doublemetaphone(value) | |
#(Primary Key = Primary Key) = Strongest Match | |
#(Secondary Key = Primary Key) = Normal Match | |
#(Primary Key = Secondary Key) = Normal Match | |
#(Alternate Key = Alternate Key) = Minimal Match | |
def double_metaphone_compare(tuple1,tuple2,threshold): | |
if threshold == Threshold.WEAK: | |
if tuple1[1] == tuple2[1]: | |
return True | |
elif threshold == Threshold.NORMAL: | |
if tuple1[0] == tuple2[1] or tuple1[1] == tuple2[0]: | |
return True | |
else: | |
if tuple1[0] == tuple2[0]: | |
return True | |
return False |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment