Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yavuzKomecoglu/2f023d74417f9ecf41e91f20496f0897 to your computer and use it in GitHub Desktop.
Save yavuzKomecoglu/2f023d74417f9ecf41e91f20496f0897 to your computer and use it in GitHub Desktop.
def preprocess_word(word):
# Remove punctuation
word = word.strip('\'"?!,.():;``')
# Convert more than 2 letter repetitions to 2 letter
# funnnnny --> funny
word = re.sub(r'(.)\1+', r'\1\1', word)
# Remove - & '
word = re.sub(r'(-|\')', '', word)
return word
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment