The Muggy Weather Robotics Duo

Image
 The Muggy Weather Robotics Duo A C++ System That Thinks, Feels (Sensors!), and Acts Humidity is like the quiet character in the weather story that actually runs the show. On muggy days, everything feels heavier—breathing, drying laundry, running machines, even keeping a data center cool. For people, it’s about comfort and health; for machines, it’s about performance and reliability; for plants and buildings, it’s about moisture balance and mold risk. In robotics and automation, muggy weather isn’t just a nuisance—it’s a signal . It tells your systems when to ventilate, when to dehumidify, when to throttle physically demanding tasks, and when to take preventative maintenance actions. Today, we’ll build a two-program C++ system that “understands” muggy weather: Program A — sensor_hub.cpp A sensor-side program that generates (or ingests) a live stream of environmental data (temperature, relative humidity, pressure, CO₂, VOCs). Think of it as your robotic nose and skin , con...

AI-Powered Smart Note-Taking System

AI-Powered Smart Note-Taking System

This project consists of two integrated C++ programs that work together to manage and enhance note-taking using AI.

1. Note-Taking Manager (Core System)

Features:

  • Create, edit, delete, and search notes.
  • Store notes in a MySQL database or text files.
  • Lightweight GUI for easy navigation.

2. AI-Powered Summarizer & Keyword Extractor

Features:

  • Developed in C++ using NLP (Natural Language Processing).
  • Uses TensorFlow C++ API (or similar libraries).
  • Automatically summarizes long notes.
  • Extracts keywords to improve organization.

Integration Approach

  • The Note Manager stores data, while the AI module processes and summarizes notes.
  • Both modules communicate via inter-process communication (IPC) or database sharing.

Basic Implementation

1. Note-Taking Manager (CLI-Based)

  • Stores notes in a MySQL database or text files.

2. AI Summarizer & Keyword Extractor (Basic Version)

  • Initially uses C++ string processing for keyword extraction.
  • Later, NLP techniques will be added.

3. Integration

  • The summarizer processes notes stored in files or a database.

Phase 1: Implementing the Note Manager

Step 1: Setting Up MySQL for the Note Manager

Database Setup

Run the following SQL commands to create the database and tables:

CREATE DATABASE smart_notes;
USE smart_notes;

CREATE TABLE notes (
    id INT AUTO_INCREMENT PRIMARY KEY,
    title VARCHAR(255) NOT NULL,
    content TEXT NOT NULL,
    created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);

Step 2: Installing MySQL Connector for C++

For Linux (Ubuntu):

sudo apt install libmysqlcppconn-dev

For Windows:

Step 3: C++ Code for Adding Notes

This code connects to MySQL and allows users to add notes:

#include <iostream>
#include <mysql_driver.h>
#include <cppconn/prepared_statement.h>

using namespace std;
using namespace sql;

void addNote(Connection* conn, const string& title, const string& content) {
    PreparedStatement* pstmt = conn->prepareStatement("INSERT INTO notes (title, content) VALUES (?, ?)");
    pstmt->setString(1, title);
    pstmt->setString(2, content);
    pstmt->executeUpdate();
    delete pstmt;
    cout << "Note added successfully!\n";
}

int main() {
    try {
        MySQL_Driver* driver = MySQL::get_mysql_driver_instance();
        Connection* conn = driver->connect("tcp://127.0.0.1:3306", "root", "your_password");
        conn->setSchema("smart_notes");

        string title, content;
        cout << "Enter note title: ";
        getline(cin, title);
        cout << "Enter note content: ";
        getline(cin, content);

        addNote(conn, title, content);
        delete conn;
    } catch (SQLException& e) {
        cerr << "Error: " << e.what() << endl;
    }

    return 0;
}

Extending the Note Manager (Full CRUD Operations)

New Features Added:

  • View Notes
  • Edit Notes
  • Delete Notes

Updated C++ Code for Full CRUD Operations

#include <iostream>
#include <mysql_driver.h>
#include <mysql_connection.h>
#include <cppconn/prepared_statement.h>
#include <cppconn/resultset.h>

using namespace std;
using namespace sql;

void viewNotes(Connection* conn) {
    Statement* stmt = conn->createStatement();
    ResultSet* res = stmt->executeQuery("SELECT * FROM notes");

    cout << "\n----- Notes -----\n";
    while (res->next()) {
        cout << "ID: " << res->getInt("id") << " | Title: " << res->getString("title") << "\nContent: " << res->getString("content") << "\n----\n";
    }
    delete res;
    delete stmt;
}

void editNote(Connection* conn, int id, const string& newContent) {
    PreparedStatement* pstmt = conn->prepareStatement("UPDATE notes SET content=? WHERE id=?");
    pstmt->setString(1, newContent);
    pstmt->setInt(2, id);
    pstmt->executeUpdate();
    delete pstmt;
    cout << "Note updated successfully!\n";
}

void deleteNote(Connection* conn, int id) {
    PreparedStatement* pstmt = conn->prepareStatement("DELETE FROM notes WHERE id=?");
    pstmt->setInt(1, id);
    pstmt->executeUpdate();
    delete pstmt;
    cout << "Note deleted successfully!\n";
}

int main() {
    try {
        MySQL_Driver* driver = MySQL::get_mysql_driver_instance();
        Connection* conn = driver->connect("tcp://127.0.0.1:3306", "root", "your_password");
        conn->setSchema("smart_notes");

        int choice, id;
        string title, content;

        while (true) {
            cout << "\n1. Add Note\n2. View Notes\n3. Edit Note\n4. Delete Note\n5. Exit\nChoose: ";
            cin >> choice;
            cin.ignore();

            switch (choice) {
                case 1:
                    cout << "Enter title: ";
                    getline(cin, title);
                    cout << "Enter content: ";
                    getline(cin, content);
                    addNote(conn, title, content);
                    break;
                case 2:
                    viewNotes(conn);
                    break;
                case 3:
                    cout << "Enter note ID to edit: ";
                    cin >> id;
                    cin.ignore();
                    cout << "Enter new content: ";
                    getline(cin, content);
                    editNote(conn, id, content);
                    break;
                case 4:
                    cout << "Enter note ID to delete: ";
                    cin >> id;
                    deleteNote(conn, id);
                    break;
                case 5:
                    delete conn;
                    return 0;
                default:
                    cout << "Invalid choice. Try again!\n";
            }
        }
    } catch (SQLException& e) {
        cerr << "Error: " << e.what() << endl;
    }

    return 0;
}

Phase 2: AI-Powered Summarization & Keyword Extraction

Step 1: Installing NLP Libraries

Python Option

pip install sumy flashtext

C++ Option

  • Use word frequency analysis for keyword extraction.

Step 2: Python Script for AI Summarization

import sys
from sumy.parsers.plaintext import PlaintextParser
from sumy.nlp.tokenizers import Tokenizer
from sumy.summarizers.lsa import LsaSummarizer
from flashtext import KeywordProcessor

def summarize(text):
    parser = PlaintextParser.from_string(text, Tokenizer("english"))
    summarizer = LsaSummarizer()
    summary = summarizer(parser.document, 2)  # Get 2 summarized sentences
    return " ".join(str(sentence) for sentence in summary)

def extract_keywords(text):
    keyword_processor = KeywordProcessor()
    keyword_processor.add_keywords_from_list(["C++", "database", "notes", "summarization"])
    return keyword_processor.extract_keywords(text)

if __name__ == "__main__":
    input_text = sys.argv[1]
    summary = summarize(input_text)
    keywords = extract_keywords(input_text)
    print(summary + "\nKEYWORDS: " + ", ".join(keywords))

Final Integration: C++ Calls Python for Summarization

void summarizeNote(int id) {
    // Fetch note content from MySQL
    string command = "python3 summarizer.py \"" + content + "\"";
    system(command.c_str());
}

How the System Works

  1. The Note Manager retrieves notes from MySQL.
  2. The C++ program calls the Python script.
  3. The AI module summarizes the note and extracts keywords.
  4. The results are displayed on the screen.

This project enhances note management with AI-powered efficiency!

Comments

Popular posts from this blog

C++ Projects: Basic Traffic Management System

C++ Projects: Book Shop Management System

🌿 Smart Garden Manager in C++ with Robotics, UI, Drones, and Sound "A Rainwater Conservation System for Tomorrow’s Farms"