mirror of
https://github.com/kaiyuran/Emoji-translator-Server.git
synced 2025-02-16 18:22:07 +00:00
Compare commits
No commits in common. "ca65d941567e054cb2ed73bf3cdd0c39c9d099c0" and "8790133b2770aa34c0aadc7f0a6782d8e9a39ffa" have entirely different histories.
ca65d94156
...
8790133b27
4 changed files with 12 additions and 136 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -10,4 +10,3 @@ docs/_build/
|
||||||
dist/
|
dist/
|
||||||
venv/
|
venv/
|
||||||
.venv
|
.venv
|
||||||
tempCodeRunnerFile.py
|
|
||||||
|
|
|
@ -1,4 +0,0 @@
|
||||||
#Emojify Server
|
|
||||||
This is a simple server that takes a string as input and returns the string with emojis. The server is written in Python and uses Flask as the web framework and I am running this on Hackclub's nest server.
|
|
||||||
|
|
||||||
I have added a bunch of emojis manually but in the future I plan to use AI to predict the emojis based on the text.
|
|
139
app.py
139
app.py
|
@ -5,12 +5,6 @@ import random
|
||||||
def emojify(message):
|
def emojify(message):
|
||||||
|
|
||||||
choiceWordDict = {
|
choiceWordDict = {
|
||||||
"hello": "👋",
|
|
||||||
"hi": "👋",
|
|
||||||
"hey": "👋",
|
|
||||||
"greetings": "👋",
|
|
||||||
"goodbye": "👋",
|
|
||||||
|
|
||||||
#happy face
|
#happy face
|
||||||
"happy": "😊",
|
"happy": "😊",
|
||||||
"joy": "😊",
|
"joy": "😊",
|
||||||
|
@ -181,114 +175,8 @@ def emojify(message):
|
||||||
"fruit": "🍉",
|
"fruit": "🍉",
|
||||||
"refreshing": "🍉",
|
"refreshing": "🍉",
|
||||||
"summer": "🍉",
|
"summer": "🍉",
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
"eggplant": "🍆",
|
|
||||||
"aubergine": "🍆",
|
|
||||||
"banana": "🍌",
|
|
||||||
"peach": "🍑",
|
|
||||||
"cherries": "🍒",
|
|
||||||
"strawberry": "🍓",
|
|
||||||
"tomato": "🍅",
|
|
||||||
"avocado": "🥑",
|
|
||||||
"broccoli": "🥦",
|
|
||||||
"carrot": "🥕",
|
|
||||||
"corn": "🌽",
|
|
||||||
"cucumber": "🥒",
|
|
||||||
"lettuce": "🥬",
|
|
||||||
"mushroom": "🍄",
|
|
||||||
"pepper": "🌶️",
|
|
||||||
"hotpepper": "🌶️",
|
|
||||||
"potato": "🥔",
|
|
||||||
"sweetpotato": "🍠",
|
|
||||||
"croissant": "🥐",
|
|
||||||
"baguette": "🥖",
|
|
||||||
"pretzel": "🥨",
|
|
||||||
"cheese": "🧀",
|
|
||||||
"egg": "🥚",
|
|
||||||
"bacon": "🥓",
|
|
||||||
"pancakes": "🥞",
|
|
||||||
"poultryleg": "🍗",
|
|
||||||
"chicken": "🍗",
|
|
||||||
"meat": "🍖",
|
|
||||||
"bacon": "🥓",
|
|
||||||
|
|
||||||
"sad": "😢",
|
|
||||||
"angry": "😡",
|
|
||||||
"mad": "😡",
|
|
||||||
"fury": "😡",
|
|
||||||
"rage": "😡",
|
|
||||||
"disgust": "🤢",
|
|
||||||
"sick": "🤢",
|
|
||||||
"vomit": "🤢",
|
|
||||||
"gross": "🤢",
|
|
||||||
"nausea": "🤢",
|
|
||||||
"unhappy": "😞",
|
|
||||||
"depressed": "😞",
|
|
||||||
"miserable": "😞",
|
|
||||||
"gloomy": "😞",
|
|
||||||
"despair": "😞",
|
|
||||||
"spy": "🕵️",
|
|
||||||
"detective": "🕵️",
|
|
||||||
"sleuth": "🕵️",
|
|
||||||
"investigate": "🕵️",
|
|
||||||
"search": "🕵️",
|
|
||||||
"inspect": "🕵️",
|
|
||||||
"dance": "💃",
|
|
||||||
"dancer": "💃",
|
|
||||||
"ballerina": "💃",
|
|
||||||
"tango": "💃",
|
|
||||||
"dancing": "🕺",
|
|
||||||
"twin": "👯",
|
|
||||||
"sisters": "👯",
|
|
||||||
"twins": "👯",
|
|
||||||
"ballet": "🩰",
|
|
||||||
"pointeshoes": "🩰",
|
|
||||||
"balletshoes": "🩰",
|
|
||||||
"shoes": "👟",
|
|
||||||
"heels": "👠",
|
|
||||||
"finish": "🏁",
|
|
||||||
"sign": "🚩",
|
|
||||||
"leaf": "🍃",
|
|
||||||
"plant": "🌱",
|
|
||||||
"flower": "🌸",
|
|
||||||
"blossom": "🌸",
|
|
||||||
"rose": "🌹",
|
|
||||||
"tulip": "🌷",
|
|
||||||
"sunflower": "🌻",
|
|
||||||
"daisy": "🌼",
|
|
||||||
"hibiscus": "🌺",
|
|
||||||
"work": "🏢",
|
|
||||||
"office": "🏢",
|
|
||||||
"building": "🏢",
|
|
||||||
"construction": "🏗️",
|
|
||||||
"site": "🏗️",
|
|
||||||
"school": "🏫",
|
|
||||||
"university": "🏫",
|
|
||||||
"college": "🏫",
|
|
||||||
"hospital": "🏥",
|
|
||||||
"clinic": "🏥",
|
|
||||||
"doctor": "👩⚕️",
|
|
||||||
"nurse": "👩⚕️",
|
|
||||||
"therapist": "👩⚕️",
|
|
||||||
"healthcare": "👩⚕️",
|
|
||||||
"police": "👮",
|
|
||||||
"cop": "👮",
|
|
||||||
"law": "👮",
|
|
||||||
"enforcement": "👮",
|
|
||||||
"officer": "👮",
|
|
||||||
"movie": "🎥",
|
|
||||||
"film": "🎥",
|
|
||||||
"camera": "🎥",
|
|
||||||
"movies": "🎥",
|
|
||||||
"cinema": "🎥",
|
|
||||||
"theater": "🎭",
|
|
||||||
"drama": "🎭",
|
|
||||||
"acting": "🎭",
|
|
||||||
"perform": "🎭",
|
|
||||||
}
|
}
|
||||||
puncList = [".",",","!","?",";", "'", '"', ":"]
|
|
||||||
message = message.strip('"')
|
message = message.strip('"')
|
||||||
message = message.strip("'")
|
message = message.strip("'")
|
||||||
finalMessage = []
|
finalMessage = []
|
||||||
|
@ -297,12 +185,9 @@ def emojify(message):
|
||||||
for word in message:
|
for word in message:
|
||||||
try:
|
try:
|
||||||
formWord = word.lower()
|
formWord = word.lower()
|
||||||
done = False
|
if formWord[-1] == ".":
|
||||||
for punctuation in puncList:
|
finalMessage.append(word[:-1] + (choiceWordDict[formWord[:-1]] * random.randint(1,3)) +".")
|
||||||
if formWord[-1] == punctuation:
|
else:
|
||||||
finalMessage.append(word[:-1] + (choiceWordDict[formWord[:-1]] * random.randint(1,3)) +punctuation)
|
|
||||||
done = True
|
|
||||||
if not done:
|
|
||||||
finalMessage.append(word + choiceWordDict[word.lower()])
|
finalMessage.append(word + choiceWordDict[word.lower()])
|
||||||
|
|
||||||
|
|
||||||
|
@ -316,21 +201,19 @@ def emojify(message):
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
app = Flask(__name__)
|
app = Flask(__name__)
|
||||||
CORS(app)
|
CORS(app)
|
||||||
|
|
||||||
#if __name__ == "__main__":
|
|
||||||
# app.run(host='0.0.0.0', port=33303)
|
|
||||||
|
|
||||||
|
|
||||||
@app.route('/getemoji', methods=['GET'])
|
@app.route('/getemoji', methods=['GET'])
|
||||||
# @cross_origin()
|
|
||||||
def get_random_emoji():
|
def get_random_emoji():
|
||||||
# Get the 'letter' parameter from the URL
|
# Get the 'letter' parameter from the URL
|
||||||
message = request.args.get('message')
|
message = request.args.get('message')
|
||||||
print(message)
|
print(message)
|
||||||
|
|
||||||
|
|
||||||
final = emojify(message)
|
final = emojify(message)
|
||||||
# print(final)
|
# print(final)
|
||||||
final = jsonify({"message": final})# emoji in JSON format
|
final = jsonify({"message": final})# emoji in JSON format
|
||||||
|
@ -339,6 +222,4 @@ def get_random_emoji():
|
||||||
return final
|
return final
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
#app.run(debug=True)
|
app.run(debug=True)
|
||||||
# app.run(port=33303)
|
|
||||||
app.run(host='0.0.0.0', port=33303)
|
|
|
@ -1,7 +1,7 @@
|
||||||
import requests
|
import requests
|
||||||
|
|
||||||
url = "http://127.0.0.1:33303/getemoji"
|
url = "http://127.0.0.1:5000/getemoji"
|
||||||
# url = "http://37.27.51.34:33303/getemoji"
|
|
||||||
params = {
|
params = {
|
||||||
"message": "I love chocolate donuts. I laugh at funny jokes about it. I think it is amazing."
|
"message": "I love chocolate donuts. I laugh at funny jokes about it. I think it is amazing."
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue