Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added features #5

Merged
merged 2 commits into from
Oct 12, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.