mirror of
https://github.com/kaiyuran/Emoji-translator-Server.git
synced 2024-11-24 01:53:39 +00:00
fix punctuation handling
This commit is contained in:
parent
d9edc071c6
commit
c9c29ffeec
1 changed files with 43 additions and 6 deletions
49
app.py
49
app.py
|
@ -5,6 +5,12 @@ import random
|
|||
def emojify(message):
|
||||
|
||||
choiceWordDict = {
|
||||
"hello": "👋",
|
||||
"hi": "👋",
|
||||
"hey": "👋",
|
||||
"greetings": "👋",
|
||||
"goodbye": "👋",
|
||||
|
||||
#happy face
|
||||
"happy": "😊",
|
||||
"joy": "😊",
|
||||
|
@ -253,8 +259,36 @@ def emojify(message):
|
|||
"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("'")
|
||||
finalMessage = []
|
||||
|
@ -263,9 +297,12 @@ def emojify(message):
|
|||
for word in message:
|
||||
try:
|
||||
formWord = word.lower()
|
||||
if formWord[-1] == ".":
|
||||
finalMessage.append(word[:-1] + (choiceWordDict[formWord[:-1]] * random.randint(1,3)) +".")
|
||||
else:
|
||||
done = False
|
||||
for punctuation in puncList:
|
||||
if formWord[-1] == punctuation:
|
||||
finalMessage.append(word[:-1] + (choiceWordDict[formWord[:-1]] * random.randint(1,3)) +punctuation)
|
||||
done = True
|
||||
if not done:
|
||||
finalMessage.append(word + choiceWordDict[word.lower()])
|
||||
|
||||
|
||||
|
@ -303,5 +340,5 @@ def get_random_emoji():
|
|||
|
||||
if __name__ == '__main__':
|
||||
#app.run(debug=True)
|
||||
app.run(port=33303)
|
||||
# app.run(host='0.0.0.0', port=33303)
|
||||
# app.run(port=33303)
|
||||
app.run(host='0.0.0.0', port=33303)
|
Loading…
Reference in a new issue