实现功能:
中文模糊匹配,支持拼音,支持模糊拼音
从string中匹配match_string
支持的模糊音有:
1. 声母模糊音:s <–> sh,c<–>ch,z <–>zh
2. 韵母模糊音:an<–>ang,en<–>eng,in<–>ing
代码结构
def chinese_fuzzy_match(match_string, string, use_fuzzy=True):
中文模糊匹配
def py_full_math(match_ls, str_ls):
检查拼音字符串是否匹配"
def py_fuzzy_format(py_ls):
格式化模糊拼音
测试
string = '人工智能与大数据'
match = '人工只能'
print("%s ==> %s" % (match, string))
print(chinese_fuzzy_match(match, string))
# print('not_match: ', chinese_fuzzy_match(match, string, use_fuzzy=False))
match = '人工智障'
print("%s ==> %s" % (match, string))
print(chinese_fuzzy_match(match, string))
项目使用
在输入作者的名字时,用户可以只需要输入作者的拼音名字谐音,就可以返回一个所有满足该读音的作者列表,供用户自己选择。