AI-Enhanced Joke Bot v4.0
Welcome to the AI-Enhanced Joke Bot! This application combines humor with artificial intelligence to deliver jokes and analyze their sentiment.
📋 Project Structure
v4.0/
├── database.py # Creates the SQLite database and jokes table with user sentiment tracking
├── jokes.py # Main application with AI sentiment analysis and user rating
├── jokes.db # SQLite database containing jokes and user sentiments
├── sample_data.sql # Sample jokes to populate the database
├── populate_db.py # Script to populate the database with sample data
├── check_db.py # Utility to check database content
├── upgrade_db.py # Utility to upgrade existing databases with new schema
└── README.md # This file
🚀 Quick Start
1. Install Dependencies
First, make sure you have Python installed and then install the required packages:
# Create and activate virtual environment (recommended)
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
# Install required packages
pip install textblob
# Download required corpora for textblob
python -m textblob.download_corpora
2. Set Up the Database
Run the database creation script:
python database.py
This creates the jokes.db file with the proper table structure, including a table for user sentiments.
3. (Optional) Upgrade Existing Database
If you have an existing database from a previous version, run the upgrade script:
python upgrade_db.py
This adds the user_sentiments table to your existing database.
4. Populate the Database with Sample Jokes
To add sample jokes to your database:
python populate_db.py
Alternatively, you can use the SQL file directly:
sqlite3 jokes.db < sample_data.sql
5. Run the Application
Start the Joke Bot:
python jokes.py
🔧 Troubleshooting
No Jokes in Database
If you're getting "No jokes in the database" message:
- Make sure you've run
python database.pyto create the database - Run
python populate_db.pyto add sample jokes to the database - Verify the database content with
python check_db.py
Missing Dependencies
If you get an ImportError for textblob:
pip install textblob
python -m textblob.download_corpora
⚙️ Features
- Random Joke Generator: Get a random joke from the database
- AI Sentiment Analysis: Analyzes the sentiment of jokes using TextBlob
- User Sentiment Rating: After each joke, rate it with thumbs up/down/neutral
- Community Ratings: See how other users rated each joke
- Mood-Based Joke Selection: Filter jokes by sentiment (positive, negative, neutral)
- Add New Jokes: Contribute your own jokes to the database
- Joke Management: View all jokes in the database with community ratings
💡 Usage Tips
- Choose option 1 to get a random joke, then rate it with U(p)/D(own)/N(eutral)
- Choose option 2 to add a new joke with automatic sentiment analysis and rating
- Choose option 3 to analyze the sentiment of any text
- Choose option 4 to get jokes based on mood
- Choose option 5 to view all jokes in the database with community ratings
- Choose option 6 to exit the application
🗂️ Database Schema
The application uses two tables:
jokes: Contains the joke text, contributor, publication date, and AI-analyzed sentimentuser_sentiments: Tracks user ratings for each joke with timestamps
Enjoy the AI-enhanced humor experience with community feedback!