Questions tagged «difflib»

2
Python中的高性能模糊字符串比较,使用Levenshtein或difflib
已关闭。这个问题是基于观点的。它当前不接受答案。 想改善这个问题吗?更新问题,以便通过编辑此帖子以事实和引用的形式回答。 4年前关闭。 改善这个问题 我正在进行临床消息标准化(拼写检查),其中我对照900,000个单词的医学词典检查每个给定的单词。我更关心时间的复杂性/性能。 我想进行模糊字符串比较,但是不确定使用哪个库。 选项1: import Levenshtein Levenshtein.ratio('hello world', 'hello') Result: 0.625 选项2: import difflib difflib.SequenceMatcher(None, 'hello world', 'hello').ratio() Result: 0.625 在此示例中,两者给出相同的答案。您是否认为在这种情况下两者表现都一样?
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.