Ghmustafa11/EmojiMagic
0
1import streamlit as st2 3# Define a dictionary mapping words to emojis4emoji_mapping = {5 "happy": "๐",6 "sad": "๐ข",7 "love": "โค๏ธ",8 "angry": "๐ก",9 "sun": "โ๏ธ",10 "star": "โญ",11 "fire": "๐ฅ",12 "cool": "๐",13 "cat": "๐ฑ",14 "dog": "๐ถ",15}16 17# Function to convert text to emojis18def text_to_emoji(text):19 words = text.split()20 converted_text = []21 for word in words:22 # Replace word with emoji if it exists in the mapping23 converted_text.append(emoji_mapping.get(word.lower(), word))24 return " ".join(converted_text)25 26# Streamlit UI27st.title("Text to Emoji Converter")28st.write("Convert your sentences into emojis! Type some text below and see the magic. ๐")29 30# User input31user_input = st.text_input("Enter your text here:", placeholder="e.g., I am happy and love the sun!")32 33# Convert and display the result34if user_input:35 output = text_to_emoji(user_input)36 st.write("### Converted Text:")37 st.write(output)38 st.write("โจ Enjoy your emojis!")39 40st.write("---")41st.write("Built with โค๏ธ using [Streamlit](https://streamlit.io/) and hosted on [Hugging Face Spaces](https://huggingface.co/spaces).")42 