字符三元模糊集。

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第三方库


热门话题
java为什么javaassist仅在项目中使用lambda时加载Entitymanager时抛出无效的常量类型:18   java如何识别用户是否在Alexa中首次启动技能?   java maven:如何防止插件更新   java StringBuilder将null追加为“null”   在java中,我可以在画布上绘制画布吗?   java如何在JRadioButton上垂直对齐文本和图像?   java“类是对象的集合”。这个定义是对的还是错的?   java如何用其他字符替换字符串中的1个或多个字符?   Java的HashSet<Double>及其子集的hashcode的唯一性   对象ArrayList的java并发修改错误   多线程Java线程:让EDT函数等待长时间运行的函数离开EDT   java如何重写方法,将一个实例变量和一个局部变量相加,从而生成一个数据类型为Double的新变量?