模糊前男友的奇怪行为

2024-10-01 00:21:57 发布

您现在位置:Python中文网/ 问答频道 /正文

我试图用fuzzyfuzzy来纠正文本中拼写错误的名字。但是我得不到工艺提取以及工艺提取酮按照我期望的方式行事。在

from fuzzywuzzy import process

the_text = 'VICTOR HUGO e MARIANA VEIGA'
search_term = 'VEYGA'

the_text = the_text.split()
found_word = process.extract(search_term, the_text)

print(found_word)

这将导致:

^{pr2}$

我怎样才能让fuzzyfuzzy正确识别“VEIGA”作为正确的回答?在


Tags: thetext文本search方式名字processword
1条回答
网友
1楼 · 发布于 2024-10-01 00:21:57

您可以尝试使用:fuzz.token_set_比率或者fuzz.token_sort_比率 这里的答案是:When to use which fuzz function to compare 2 strings给出了一个很好的解释。在

对于completes,这里有一些代码:

from fuzzywuzzy import process
from fuzzywuzzy import fuzz

the_text = 'VICTOR HUGO e MARIANA VEIGA'
search_term = 'VEYGA'

the_text = the_text.split()
found_word = process.extract(search_term, the_text, scorer=fuzz.token_sort_ratio)

print(found_word)

输出:

[('VEIGA',80),('e',33),('HUGO',22),('VICTOR',18),('MARIANA',17)]

相关问题 更多 >