Matching incorrectly spelt words with correct ones in python

后端 未结 5 925
佛祖请我去吃肉
佛祖请我去吃肉 2021-01-01 05:36

I\'m building an app that gets incoming SMSs, then based on a keyword, it looks to see if that keyword is associated with any campaigns that it is running. The way I\'m doin

5条回答
  •  慢半拍i
    慢半拍i (楼主)
    2021-01-01 06:19

    The simplest solution is to use the difflib package, which has a get_close_matches function for approximate string matching:

    import difflib
    difflib.get_close_matches(word, possibilities)
    

提交回复
热议问题