我已经下载了双变音功能:https ://github.com/dracos/double-metaphone
它应该像这样工作:
>>> dm(u'aubrey')
('APR', '')
>>> dm(u'richard')
('RXRT', 'RKRT')
>>> dm(u'katherine') == dm(u'catherine')
True
如何将变量传递给该函数?你总是在路上。我需要能够做到
dm(x)==dm(y)
现在这就是发生的事情:
>>> x='wal mart'
>>> y='wall mart'
>>> dm(x)==dm(y)
Traceback (most recent call last):
File "<pyshell#35>", line 1, in <module>
dm(x)==dm(y)
File "<pyshell#18>", line 6, in dm
st = ''.join((c for c in unicodedata.normalize('NFD', st) if unicodedata.category(c) != 'Mn'))
TypeError: normalize() argument 2 must be unicode, not str