字符三元模糊集。

charactertrigramfuzzyset的Python项目详细描述


基于余弦相似度的字符三元模糊集实现 模糊匹配。

这个库在字符串的iterables上做一件事任何超越 那-列文施泰因距离,得分,大逆转等等-作为一个 向读者练习

用法

importos.pathfromtimeitimporttimeitimportrequests# Retrieve a file containing around 470,000 English wordsurl='https://github.com/dwyl/english-words/raw/master/words.txt'r=requests.get(url,stream=True)words_path=os.path.expanduser('~/words.txt')ifnotos.path.isfile(words_path):withopen(words_path,'wb')asf:forchunkinr.iter_content(chunk_size=1024):ifchunk:f.write(chunk)# Usageimportcharactertrigramfuzzysetasctfsitems=[line.rstrip()forlineinopen(words_path,'r')]fs=ctfs.CharacterTrigramFuzzySet(items)fs.get('bryan')# Profiling, generally around 10-20 ms per call on my machinetimeit("fs.get('bryan')",setup='''
import charactertrigramfuzzyset as ctfs
items = [line.rstrip() for line in open('{words_path}', 'r')]
fs = ctfs.CharacterTrigramFuzzySet(items)
'''.format(words_path=words_path),number=1000)

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
Spring 4升级后未加载java应用程序上下文   java Android 2.3.3 internet可以在我的Galaxy S上运行,但不能在我的Galaxy选项卡上运行?(许可?)   java通过不改变其原始位置对大小写字母进行排序   java Spring Boot一直在破坏我的电脑。。。sts的最佳配置是什么。Windows 10上的ini文件?   css Java Spring+引导问题   java Jackson将GeoJsonPoint序列化为纬度/经度   xml Java Transformer:如何将其结果生成OutputStream?   java如何更改字体、文本大小和设置文本位置?   在JavaSpringHibernate3.6.3中,如何告诉一个方法等待,直到获得锁,以及如何重试失败的事务?   java安卓服务代替线程   Java Swing使用鼠标移动JFrame