Skip to main content

Python chatbot code

 from chatterbot import ChatBot

from chatterbot.trainers import ChatterBotCorpusTrainer


# Create a new chat bot

chatbot = ChatBot('MyBot')


# Create a new trainer for the chat bot

trainer = ChatterBotCorpusTrainer(chatbot)


# Train the chat bot on English language data

trainer.train('chatterbot.corpus.english')


# Main chat loop

print("Hello! I'm your AI chat bot. Type 'exit' to end the conversation.")

while True:

    # Get user input

    user_input = input("You: ")


    # Exit the chat if the user types 'exit'

    if user_input.lower() == 'exit':

        print("Goodbye!")

        break


    # Get the AI's response

    response = chatbot.get_response(user_input)


    # Display the AI's response

    print(f"Bot: {response}")


Comments

Popular posts from this blog

Basic python

  Python is a versatile and powerful programming language known for its readability and simplicity. Here are some basic concepts and syntax in Python: Print Statement: To display output, use the print statement: python Copy code print("Hello, World!") Variables: Variables store data. No need to declare the data type explicitly. python Copy code x = 5 message = "Hello" Data Types: Python has various data types, including integers, floats, strings, lists, tuples, and dictionaries. Indentation: Python uses indentation (whitespace) to define code blocks. This is a fundamental aspect of Python's syntax. python Copy code if x > 0:     print("Positive number") Comments: Use the # symbol for single-line comments. python Copy code # This is a comment Input: To take user input, use the input() function. python Copy code name = input("Enter your name: ") Conditional Statements: Python supports if, elif, and else statements for decision-making. python...

How To secure An Iphone

Securing your iPhone is crucial to protect your personal data, privacy, and device integrity. Here are some essential tips to enhance the security of your iPhone: Enable Passcode or Face ID/Touch ID: Set up a strong alphanumeric passcode or use Face ID/Touch ID for an added layer of security. Go to Settings > Face ID & Passcode (or Touch ID & Passcode) to configure these options. Update iOS regularly: Keep your iPhone's operating system up to date by installing the latest iOS updates. These updates often include security patches that address vulnerabilities. Activate Find My iPhone: Enable Find My iPhone under Settings > [your name] > Find My > Find My iPhone. This feature allows you to locate, lock, and remotely wipe your device if it's lost or stolen. Use Two-Factor Authentication (2FA): Enable two-factor authentication for your Apple ID. This adds an extra layer of protection by requiring a verification code in addition to your password when signing in. M...

How to install windows in a pc or laptop

 Installing Windows on a laptop involves several steps. Here's a general guide for installing Windows on a laptop: Before you begin: Ensure that you have a valid Windows installation media (USB drive or DVD) and a valid product key. Backup important data on your laptop as the installation process will involve formatting the drive. Installation Steps: Insert the Installation Media: If you have a USB drive, insert it into a USB port. If you have a DVD, insert it into the laptop's optical drive. Boot from Installation Media: Restart your laptop and access the boot menu or BIOS/UEFI settings. This is usually done by pressing a specific key during startup (e.g., Esc, F2, F10, or Del). Select the option to boot from the USB drive or DVD. Windows Setup: The Windows setup screen will appear. Select your language, time, and keyboard input preferences, then click "Next." Install Now: Click on "Install Now" to start the installation process. Enter the Product Key: Ente...