字符三元模糊集。

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从xml文件中删除标记属性   HashMap的java自定义键   java ListView在目录中显示文件时出错   JavaSpring建议:代理机制与类或接口上的@Transactional   java我对th有问题:如果在春天   是否有任何API或网站可以对我的Java代码进行颜色编码并将其转换为html?   java从资产中的文本文件中读取两次,扫描仪不带缓冲读取器   java是否可以将RestHighLevelClient与假定角色一起使用?   java在java8流中下载文件的有效方法   具有多对一映射的java kafka流左连接   带循环的java灰度/渐变   用Java创建CAB文件   java取代了JTable的组合框编辑器   与Websocket的java连接   JavaSpringBootSecurity不会重定向对configure(httpsecurityhttp)方法的oauth/authorize调用   java Spring注入变量为null   java Restlet无法处理json   java中的函数未完成   用java实现带记录文件的排序