Skip to content

Instantly share code, notes, and snippets.

@talfco
Created February 27, 2019 20:33
Show Gist options
  • Save talfco/6ceb8413978f39d37a2ada1d3c91ce16 to your computer and use it in GitHub Desktop.
Save talfco/6ceb8413978f39d37a2ada1d3c91ce16 to your computer and use it in GitHub Desktop.
# -*- 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