Skip to content

Commit

Permalink
Create sushil-AI-Based Chatbot for Customer Support Automation
Browse files Browse the repository at this point in the history
Text Input Handling:

The program accepts user input using input(). The user enters a sentence or paragraph that is analyzed for sentiment.
Bag of Words (BoW) Representation:

The text is tokenized into individual words.
A Bag of Words model is created using CountVectorizer(), which counts the frequency of each unique word in the text.
The resulting matrix (word counts) and feature names (unique words) are displayed.
Word Sentiment Rating:

Each word from the Bag of Words feature set is analyzed using the TextBlob library to calculate its sentiment polarity.
Based on polarity:
Positive: Polarity > 0
Negative: Polarity < 0
Neutral: Polarity = 0
Words with negative polarity are flagged, and their sentiment is printed.
Sentence-Level Sentiment Analysis:

The input text is split into individual sentences.
Each sentence is analyzed for sentiment using TextBlob:
Positive: Polarity > 0
Negative: Polarity < 0
Neutral: Polarity = 0
If a sentence has a negative sentiment, a predefined negative response is triggered.
Overall Sentiment Analysis:

The overall sentiment polarity is calculated by analyzing the entire input text as a single unit.
If any sentence was flagged as negative earlier, the overall sentiment is overridden as Negative. Otherwise, it is determined by the calculated polarity:
Positive: Polarity > 0
Neutral: Polarity = 0
Response Generation:

Based on the overall sentiment:
Positive Sentiment: Displays a predefined positive response.
Negative Sentiment: Displays a predefined negative response.
Neutral Sentiment: Indicates that the text is neutral.
Execution Example:

Input: "The product is amazing and I absolutely love it! But the delivery service was horrible."
Output:
Sentence 1: Positive (Polarity: 0.6125)
Sentence 2: Negative (Polarity: -1.0)
Overall: Negative (overridden due to the negative sentence)
Response: "Sorry for the bad service. Our customer care will call you back."
  • Loading branch information
AISushilRaj authored Jan 14, 2025
1 parent 36bed58 commit bedb6ac
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions sushil-AI-Based Chatbot for Customer Support Automation
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

0 comments on commit bedb6ac

Please sign in to comment.