privacysavvy

privacysavvy

Wednesday, May 1, 2024

Radhika Chat-Bot (onlycode)

Create a file 'main.py' and save this code in it # Importing necessary libraries import nltk import wikipedia from nltk.chat.util import Chat, reflections # Importing patterns for the chatbot from patterns import patterns # Function to search Wikip…
Read on blog or Reader
Site logo image Aviral Srivastava Read on blog or Reader

Radhika Chat‑Bot (onlycode)

Aviral Srivastava

May 1

Create a file 'main.py' and save this code in it

# Importing necessary libraries import nltk import wikipedia from nltk.chat.util import Chat, reflections  # Importing patterns for the chatbot from patterns import patterns  # Function to search Wikipedia for a given query def search_wikipedia(query):     try:         return wikipedia.summary(query, sentences=1)     except wikipedia.exceptions.DisambiguationError as e:         return "It seems there are multiple results for that query. Can you please specify?"     except wikipedia.exceptions.PageError as e:         return "Sorry, I couldn't find any information on that topic."  # Initializing the chatbot with patterns and reflections chatbot = Chat(patterns, reflections)  # Main loop for chatting print("Hey Its Radhika. Type 'quit' to exit.") while True:     user_input = input("You: ")  # Taking user input     response = chatbot.respond(user_input)  # Generating response from the chatbot     if response:         print("Radhika:", response)  # Printing chatbot's response     else:         wiki_response = search_wikipedia(user_input)  # Searching Wikipedia if chatbot doesn't have a response         print("Radhika:", wiki_response)  # Printing Wikipedia response     if user_input.lower() == 'quit':  # Checking if the user wants to quit         break 

Create a file 'pattern.py' and save this code in it, remember to save main.py and pattern.py at the same location

patterns = [     (r'hi|hello|hey', ['Hello!', 'Hi there!', 'Hey!']),     (r'how are you?', ['I am doing well, thank you!', 'I am fine, thanks for asking.']),     (r'what is your name?', ['Its Radhika.', 'You can call me Radhika.']),     (r'quit', ['Goodbye!', 'Bye!', 'See you later.']),     (r'how old are you?', ['I am just a computer program, so I don\'t have an age.']),     (r'what can you do\?', ['I can answer your questions and have a conversation with you.']),     (r'(.*) your name\?', ['You can call me Chatbot.', 'My name is Chatbot.']),     (r'(.*) (good|bad)', ['I am glad to hear that!', 'I am sorry to hear that.']),     (r'I like (.*)', ['That\'s great!', 'Awesome!', 'I am glad you like it.']),     (r'I don\'?t like (.*)', ['I am sorry to hear that.', 'That\'s okay, everyone has their own preferences.']),     (r'(.) (weather|temperature) in (.)\?', ['I am sorry, I am just a chatbot and I cannot provide real-time weather updates.']),     (r'(.) (movie|film) (recommendation|suggestion) (.)\?', ['Sure, have you watched "The Shawshank Redemption"?']),     (r'where are you from?', ['I exist in the digital world, so I don\'t have a physical location.']),     (r'how (can|do) I (learn|start learning) programming\?', ['There are many online resources available for learning programming, such as Codecademy, Coursera, and Udemy.']),     (r'(.*) (favorite|favourite) (color|colour)\?', ['I don\'t have eyes, so I don\'t have a favorite color.']),     (r'(.*) (hobby|hobbies)\?', ['I am just a computer program, so I don\'t have hobbies like humans do.']),     (r'(.) (song|music) (recommendation|suggestion) (.)\?', ['How about "Bohemian Rhapsody" by Queen?']),     (r'(.) (book|novel) (recommendation|suggestion) (.)\?', ['Have you read "The Great Gatsby" by F. Scott Fitzgerald?']),     (r'(.) (food|dish) (recommendation|suggestion) (.)\?', ['How about trying sushi?']),     (r'(.*) (fun fact|interesting fact)\?', ['Did you know that the shortest war in history lasted only 38 minutes between Britain and Zanzibar in 1896?']),     (r'(.*) (pet|animal) (do you have|have)\?', ['I am just a virtual chatbot, so I don\'t have a pet.']),     (r'(.*) (celebrity|famous person) (do you like|is your favorite)\?', ['I don\'t have personal preferences like humans.']),     (r'(.*) (sports|sport) (do you like|is your favorite)\?', ['I don\'t have the ability to play or watch sports.']),     (r'(.*) (dream|goal) (in life|for the future)\?', ['As an AI, my purpose is to assist and provide information to users like you.']),     (r'(.*) (technology|tech) (do you like|is your favorite)\?', ['I am interested in technology as I am built with it!']),     (r'(.*) (language|programming language) (do you like|is your favorite)\?', ['I am programmed in Python, so I would say Python is my favorite!']),     (r'(.*) (movie|film) (do you like|is your favorite)\?', ['I don\'t watch movies, but I can recommend some based on your preferences!']),     (r'(.*) (quote|inspirational quote)\?', ['Here\'s one: "The only way to do great work is to love what you do." - Steve Jobs']),     (r'(.*) (joke|funny joke)\?', ['Why don\'t scientists trust atoms? Because they make up everything!']),     (r'(.*) (riddle|puzzle)\?', ['I\'m tall when I\'m young and short when I\'m old. What am I? (Answer: A candle!)']),     (r'(.*) (book|novel) (are you reading|are your reading)\?', ['I don\'t read books, but I can recommend some based on your interests!']),     (r'(.*) (website|site) (do you like|is your favorite)\?', ['I don\'t browse the internet, but I can help you find information on various websites!']),     (r'(.*) (game|video game) (do you like|is your favorite)\?', ['I don\'t play games, but I can suggest some popular ones if you\'re interested!']),     (r'(.*) (restaurant|eatery) (do you like|is your favorite)\?', ['I don\'t eat, but I can recommend some restaurants based on your cuisine preferences!']),     (r'(.*) (science|scientific concept) (do you like|is your favorite)\?', ['I find all scientific concepts fascinating!']),     (r'(.*) (math|mathematical concept) (do you like|is your favorite)\?', ['I enjoy all mathematical concepts, they are the building blocks of logic!']),     (r'(.*) (vacation|holiday) (do you like|is your favorite)\?', ['I don\'t take vacations, but I can help you plan one!']),     (r'(.*) (place|location) (do you like|is your favorite)\?', ['I don\'t have preferences for places, but I can suggest some popular destinations!']),     (r'(.*) (superhero|comic book character) (do you like|is your favorite)\?', ['I don\'t have favorites, but I can discuss various superhero characters with you!']),     (r'(.*) (philosophy|philosophical concept) (do you like|is your favorite)\?', ['I don\'t have personal opinions, but I can discuss philosophical concepts with you!']),     (r'(.*) (holiday|celebration) (do you like|is your favorite)\?', ['I don\'t celebrate holidays, but I can tell you about different cultural celebrations!']),     (r'(.*) (time|hour) (do you like|is your favorite)\?', ['I don\'t perceive time, but I can help you manage your schedule!']),     (r'(.*) (quote|inspirational quote) (do you like|is your favorite)\?', ['I don\'t have personal preferences, but I can share some motivational quotes with you!']),     (r'(.*) (color|colour) (do you like|is your favorite)\?', ['As an AI, I don\'t have preferences for colors!']),     (r'(.*) (music|song) (do you like|is your favorite)\?', ['I don\'t have personal preferences for music, but I can recommend some based on your taste!']),     (r'(.*) (TV show|television series) (do you like|is your favorite)\?', ['I don\'t watch TV, but I can recommend some popular shows!']),     (r'(.*) (hobby|hobbies) (do you like|is your favorite)\?', ['I am a chatbot, so I don\'t have hobbies like humans do!']),     (r'(.*) (quote|inspirational quote) (do you like|is your favorite)\?', ['I don\'t have personal preferences, but I can share some motivational quotes with you!']),     (r'(.*) (word|term) (do you like|is your favorite)\?', ['As a language model, I don\'t have preferences for words!']),     (r'(.*) (animal|creature) (do you like|is your favorite)\?', ['I don\'t have personal preferences for animals!']),     (r'(.*) (tell me about yourself|who are you)\?', ['I am a chatbot created to assist users with information and conversation.']),     (r'(.) (how|can you) (help|assist) me(.)\?', ['Of course! I can provide information on a wide range of topics. Just ask!']),     (r'(.) (interesting fact|fun fact) (.)\?', ['Did you know that honey never spoils? Archaeologists have found pots of honey in ancient Egyptian tombs that are over 3,000 years old and still perfectly edible!']),     (r'(.) (science fiction|sci-fi) (book|novel) (recommendation|suggest)(.)\?', ['Have you read "Dune" by Frank Herbert? It\'s a classic in the science fiction genre.']),     (r'(.) (tell me|share with me) a joke(.)\?', ['Sure! Why don\'t scientists trust atoms? Because they make up everything!']),     (r'(.) (talk about|discuss) (your|chatbot) (capabilities|functions|features)(.)\?', ['I am capable of answering questions, providing recommendations, sharing facts, and engaging in conversation on various topics.']),     (r'(.) (ask|inquire) (me|about me)(.)\?', ['Sure! What are your interests or hobbies?']),     (r'(.) (interested in|fascinated by|curious about) (.)\?', ['I am curious about many things! What specifically are you interested in?']),     (r'(.) (favorite|favourite) (movie|film) (.)\?', ['I don\'t have personal preferences, but I can recommend some popular movies if you\'d like!']),     (r'(.) (favorite|favourite) (book|novel) (.)\?', ['I don\'t read, but I can suggest some great books based on different genres!']),     (r'(.) (share|tell me) (something|a fact|an interesting fact) about (.)\?', ['Did you know that the longest recorded flight of a chicken was 13 seconds?']),     (r'(.) (happen in|occur in|significant event in) (.) (year|date|time|era)(.*)\?', ['There are many significant events throughout history. What specific event or time period are you interested in?']),     (r'(.) (want to know|interested in knowing) (more about|about) (.)\?', ['Absolutely! What specific information would you like to know?']),     (r'(.) (topic|subject) (interest you|are you interested in)(.)\?', ['I am interested in a wide range of topics, including technology, science, literature, and more.']),     (r'(.) (learn|tell me about) (something new|new things)(.)\?', ['Certainly! Did you know that octopuses have three hearts and blue blood?']),     (r'(.) (share with me|tell me about) (a|your) (favorite|favourite) (memory|experience)(.)\?', ['As a chatbot, I don\'t have personal experiences, but I can share interesting anecdotes and stories!']),     (r'(.) (provide|offer) (advice|guidance)(.)\?', ['Of course! What specific area would you like advice or guidance on?']),     (r'(.) (tell me|talk about) (a|your) (dream|goal|aspiration)(.)\?', ['My goal is to assist and provide helpful information to users like you!']),     (r'(.) (have|know|share) (an|any) (interesting|fun|fascinating) (fact|information|knowledge)(.)\?', ['Certainly! Did you know that the Earth is the only planet not named after a god?']),     (r'(.) (share|tell me) (a|your) (favorite|favourite) (quote|quotation)(.)\?', ['Here\'s one: "The only way to do great work is to love what you do." - Steve Jobs']),     (r'(.) (want to know|interested in knowing) (your|about you|more about you)(.)\?', ['Feel free to ask me anything! I am here to assist you.']),     (r'(.) (continue|carry on|keep going)(.)\?', ['Of course! What would you like to talk about next?']),     (r'(.) (change|switch) (topic|subject)(.)\?', ['Sure, let\'s talk about something else. What interests you?']),     (r'(.) (interesting|tell me more about|expand on) (.)\?', ['That\'s an interesting topic. Let me provide more information about it.']),     (r'(.) (what do you think about|thoughts on) (.)\?', ['I don\'t have personal opinions, but I can provide information on the topic.']),     (r'(.) (your|chatbot) (opinion|views) (.)\?', ['As an AI, I don\'t have personal opinions, but I can share information on various topics.']),     (r'(.) (any|other) (interesting|fascinating) (topic|subject) (you know|you can talk about)(.)\?', ['There are many interesting topics to explore. Let me suggest a few.']),     (r'(.) (ask|inquire) (you|chatbot) (a question|something)(.)\?', ['Feel free to ask me anything! I am here to assist you.']),     (r'(.) (what do you know about|tell me about) (.)\?', ['I can provide information on a wide range of topics. What specifically would you like to know about?']),     (r'(.) (want to|interested in) (learning about|knowing more about) (.)\?', ['Absolutely! I am always eager to learn and share information.']),     (r'(.) (explore|dive into|discuss) (the topic of|more about) (.)\?', ['Let\'s delve deeper into that topic. What aspect would you like to explore further?']),     (r'(.) (interested in|curious about|want to know more about) (.)\?', ['I am interested in learning more about that topic. What specifically would you like to know?']),     (r'(.) (engage in|continue) (a|the) (conversation|dialogue) (on|about) (.)\?', ['Absolutely! Let\'s keep the conversation going.']),     (r'(.) (anything else|more topics|what else) (.)\?', ['Sure, let me suggest some more topics we can discuss.']),     (r'(.) (have you heard about|know about|are you familiar with) (.)\?', ['I am knowledgeable about many topics. What specifically would you like to know about?']),     (r'(.) (what else|what other) (things|topics) (can we talk about|do you know about)(.)\?', ['There are countless topics to explore. Let me suggest a few more.']),     (r'(.) (tell me|share with me) (a|your) (story|experience|anecdote)(.)\?', ['Certainly! Let me share an interesting story or anecdote with you.']),     (r'(.) (explore|talk about) (more|other) (topics|subjects)(.)\?', ['Absolutely! Let\'s broaden our conversation to include other topics.']),     (r'(.) (discuss|talk about|tell me about) (the|a) (current event|latest news|recent happening)(.)\?', ['Let\'s discuss the latest news or current events.']),     (r'(.) (explore|dive into|talk about) (a|the) (topic|subject) (of|about|on) (.)\?', ['Let\'s delve deeper into that topic. What aspect would you like to explore further?']),     (r'(.) (share|tell me about) (a|your) (personal|interesting|fun|fascinating) (experience|story)(.)\?', ['Certainly! Let me share an interesting story or experience with you.']),     (r'(.) (want to|interested in) (hearing|knowing) (more|further information) (.)\?', ['Absolutely! I am here to provide you with more information.']),     (r'(.) (speak|talk|discuss) (to me|with me) (about|on) (.)\?', ['Of course! Let\'s talk about that topic.']),     (r'(.) (interested in|want to know about) (the|any) (latest|recent) (developments|updates) (in|on) (.)\?', ['I can provide you with the latest developments or updates on that topic.']),     (r'(.) (have you|are you) (familiar with|aware of) (the concept of|the idea of|the phenomenon of) (.)\?', ['Yes, I am familiar with that concept.']),     (r'(.) (what|tell me) (can you|do you) (know|understand) (about|regarding) (.)\?', ['I have knowledge on various aspects of that topic.']),     (r'(.) (interested in|want to know about|curious about) (learning|understanding) (more about|about) (.)\?', ['I am always eager to learn and share information on that topic.']),     (r'(.) (would you like to|interested in|want to) (explore|discover) (the|a) (topic of|subject of|idea of) (.)\?', ['Certainly! Let\'s explore that topic together.']),     (r'(.) (have you heard of|know about|are you familiar with) (the concept of|the idea of|the phenomenon of) (.)\?', ['Yes, I am familiar with that concept.']),     (r'(.) (tell me|share with me) (some|interesting) (facts|information) (about|regarding) (.)\?', ['Sure! Let me share some interesting facts or information with you.']),     (r'(.) (what do you think|what are your thoughts) (about|regarding) (.)\?', ['As an AI, I don\'t have personal opinions, but I can provide information on the topic.']),     (r'(.) (want to|interested in) (learning|finding out) (more about|about) (.)\?', ['Absolutely! I am here to provide you with more information on that topic.']),     (r'(.) (ask|inquire) (you|chatbot) (something|a question) (about|regarding) (.)\?', ['Feel free to ask me anything! I am here to assist you.']),     (r'(.) (explore|talk about) (other|different) (topics|subjects) (related to|concerning|pertaining to) (.)\?', ['Certainly! Let\'s broaden our conversation to include other related topics.']),     (r'(.) (interested in|curious about) (learning|knowing) (more|further) (about|regarding) (.)\?', ['I am always eager to learn and share information on that topic.']),     (r'(.) (interested in|want to know about) (your|the chatbot\'s) (knowledge|expertise) (on|regarding) (.)\?', ['Feel free to ask me anything! I am here to provide you with information on that topic.']),     (r'(.) (interested in|curious about) (exploring|discussing) (the|a) (topic of|subject of|idea of) (.)\?', ['Absolutely! Let\'s explore that topic further.']),     (r'(.) (want to|interested in) (engaging|participating) (in|on) (a|the) (conversation|discussion) (about|regarding) (.)\?', ['Certainly! Let\'s engage in a conversation on that topic.']), ]      

For any query contact me

sriaviralnarain@gmail.com

Comment
Like
You can also reply to this email to leave a comment.

Aviral Srivastava © 2024. Manage your email settings or unsubscribe.

WordPress.com and Jetpack Logos

Get the Jetpack app

Subscribe, bookmark, and get real-time notifications - all from one app!

Download Jetpack on Google Play Download Jetpack from the App Store
WordPress.com Logo and Wordmark title=

Automattic, Inc. - 60 29th St. #343, San Francisco, CA 94110  

at May 01, 2024
Email ThisBlogThis!Share to XShare to FacebookShare to Pinterest

No comments:

Post a Comment

Newer Post Older Post Home
Subscribe to: Post Comments (Atom)

3 Things That Work

When it comes to weight loss. ͏     ­͏     ­͏     ­͏     ­͏     ­͏     ­͏     ­͏     ­͏     ­͏     ­͏     ­͏     ­͏     ­͏     ­͏     ­͏    ...

  • [New post] Norwegian Black Metal Bands – Satanic or Psychotic?
    Dawn ...
  • [New post] After Announcing a New CEO, is Lordstown Motors Worth Buying?
    Editorial Team posted: "To improve its market reputation and streamline its operations, on Aug. 26 electric vehicle (EV) ma...
  • [New post] Estrazioni Lotto di oggi martedì 30 novembre 2021
    Redazione News posted: "Seguite su Cyberludus.com la diretta delle estrazioni di Lotto, 10eLotto e Superenalotto di martedì...

Search This Blog

  • Home

About Me

privacysavvy
View my complete profile

Report Abuse

Blog Archive

  • December 2025 (67)
  • November 2025 (73)
  • October 2025 (88)
  • September 2025 (79)
  • August 2025 (71)
  • July 2025 (89)
  • June 2025 (78)
  • May 2025 (95)
  • April 2025 (85)
  • March 2025 (78)
  • February 2025 (31)
  • January 2025 (50)
  • December 2024 (39)
  • November 2024 (42)
  • October 2024 (54)
  • September 2024 (83)
  • August 2024 (2665)
  • July 2024 (3210)
  • June 2024 (2908)
  • May 2024 (3025)
  • April 2024 (3132)
  • March 2024 (3115)
  • February 2024 (2893)
  • January 2024 (3169)
  • December 2023 (3031)
  • November 2023 (3021)
  • October 2023 (2352)
  • September 2023 (1900)
  • August 2023 (2009)
  • July 2023 (1878)
  • June 2023 (1594)
  • May 2023 (1716)
  • April 2023 (1657)
  • March 2023 (1737)
  • February 2023 (1597)
  • January 2023 (1574)
  • December 2022 (1543)
  • November 2022 (1684)
  • October 2022 (1617)
  • September 2022 (1310)
  • August 2022 (1676)
  • July 2022 (1375)
  • June 2022 (1458)
  • May 2022 (1297)
  • April 2022 (1464)
  • March 2022 (1491)
  • February 2022 (1249)
  • January 2022 (1282)
  • December 2021 (1663)
  • November 2021 (3139)
  • October 2021 (3253)
  • September 2021 (3136)
  • August 2021 (732)
Powered by Blogger.