Last active
October 7, 2019 18:46
-
-
Save xpe/85899a3ad361a3881aed7e75275ba9fa to your computer and use it in GitHub Desktop.
Use this when your phrases need numeronyms!
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 abbreviate(phrase): | |
def shorten(w, t=7): | |
if len(w) <= t: | |
return w | |
else: | |
return "{}{}{}".format(w[0], len(w)-2, w[-1]) | |
return " ".join([shorten(w) for w in phrase.split(" ")]) | |
abbreviate("The Heilmeier Catechism demands a thoughtful approach to risk taking") | |
# 'The H7r C7m demands a t8l a6h to risk taking' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
https://en.wikipedia.org/wiki/Numeronym