Last active
May 22, 2021 19:34
-
-
Save Navjotbians/09cf80d48626885a3e0d39857a058447 to your computer and use it in GitHub Desktop.
Clean comment
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import re | |
import string | |
def clean(input_str): | |
input_str = input_str.lower() | |
for sub in SUBSTITUTIONS: | |
input_str = re.sub(sub[0], sub[1], input_str) | |
# Eliminate punchuation | |
input_str = input_str.translate(str.maketrans('','', string.punctuation)) | |
input_str = input_str.strip() | |
return input_str |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment