viligen

emoji_detector

Nov 28th, 2021
711
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import re
  2.  
  3. text = input()
  4.  
  5. pattern = r"(::|\*\*)([A-Z][a-z]{2,})\1"
  6. threshold = 1
  7. coolness = 0
  8. counter = 0
  9. cool_emojis = []
  10. digits_match = re.findall(r"\d", text)
  11. for digit in digits_match:
  12.     threshold *= int(digit)
  13.  
  14. emoji_matches = re.finditer(pattern, text)
  15. for emoji in emoji_matches:
  16.     counter += 1
  17.     coolness = sum([ord(s) for s in emoji.group(2)])
  18.     if coolness > threshold:
  19.         cool_emojis.append(emoji.group(0))
  20. print(f"Cool threshold: {threshold}")
  21. print(f"{counter} emojis found in the text. The cool ones are:")
  22. print('\n'.join(cool_emojis))
  23.  
RAW Paste Data