feat: implement automated sentiment analysis for product reviews#329
Open
Mayuresh-1306 wants to merge 1 commit into
Open
feat: implement automated sentiment analysis for product reviews#329Mayuresh-1306 wants to merge 1 commit into
Mayuresh-1306 wants to merge 1 commit into
Conversation
Author
|
Hi @Nsanjayboruds! 👋 I've just submitted this PR for the automated sentiment analysis feature. I am actively participating in GirlScript Summer of Code (GSSoC) 2026. Could you please review this, add the gssoc and gssoc 26 labels, and assign this PR to me so it gets officially tracked for the program? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Currently, product reviews rely solely on numerical star ratings. This PR introduces a lightweight, native sentiment analysis feature using the dependency-free
sentimentnpm package to help users visually filter feedback efficiently.The text analysis is processed synchronously before hitting the database, assigning UI badges to reviews based on the actual context of the user's written feedback.
Changes Made
sentimentScore(Number) andsentimentLabel(String: Positive/Neutral/Negative) tobackend/model/reviewModel.js.sentimentpackage intobackend/controller/reviewController.js. It automatically calculates the text score upon review creation and updates existing reviews seamlessly.frontend/src/pages/ProductDetail.jsxto dynamically render styled "Helpful Positive" (green) and "Critical Review" (red) badges next to the stars for both the logged-in user's review and the general review feed.Testing & Graceful Fallback
Due to a currently known bug in the local
mainbranch preventing new user signups (Issue #311), UI screenshots could not be captured. However, the data flow has been architected to fail gracefully—if the sentiment score cannot be calculated for any reason, it simply defaults to 'Neutral' and does not interrupt the review submission pipeline.