def ratcliff_obershelp_similarity(a, b):
"""
A kind of approximate string matching.
Computes the generalized Ratcliff/Obershelp similarity of two strings
as the number of matching characters divided by the total number of characters in the two strings.
Matching characters are those in the longest common subsequence plus,
recursively matching characters in the unmatched region on either side of the longest common subsequence.
"""
if a and b:
return SequenceMatcher(None, a, b).ratio()
else:
return None
评论列表
文章目录