Python “regex” module: Fuzziness value

前端 未结 2 1468
温柔的废话
温柔的废话 2021-01-13 23:11

I\'m using the \"fuzzy match\" functionality of the Regex module.

How can I get the \"fuzziness value\" of a \"match\" which indicates how different the pattern is

2条回答
  •  既然无缘
    2021-01-14 00:10

    a = regex.match('(?:foo){e}','for')
    a.fuzzy_counts 
    

    this returns a tuple (x,y,z) where:

    x = number of substitutions

    y = number of insertions and

    z = number of deletions

    But this is not always a reliable count, ie: the regex match fuzziness night not equate to the true Levinstein distance in some cases

    Python regex module fuzzy match: substitution count not as expected

提交回复
热议问题