Skip to content
This repository was archived by the owner on Aug 26, 2024. It is now read-only.

NameError: name 'ratio' is not defined #329

Description

@DivanshuTak

While running the Fuzzy Wuzzy process.extract() method the following error is thrown :-

    matches = fw_process.extract(
../../.local/share/virtualenvs/proj-NKfiPrkj/lib/python3.8/site-packages/fuzzywuzzy/process.py:168: in extract
    return heapq.nlargest(limit, sl, key=lambda i: i[1]) if limit is not None else \
/usr/lib/python3.8/heapq.py:563: in nlargest
    result = [(key(elem), i, elem) for i, elem in zip(range(0, -n, -1), it)]
/usr/lib/python3.8/heapq.py:563: in <listcomp>
    result = [(key(elem), i, elem) for i, elem in zip(range(0, -n, -1), it)]
../../.local/share/virtualenvs/proj-NKfiPrkj/lib/python3.8/site-packages/fuzzywuzzy/process.py:117: in extractWithoutOrder
    score = scorer(processed_query, processed)
../../.local/share/virtualenvs/proj-NKfiPrkj/lib/python3.8/site-packages/fuzzywuzzy/fuzz.py:276: in WRatio
    base = ratio(p1, p2)
../../.local/share/virtualenvs/proj-NKfiPrkj/lib/python3.8/site-packages/fuzzywuzzy/utils.py:38: in decorator
    return func(*args, **kwargs)
../../.local/share/virtualenvs/proj-NKfiPrkj/lib/python3.8/site-packages/fuzzywuzzy/utils.py:29: in decorator
    return func(*args, **kwargs)
../../.local/share/virtualenvs/proj-NKfiPrkj/lib/python3.8/site-packages/fuzzywuzzy/utils.py:47: in decorator
    return func(*args, **kwargs)
../../.local/share/virtualenvs/proj-NKfiPrkj/lib/python3.8/site-packages/fuzzywuzzy/fuzz.py:28: in ratio
    return utils.intr(100 * m.ratio())
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <fuzzywuzzy.StringMatcher.StringMatcher object at 0x7f115ab32160>

    def ratio(self):
        if not self._ratio:
>           self._ratio = ratio(self._str1, self._str2)
E           NameError: name 'ratio' is not defined


I found that pinning the python-Levenshtein version to 0.12.2 solve the issue.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions