Created
March 6, 2019 21:11
-
-
Save schaunwheeler/0e290c355b456d59d3614a67c540d2b9 to your computer and use it in GitHub Desktop.
Data science productionization: portability - example 2
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
STOPCHARS = ['a', 'b', 'c', 'd'] | |
def normalize_word(word, stops=None): | |
word = word.strip().lower() | |
if stops: | |
word = ''.join([char for char in word if char not in stops]) | |
return word | |
normalize_word('abracadabra', STOPCHARS) | |
> 'rr' | |
normalize_word('HocusPocus ', STOPCHARS) | |
> 'houspous' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment