Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AttributeError: module 'fuzzywuzzy' has no attribute 'ratio'

I am trying to call ratio() function from the library fuzzywuzzy to match two string and get the following error message:

AttributeError: module 'fuzzywuzzy' has no attribute 'ratio'

Has the version changed? I tried to look for other functions within fuzz to see if it exists, but I am unable to find it.

import fuzzywuzzy as fuzz
from fuzzywuzzy import process
import Levenshtein
fuzz.ratio('Lord of the Rings', 'The Lord of the Rings')
like image 606
sharp Avatar asked Oct 14 '25 14:10

sharp


2 Answers

ratio is a method of fuzzywuzzy.fuzz. Use:

from fuzzywuzzy import fuzz

Then you can use:

fuzz.ratio('Lord of the Rings', 'The Lord of the Rings')
like image 64
Jab Avatar answered Oct 18 '25 21:10

Jab


Change import to:

from fuzzywuzzy as fuzz
from fuzzywuzzy import process
like image 38
kosist Avatar answered Oct 18 '25 21:10

kosist



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!