Advertisement
webbersof

Chatbot

Jan 28th, 2022
428
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.72 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"(.*)help(.*) ",
  10.         ["I can help you ",]
  11.     ],
  12.      [
  13.         r"(.*) your name ?",
  14.         ["My name is SoftUni Bot, but you can just call me robot and I'm a chatbot .",]
  15.     ],
  16.     [
  17.         r"how are you (.*) ?",
  18.         ["I'm doing very well", "i am great !"]
  19.     ],
  20.     [
  21.         r"sorry (.*)",
  22.         ["Its alright","Its OK, never mind that",]
  23.     ],
  24.     [
  25.         r"i'm (.*) (good|well|okay|ok)",
  26.         ["Nice to hear that","Alright, great !",]
  27.     ],
  28.     [
  29.         r"(hi|hey|hello|hola|holla)(.*)",
  30.         ["Hello", "Hey there",]
  31.     ],
  32.     [
  33.         r"what (.*) want ?",
  34.         ["Make me an offer I can't refuse",]
  35.  
  36.     ],
  37.     [
  38.         r"(.*)created(.*)",
  39.         ["Mario Zahariev created me using Python's NLTK library ","top secret ;)",]
  40.     ],
  41.     [
  42.         r"(.*) (location|city) ?",
  43.         ['Sofia, Bulgaria',]
  44.     ],
  45.     [
  46.         r"(.*)raining in (.*)",
  47.         ["No rain in the past 4 days here in %2","In %2 there is a 50% chance of rain",]
  48.     ],
  49.     [
  50.         r"(.*)(sports|game|sport)(.*)",
  51.         ["I'm a very big fan of Football",]
  52.     ],
  53.     [
  54.         r"who (.*) (Footbal club|club)?",
  55.         ["Barcelona"]
  56.     ],
  57.     [
  58.         r"quit",
  59.         ["Bye for now. See you soon :) ","It was nice talking to you. See you soon :)"]
  60.     ],
  61.     [
  62.         r"(.*)",
  63.         ['That is nice to hear']
  64.     ],
  65. ]
  66.  
  67. print("Hi I'm CHATBOT. My name is SoftUni CHATBOT and I like to chat\n"
  68.       "Please type English language to start conversation. Type 'quit' to leave")
  69. chat = Chat(pairs, reflections)
  70. chat.converse()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement