Skip to content

Commit

Permalink
Merge pull request #5 from EFFLUX110/feature/issues1
Browse files Browse the repository at this point in the history
Added features
  • Loading branch information
adityamangal1 authored Oct 12, 2021
2 parents cb05ea5 + 85654c1 commit 371b5f3
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 9 deletions.
Binary file modified db.sqlite3
Binary file not shown.
Binary file removed db.sqlite3-shm
Binary file not shown.
Binary file removed db.sqlite3-wal
Binary file not shown.
54 changes: 45 additions & 9 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,26 +3,62 @@
Purpose - Python mini project
Date - 18 october 2020
'''
from termcolor import cprint
import re
from nltk.util import pr
from termcolor import cprint,colored
from chatterbot import ChatBot
from chatterbot.trainers import ChatterBotCorpusTrainer
import text2emotion as te
import time

chatbot = ChatBot('Bot')
trainer = ChatterBotCorpusTrainer(chatbot)
available='\nAvailable languages >> \nbengali, chinese, english, french, german, hebrew, hindi, indonesian, italian,japanese, korean, marathi,\n oriya, persian, portuguese, russian, spanish, swedish, telugu, thai, traditionalchinese, turkish'
print(colored(available,'yellow'))
while True:
language=input("\n\nIn which language do you want to start the conversation ? >> ").lower()
if language in available:
break
else:
print(f"Sorry {language} language is not available,\n please select from the above list.")
trainer.train(f'chatterbot.corpus.{language}')

trainer.train('chatterbot.corpus.english')
def get_emoji(query):
emotion=te.get_emotion(query)
# taking list of emotion values in v
v = list(emotion.values())
# taking list of emotion keys in v
k = list(emotion.keys())

emotion=k[v.index(max(v))] # Getting user's emotion

emotion_dict={'Happy': '😊', 'Angry': '😠', 'Surprise': '😯', 'Sad': '😟', 'Fear': '😨'}
emoji=emotion_dict.get(f'{emotion}') # Getting emoji of the emotion

return emoji

if __name__ == "__main__":
cprint("#" * 50, "magenta")
cprint((f"A Chatot ").center(50), "yellow")
cprint("#" * 50, "magenta")

print('You can exit by type exit\n')
cprint("#" * 80, "magenta")
cprint((f" \ ___| | | | | ").center(50), "yellow")
cprint((f" _ \ | __ \ _` | __| __ \ _ \ __| ").center(50), "yellow")
cprint((f" ___ \ _____| | | | | ( | | | | ( | | ").center(50), "yellow")
cprint((f" _/ _\ \____|_| |_| \__._| \__| _.__/ \___/ \__| ").center(50), "yellow")
cprint("#" * 80, "magenta")

print('You can exit by typing exit or bye\n')
name=input("Enter your name:")
cprint((f"Start Chatting").center(20), "yellow")
print()

while True:
query = input(">> ")
if 'exit' in query:
query = input(colored(f" {name}>> ",'red'))
if 'exit' in query.lower() or 'bye' in query.lower():
print(colored("Bot>> Bye :) See you soon.....",'green'))
exit()
else:
print(chatbot.get_response(query))
if language.lower()=='english':
emoji=get_emoji(query)
print(colored(f"Bot>> {chatbot.get_response(query)} [{emoji} ]",'green'))
else:
print(colored(f"Bot>> {chatbot.get_response(query)}",'green'))
Binary file modified requirements.txt
Binary file not shown.

0 comments on commit 371b5f3

Please sign in to comment.