相关疑难解决方法(0)

Python中的模糊字符串比较,与使用哪个库相混淆

我想做模糊字符串比较,但与使用哪个库混淆.

选项1:

import Levenshtein
Levenshtein.ratio('hello world', 'hello')

Result: 0.625
Run Code Online (Sandbox Code Playgroud)

选项2:

import difflib
difflib.SequenceMatcher(None, 'hello world', 'hello').ratio()

Result: 0.625
Run Code Online (Sandbox Code Playgroud)

在这个例子中,两者给出了相同的答案.但我更喜欢使用__CODE__.专家的任何建议.谢谢.

__CODE__

我正在进行临床信息规范化(拼写检查),其中我检查每个给定的单词对900,000字的医学词典.我更关注时间复杂度/性能.

在这种情况下,你认为两者都表现相似吗?

python string-matching difflib levenshtein-distance

119
推荐指数
2
解决办法
6万
查看次数

无法在Windows Python 3.5上安装Levenshtein distance软件包

我需要安装python Levenshtein距离包才能使用这个库.不幸的是,我无法成功安装它.我通常用pip安装库.但是,这次我得到error: [WinError 2] The system cannot find the file specified了之前从未发生过的事情(安装库时).我试图使用它安装它,python setup.py install但我得到完全相同的错误.这是我从控制台获得的输出.

C:\Users\my_user\Anaconda3\Lib\site-packages\python-Levenshtein-0.10.2>python setup.py install
running install
running bdist_egg
running egg_info
writing dependency_links to python_Levenshtein.egg-info\dependency_links.txt
writing namespace_packages to python_Levenshtein.egg-info\namespace_packages.txt
writing entry points to python_Levenshtein.egg-info\entry_points.txt
writing python_Levenshtein.egg-info\PKG-INFO
writing top-level names to python_Levenshtein.egg-info\top_level.txt
writing requirements to python_Levenshtein.egg-info\requires.txt
reading manifest file 'python_Levenshtein.egg-info\SOURCES.txt'
reading manifest template 'MANIFEST.in'
warning: no files found matching '*' under directory 'docs'
warning: no previously-included files matching '*pyc' found anywhere in …
Run Code Online (Sandbox Code Playgroud)

pip python-3.x levenshtein-distance

7
推荐指数
5
解决办法
2万
查看次数