ajaynegi45 / LibraryMan-API

Revolutionize book management with LibraryMan! Easily track stock, borrowers, and due dates, streamlining operations for schools, companies, and libraries worldwide, ensuring efficient and organized book lending.
MIT License
44 stars 49 forks source link

[FEATURE] <Implementing a AI chatbot to asist > #91

Closed divyalakshmi0 closed 3 weeks ago

divyalakshmi0 commented 1 month ago

Is this feature already requested?

Problem or Missing Functionality

No response

Feature Description

I suggest adding ai to help user find books

Screenshots

No response

Would you like to work on this feature?

Yes

Implementation Plan

No response

github-actions[bot] commented 1 month ago

👋 Thank you @divyalakshmi0 for raising an issue! We’re thrilled to have your input as we work to make this project even better. Our team will review it shortly, so stay tuned! Meanwhile, make sure your issue gets noticed, don’t forget to star the repo 🌟 and follow @ajaynegi45 for even more project insights!

ajaynegi45 commented 1 month ago

I want to know how you implement it

Tanisha0708 commented 1 month ago

@divyalakshmi0 i would like to workk on this issue. please assign me this issue

ajaynegi45 commented 4 weeks ago

@divyalakshmi0 i would like to workk on this issue. please assign me this issue

I want to know the implementation

Tanisha0708 commented 4 weeks ago

@ajaynegi45 i would like to implement in ds and using jdbc for this issue so that we can easily add the books while returning and remove books while issue with storing book info .. while chatbot will help in assisting about book .

Tanisha0708 commented 4 weeks ago

import java.util.ArrayList; import java.util.List; import java.util.Scanner; import java.util.stream.Collectors;

public class ChatbotApplication {

public static void main(String[] args) {
    ChatbotService chatbotService = new ChatbotService();

    // Simulate user input and interaction
    Scanner scanner = new Scanner(System.in);
    System.out.println("Welcome to the Library Chatbot! Type your queries:");

    while (true) {
        System.out.print("You: ");
        String userInput = scanner.nextLine();

        if (userInput.equalsIgnoreCase("exit")) {
            System.out.println("Chatbot: Goodbye!");
            break;
        }

        String response = chatbotService.processQuery(userInput);
        System.out.println("Chatbot: " + response);
    }

    scanner.close();
}

}

// Service to handle chatbot queries class ChatbotService { private final List books;

public ChatbotService() {
    this.books = loadBooks();
}

public String processQuery(String query) {
    if (query.toLowerCase().contains("find book")) {
        String keyword = query.replace("find book", "").trim();
        return findBooksByKeyword(keyword);
    }
    return "I'm here to help you find books. Try asking me to 'find book <title or keyword>'.";
}

private String findBooksByKeyword(String keyword) {
    List<Book> foundBooks = books.stream()
            .filter(book -> book.getTitle().toLowerCase().contains(keyword.toLowerCase()))
            .collect(Collectors.toList());

    if (foundBooks.isEmpty()) {
        return "No books found with that keyword.";
    }

    return foundBooks.stream()
            .map(Book::getTitle)
            .collect(Collectors.joining(", "));
}

private List<Book> loadBooks() {
    List<Book> books = new ArrayList<>();
    books.add(new Book("Effective Java", "Joshua Bloch", "Programming"));
    books.add(new Book("Java: The Complete Reference", "Herbert Schildt", "Programming"));
    books.add(new Book("Head First Java", "Kathy Sierra", "Programming"));
    books.add(new Book("Python Crash Course", "Eric Matthes", "Programming"));
    books.add(new Book("Automate the Boring Stuff with Python", "Al Sweigart", "Programming"));
    books.add(new Book("Fluent Python", "Luciano Ramalho", "Programming"));
    return books;
}

}

// Book entity class class Book { private String title; private String author; private String genre;

public Book(String title, String author, String genre) {
    this.title = title;
    this.author = author;
    this.genre = genre;
}

public String getTitle() {
    return title;
}

}

I want to know how you implement it

Tanisha0708 commented 4 weeks ago

here is the basic starting of code using java .

skdas20 commented 3 weeks ago

I'll develop the bot with DL4J and integrate it with spring, please assign this to me

Tanisha0708 commented 3 weeks ago

@ajaynegi45 please assign me this issue