webbersof

Chatbot

May 25th, 2022
841
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.54 KB | None | 0 0
  1. from nltk.chat.util import Chat, reflections
  2.  
  3. pairs = [
  4.     [
  5.         r"(.*)my name is (.*)",
  6.         ["Hello %2, How are you today ?"]
  7.     ],
  8.     [
  9.         r"(.*) your name ?",
  10.         ["My name is SoftUni BOT, but you can just call me robot and I'm a chatbot .", ]
  11.     ],
  12.     [
  13.         r'what is the phone number of the SoftUni(.*)?',
  14.         ['9:00 - 19:30 (Понеделник - Петък) \n8:30 - 18:00 (Събота и Неделя) \nТелефон: +359899 55 55 92 \nИмейл: '
  15.          '[email protected]']
  16.     ],
  17.     [
  18.         r"what is python(.*) ?",
  19.         ["Python is an interpreted, object-oriented, high-level programming language with dynamic semantics"]
  20.     ],
  21.  
  22.     [
  23.         r"i'm (.*) (good|well|okay|ok)",
  24.         ["Nice to hear that, how can I help you?"]
  25.     ],
  26.     [
  27.         r"(hi|hey|hello|hola|holla)(.*)",
  28.         ["Hello", "Hey there", ]
  29.     ],
  30.     [
  31.         r"(.*)created(.*)",
  32.         ["Mario Zahariev created me using Python's NLTK library "]
  33.     ],
  34.     [
  35.         r"(.*) (location|city) ?",
  36.         ['Sofia, Bulgaria', ]
  37.     ],
  38.     [
  39.         r"quit",
  40.         ["Bye for now. See you soon :) ", "It was nice talking to you. See you soon :)"]
  41.     ],
  42.     [
  43.         r"(.*)",
  44.         ['That is nice to hear']
  45.     ],
  46. ]
  47.  
  48. #default message at the start of chat
  49. print("Please type lowercase English language to start a conversation. "
  50.       "Type quit to leave.\n\nHi, I'm SoftUni BOT...\nWhat is your name?")
  51.  
  52. #Create Chat Bot
  53. chat = Chat(pairs, reflections)
  54. #Start conversation
  55. chat.converse()
Advertisement
Add Comment
Please, Sign In to add comment