Skip to main content

No project description provided

Project description

Sentiment and Query Intent Analysis Library

Overview

This library provides tools for sentiment analysis and query intent detection using a fine-tuned BERT-based model to improve the emotional intelligence of your chatbot. The library enables sentiment classification at both sentence and document levels, as well as intent categorization most suited for educational chatbot conversations.

Features

Sentence-Level Sentiment Analysis - Classifies individual sentences as Positive, Neutral, or Negative.
Document-Level Sentiment Analysis - Aggregates multiple sentences and determines the overall sentiment.
Query Intent Detection - Identifies the intent behind a query, such as course information, class schedule, greetings ✅ Chat Summary Generation - Provides a summary table insights into chat sentiment and intent distribution.
Conversation Conversion & Analysis - Converts chat logs initially in a json format into a csv format structured data with sentiment, intent, and response time analysis to be used to generate a dynamic dashboard on a website link: https://chatbot-dashboard-analysis.streamlit.app/ Keys needed in the chat log: _id,Person,stime_text,stime_timestamp,last_interact_text,last_interact_timestamp,llm_deployment_name,llm_model_name,vectorstore_index,overall_cost,overall_tokens,role,content,recorded_on_text,recorded_on_timestamp,token_cost,tokens,user_sentiment,query_intent,conversation_id,previous_query_intent,overall_chat,chat_sentiment,chatbot_response_time,overall_conversation_time


Installation

Ensure you have the necessary dependencies installed:

pip install torch transformers pandas tabulate

Usage

1️⃣ Sentence-Level Sentiment Analysis

Determine sentiment (Positive, Neutral, Negative) for a given sentence. This can return the sentiment of the user.

from sentiment_analysis import sentiment_sentence

sentence = "I love this course!"
sentiment = sentiment_sentence(sentence)
print(sentiment)  # Output: Positive

2️⃣ Document-Level Sentiment Analysis

Analyze sentiment for a collection of sentences or a document. This gives back the sentiment at class level. The input should be in a dictionary format where the keys are the sentence number and values are the content

from sentiment_analysis import sentiment_document

document = {"sentence1": "The class was great!", "sentence2": "I learned a lot."}
doc_sentiment = sentiment_document(document)
print(doc_sentiment)  # Output: Positive

3️⃣ Query Intent Detection

Classify the intent behind a query ("Course Overview and Information", "Course Assessment" , "Checking Announcement", "Request for Permission", "Learning Course Content", "Class Schedule", "Greetings", "Ending", "Casual Chat" , "No Query")

from sentiment_analysis import query_intent

query = "Can I get more details on the assessment criteria?"
intent = query_intent(query)
print(intent)  # Output: Course Assessment

4️⃣ Generate Chat Sentiment & Intent Summary

Summarize sentiment and intent for multiple sentences. Use chat_summary if you want query intent to be included.

from sentiment_analysis import chat_summary
from sentiment_analysis import sentiment_summary

document = {
    "sentence1": "I love this class!",
    "sentence2": "When is the next assignment due?"
}
summary = chat_summary(document)
summary = sentiment_summary(document)
print(summary)

5️⃣ Analyze and Convert Chat Logs

Convert chatbot logs into structured data with sentiment, intent, and response time analysis.

from sentiment_analysis import conversion

chatlog = {
    "chatlog": [
        {"_id": {"$oid": "1"}, "Person": "User1", "messages": [
            {"role": "user", "content": "I'm very happy with the course!"},
            {"role": "ai", "content": "Glad to hear that!"}
        ]}
    ]
}

df = conversion(chatlog, num_of_chats=1)
print(df.head())

Query Intent Categories

The query_intent function categorizes queries into the following:

Category Description
Course Overview and Information General course-related inquiries
Course Assessment Questions about exams, assignments
Checking Announcement Checking for latest updates
Request for Permission Asking for special permissions not available in the bector database
Learning Course Content Questions about materials or topics
Class Schedule Checking class timings
Greetings Saying "hello" or "goodbye"
Ending Ending a conversation
Casual Chat Non-academic casual discussions
No Query No identifiable query present

Sentiment Classification Categories

The library classifies sentiment into:

  • Positive 😊
  • Neutral 😐
  • Negative 😡

License

This project is licensed under the MIT License.

Author

Developed by Chalamalasetti Sree Vaishnavi. For questions or contributions, please contact [Your Email].

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

chatbot_analysis-0.3.tar.gz (6.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

chatbot_analysis-0.3-py3-none-any.whl (7.5 kB view details)

Uploaded Python 3

File details

Details for the file chatbot_analysis-0.3.tar.gz.

File metadata

  • Download URL: chatbot_analysis-0.3.tar.gz
  • Upload date:
  • Size: 6.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.5

File hashes

Hashes for chatbot_analysis-0.3.tar.gz
Algorithm Hash digest
SHA256 c59d8ed8921f91bc63e85c5383daa329bda0fc233b7ff8661d62701f8c429b26
MD5 5137fef8deefe9ebb573a65fc3dfc167
BLAKE2b-256 8a438588b2f94f9d7d9baa8d6b0e43563d388bc5504219a8dcb524085573885d

See more details on using hashes here.

File details

Details for the file chatbot_analysis-0.3-py3-none-any.whl.

File metadata

  • Download URL: chatbot_analysis-0.3-py3-none-any.whl
  • Upload date:
  • Size: 7.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.5

File hashes

Hashes for chatbot_analysis-0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 fdeca9f68270dd9c4e52797a986c668ec72dfcb9940e85c4610aa628dd5578a1
MD5 78b8b25ee64cefa9039be6b6bf989937
BLAKE2b-256 0f2c7fe2ab50c6f3feb721edf618a840337d064648beea03e4c4d68e9996a383

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page