Skip to content

Instantly share code, notes, and snippets.

@talfco
Created February 27, 2019 21:35
Show Gist options
  • Save talfco/0476b9e68ca57bda60af227441cf6221 to your computer and use it in GitHub Desktop.
Save talfco/0476b9e68ca57bda60af227441cf6221 to your computer and use it in GitHub Desktop.
# -*- coding: utf-8 -*-
import re
import unicodedata
def normalize_unicode_to_ascii(data):
normal = unicodedata.normalize('NFKD', data).encode('ASCII', 'ignore')
val = normal.decode("utf-8")
val = val.lower()
# remove special characters
val = re.sub('[^A-Za-z0-9 ]+', ' ', val)
# remove multiple spaces
val = re.sub(' +', ' ', val)
return val
def sort_words(words):
words = words.split(" ")
words.sort()
newSentence = " ".join(words)
return newSentence
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment