Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeError: sentence must be a String #57

Closed
b1337xyz opened this issue Aug 29, 2023 · 2 comments
Closed

TypeError: sentence must be a String #57

b1337xyz opened this issue Aug 29, 2023 · 2 comments

Comments

@b1337xyz
Copy link

from thefuzz import process

query = "ishida to asakura"
choices = [('ishida to asakura special', 'Ishida to Asakura Special', 'None', '1'), ('sengoku musou sp sanada no shou', 'Sengoku Musou SP Sanada no Shou', 'None', '1'), ('nanocore sp lianxi pian 2015 xinnian tebie ban', 'Nanocore SP Lianxi Pian 2015 Xinnian Tebie Ban', 'None', '1'), ('shakugan no shana koi to onsen no kougai gakushuu', 'Shakugan no Shana Koi to Onsen no Kougai Gakushuu', 'None', '1'), ('baki most evil death row convicts special anime', 'Baki Most Evil Death Row Convicts Special Anime', 'None', '1')]

out = [
    i[0] for i in process.extract(
        query, choices, limit=len(choices)
    ) if i[1] >= 90
]
Traceback (most recent call last):
  File "/tmp/test.py", line 7, in <module>
    i[0] for i in process.extract(
                  ^^^^^^^^^^^^^^^^
  File "/tmp/venv/lib/python3.11/site-packages/thefuzz/process.py", line 187, in extract
    return extractBests(query, choices, processor=processor, scorer=scorer, limit=limit)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/tmp/venv/lib/python3.11/site-packages/thefuzz/process.py", line 214, in extractBests
    results = rprocess.extract(
              ^^^^^^^^^^^^^^^^^
  File "src/rapidfuzz/process_cpp_impl.pyx", line 988, in rapidfuzz.process_cpp_impl.extract
  File "src/rapidfuzz/process_cpp_impl.pyx", line 887, in rapidfuzz.process_cpp_impl.extract_list
  File "src/rapidfuzz/process_cpp_impl.pyx", line 807, in rapidfuzz.process_cpp_impl.extract_list_f64
  File "src/rapidfuzz/process_cpp_impl.pyx", line 232, in rapidfuzz.process_cpp_impl.preprocess_list
  File "/tmp/venv/lib/python3.11/site-packages/thefuzz/process.py", line 30, in wrapper
    return utils.full_process(processor(s))
                              ^^^^^^^^^^^^
  File "/tmp/venv/lib/python3.11/site-packages/thefuzz/utils.py", line 22, in full_process
    return _default_process(s)
           ^^^^^^^^^^^^^^^^^^^
  File "src/rapidfuzz/utils_cpp.pyx", line 28, in rapidfuzz.utils_cpp.default_process
TypeError: sentence must be a String
(venv) $ pip freeze
rapidfuzz==3.2.0
thefuzz==0.20.0
@maxbachmann
Copy link
Contributor

This is a regression in my implementation from #10. I wrote a quick fix for this in #58. Note that your code relies on the preprocessing function calling str on all your objects so you are comparing ishida to asakura with ishida to asakura special ishida to asakura special none 1. Not sure whether that is done on purpose.

@b1337xyz
Copy link
Author

b1337xyz commented Aug 29, 2023

Note that your code relies on the preprocessing function calling str on all your objects

Did not know about that, thought it only compared the first object.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants