python 模糊匹配_简单易用的字符模糊匹配FuzzyWuzz-Python实用工具推荐

aee5fcc4c82e3cc66dfc3e2b92d14634.png

项目:FuzzyWuzzy

作者:seatgeek

GitHubhttps://github.com/seatgeek/fuzzywuzzy

简介:这是一个简单易用的模糊字符串匹配工具包,采用 Levenshtein Distance 算法来计算两个序列之间的差异,使用起来非常简单。

环境依赖

  • Python 2.7 or higher
  • difflib
  • python-Levenshtein (optional, provides a 4-10x speedup in String Matching, though may result in differing results for certain cases)

支持的测试三方库

  • pycodestyle
  • hypothesis
  • pytest

安装方法

  1. 通过PyPI安装
1pip install fuzzywuzzy23# or the following to install python-Levenshtein too4pip install fuzzywuzzy[speedup]
  1. 通过GitHub安装
1pip install git+git://github.com/seatgeek/fuzzywuzzy.git@0.17.0#egg=fuzzywuzzy23# Adding to your requirements.txt file (run pip install -r requirements.txt afterwards)4git+ssh://git@github.com/seatgeek/fuzzywuzzy.git@0.17.0#egg=fuzzywuzzy
  1. 通过GIT安装
1git clone git://github.com/seatgeek/fuzzywuzzy.git fuzzywuzzy2cd fuzzywuzzy3python setup.py install

使用

 1# 导入 2from fuzzywuzzy import fuzz 3from fuzzywuzzy import process 4 5# 简单匹配 6fuzz.ratio("this is a test