匹配工具

正则

糢糊匹配

工具

  1. thefuzz (python >=3.7)

  2. RapidFuzz

  3. 编辑距离

  4. difflib

  5. regex 三方库

thefuzz 和 fuzzywuzzy

问题

empty query 修复

参考:https://stackoverflow.com/a/63490931

问题描述:

FuzzyWuzzy error: WARNING:root:Applied processor reduces input query to empty string, all comparisons will have score 0. [Query: '/']

修复方法:

1
2
3
4
5
6
7
from fuzzywuzzy import utils

invalid_query = " ... // "

if utils.full_process(invalid_query): # 先判断是否为 empty
    # wont execute and not produce a warning
    process.extract(invalid_query, patterns)