Skip to content

Instantly share code, notes, and snippets.

@schaunwheeler
Created March 6, 2019 21:11
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 schaunwheeler/0e290c355b456d59d3614a67c540d2b9 to your computer and use it in GitHub Desktop.
Save schaunwheeler/0e290c355b456d59d3614a67c540d2b9 to your computer and use it in GitHub Desktop.
Data science productionization: portability - example 2
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