You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
# Python 3.6.8
# CPU: Intel i7-9750H @ 2.60 GHz
import timeit
from profanity import profanity as pf
from better_profanity import profanity as bpf
# Let the 2 packages use the same list of profane words
pf.load_words(bpf.CENSOR_WORDSET)
def benchmark(func, text: str):
return func(text)
if __name__ == "__main__":
test_str = "<a 1000-word text here>"
regex_runtime = timeit('benchmark(pf.censor, test_str)', globals=globals(), number=1)
current_runtime = timeit('benchmark(bpf.censor, test_str)', globals=globals(), number=1)
print(f"Regex: {regex_runtime}")
print(f"Current: {current_runtime}")
which has the following output:
# in seconds
Regex: 26.9981138
Current: 0.0000009468
Instead of generating distorted profane words from the list of profane words, can't we use regex?
The text was updated successfully, but these errors were encountered: