vzhou842 / profanity-check

A fast, robust Python library to check for offensive language in strings.
https://pypi.org/project/profanity-check
MIT License
612 stars 114 forks source link

KeyError: 0 #34

Closed Jourdelune closed 2 years ago

Jourdelune commented 3 years ago

Hello, I have an error when I launch the program, However I execute this code which should not contain any error /home/pi/.local/lib/python3.7/site-packages/sklearn/linear_model/randomized_l1.py:580: DeprecationWarning: `np.float` is a deprecated alias for the builtin `float`. To silence this warning, use `float` by itself. Doing this will not modify any behavior and is safe. If you specifically wanted the numpy scalar type, use `np.float64` here. Deprecated in NumPy 1.20; for more details and guidance: https://numpy.org/devdocs/release/1.20.0-notes.html#deprecations eps=4 * np.finfo(np.float).eps, n_jobs=None, Traceback (most recent call last): File "/home/pi/NewBot/profany.py", line 2, in <module> from profanity_check import predict, predict_prob File "/home/pi/.local/lib/python3.7/site-packages/profanity_check/__init__.py", line 1, in <module> from .profanity_check import predict, predict_prob File "/home/pi/.local/lib/python3.7/site-packages/profanity_check/profanity_check.py", line 6, in <module> model = joblib.load(pkg_resources.resource_filename('profanity_check', 'data/model.joblib')) File "/home/pi/.local/lib/python3.7/site-packages/joblib/numpy_pickle.py", line 585, in load obj = _unpickle(fobj, filename, mmap_mode) File "/home/pi/.local/lib/python3.7/site-packages/joblib/numpy_pickle.py", line 504, in _unpickle obj = unpickler.load() File "/usr/lib/python3.7/pickle.py", line 1085, in load dispatch[key[0]](self) KeyError: 0


from profanity_check import predict, predict_prob

predict(['predict() takes an array and returns a 1 for each string if it is offensive, else 0.'])
# [0]

predict(['fuck you'])
# [1]

predict_prob(['predict_prob() takes an array and returns the probability each string is offensive'])
# [0.08686173]

predict_prob(['go to hell, you scum'])```