Advertisement
Guest User

Untitled

a guest
Sep 16th, 2019
985
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.22 KB | None | 0 0
  1. import random
  2. import sys
  3.  
  4. strings = {
  5. "2": [":battlefield-2:", ":bf2:"],
  6. "99": [":99:"],
  7. "a": [":amazon:", ":amd:", ":anarchy:", ":angular:", ":ansible:", ":arch:", ":atlassian:", ":azure:"],
  8. "actually": [":actually:"],
  9. "ati": [":ati:"],
  10. "app": [":app:"],
  11. "aws": [":aws:"],
  12. "b": [":bing:", ":bitcoin:", ":blackbaud:", ":blogger:", ":bluetooth:", ":bootstrap:", ":braintree:"],
  13. "ba": [":bart:"],
  14. "banned": [":banned_stamp:"],
  15. "bc": [":bandcamp:"],
  16. "beos": [":beos:"],
  17. "bet": [":bet:"],
  18. "butter": [":butter:"],
  19. "brick": [":brick:"],
  20. "bruh": [":bruh:"],
  21. "c": [":akamai:", ":c:"],
  22. "caltrain": [":caltrain:"],
  23. "colgate": [":bolgate:"],
  24. "co": [":bolgate-fb-1:"],
  25. "dont panic": [":calm:"],
  26. "don't panic": [":calm:"],
  27. "i": [":40:"],
  28. "lgo": [":bolgate-fb-2:"],
  29. "n": [":apple-news:"],
  30. "ninety-nine": [":99:"],
  31. "o": [":0_points:", ":alstom:", ":bepis:", ":btn:"],
  32. "oof": [":00f:"],
  33. "s": [":bash:"],
  34. "te": [":bolgate-fb-3:"],
  35. "two": [":battlefield-2:"],
  36. "two hundred": [":200:"],
  37. "v": [":bestgirlthink:"],
  38. "xd": [":adobe_xd:"],
  39. }
  40.  
  41.  
  42. def match(string):
  43. if string == None or string == "":
  44. return (None, [])
  45. elif string in strings:
  46. return (string, strings[string])
  47. else:
  48. return match(string[:-1])
  49.  
  50. def emojify(string):
  51. tokenized = string.split()
  52. emojified = []
  53.  
  54. if len(tokenized) == 0:
  55. return []
  56. elif len(tokenized) > 1:
  57. for token in tokenized:
  58. emojified += emojify(token)
  59. emojified += ' '
  60. else:
  61. token = tokenized[0]
  62. (matched, candidates) = match(token)
  63.  
  64. if not matched:
  65. emojified += token[0]
  66. emojified += emojify(token[1:])
  67. else:
  68. emojified += random.sample(candidates, 1)
  69. if matched != token:
  70. suffix = token[len(matched):]
  71. emojified += emojify(suffix)
  72.  
  73. return emojified
  74.  
  75.  
  76. if __name__ == "__main__":
  77. if len(sys.argv) != 2:
  78. print("Usage: emojifont.py <string>")
  79. exit(1)
  80.  
  81. emojified = emojify(sys.argv[1])
  82. for font in emojified:
  83. print(font, end = '')
  84. print()
  85.  
  86. pass
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement