Created
March 13, 2019 19:51
-
-
Save luismond/74ec1ddaf341ccbe6808da28485cd68f to your computer and use it in GitHub Desktop.
Strip punctuation function
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
| def strip_punct(line): | |
| line = str(line) | |
| charset = set() | |
| for ch in line: | |
| charset.update(ch) | |
| punct = [ch for ch in charset if not ch.isalpha()] | |
| if ' ' in punct: | |
| punct.remove(' ') | |
| for ch in punct: | |
| line = line.replace(ch, ' ').lower() | |
| line = line.replace(' ', ' ').lower() | |
| return line |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment