Created
January 18, 2019 05:47
-
-
Save MLWhiz/ea1dc8bac11bf256565f0015d0771d93 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| mispell_dict = {'colour': 'color', 'centre': 'center', 'favourite': 'favorite', 'travelling': 'traveling', 'counselling': 'counseling', 'theatre': 'theater', 'cancelled': 'canceled', 'labour': 'labor', 'organisation': 'organization', 'wwii': 'world war 2', 'citicise': 'criticize', 'youtu ': 'youtube ', 'Qoura': 'Quora', 'sallary': 'salary', 'Whta': 'What', 'narcisist': 'narcissist', 'howdo': 'how do', 'whatare': 'what are', 'howcan': 'how can', 'howmuch': 'how much', 'howmany': 'how many', 'whydo': 'why do', 'doI': 'do I', 'theBest': 'the best', 'howdoes': 'how does', 'mastrubation': 'masturbation', 'mastrubate': 'masturbate', "mastrubating": 'masturbating', 'pennis': 'penis', 'Etherium': 'Ethereum', 'narcissit': 'narcissist', 'bigdata': 'big data', '2k17': '2017', '2k18': '2018', 'qouta': 'quota', 'exboyfriend': 'ex boyfriend', 'airhostess': 'air hostess', "whst": 'what', 'watsapp': 'whatsapp', 'demonitisation': 'demonetization', 'demonitization': 'demonetization', 'demonetisation': 'demonetization'} | |
| def _get_mispell(mispell_dict): | |
| mispell_re = re.compile('(%s)' % '|'.join(mispell_dict.keys())) | |
| return mispell_dict, mispell_re | |
| mispellings, mispellings_re = _get_mispell(mispell_dict) | |
| def replace_typical_misspell(text): | |
| def replace(match): | |
| return mispellings[match.group(0)] | |
| return mispellings_re.sub(replace, text) | |
| # Usage | |
| replace_typical_misspell("Whta is demonitisation") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment