0% found this document useful (0 votes)
6 views

Mid - Aspect-Based Sentiment Analysis1735037483

The document outlines a mid-term examination for developing a web application that performs Aspect-Based Sentiment Analysis using Flask and JavaScript. Students are required to create a functional application that classifies sentiments for various aspects of reviews, with specific backend and frontend requirements. Deliverables include the application, source code, and a demonstration of its functionality.

Uploaded by

chhayhangs
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views

Mid - Aspect-Based Sentiment Analysis1735037483

The document outlines a mid-term examination for developing a web application that performs Aspect-Based Sentiment Analysis using Flask and JavaScript. Students are required to create a functional application that classifies sentiments for various aspects of reviews, with specific backend and frontend requirements. Deliverables include the application, source code, and a demonstration of its functionality.

Uploaded by

chhayhangs
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

Subject: Intelligence System Development

Mid-Term Examination (Co4E1)


Develop a Web Application for Aspect-Based Sentiment Analysis
(December 23, 2025)

Objective

Create a functional web-based application that performs Aspect-Based Sentiment Analysis using
Flask for the backend and HTML/CSS/JavaScript for the frontend. The application must include
a trained sentiment analysis model that evaluates multiple aspects (features) of a given text.

Examination Instructions

1. Time Allotted: 2–3 hours.

2. Deliverables:

o A fully functional application.

o Source code for Flask, HTML, CSS, and JavaScript.

o A working demonstration of the application.

3. Setup Instructions:

o Students must create the application using Python, Flask, and the required libraries.

o Internet access is allowed only for library installations and Flask documentation but
not for copying solutions.

o Follow the provided problem statement and starter code to structure the project.

Problem Statement

You are tasked with building an Aspect-Based Sentiment Analysis application. The application
must classify sentiments as Positive, Negative, or Neutral for multiple aspects of a given review,
such as Food, Service, and Ambience in restaurant reviews.
1. Train a Machine Learning Model

• Train a Naive Bayes classifier using scikit-learn on a predefined dataset.

• Use the sample dataset provided below to classify sentiments for each aspect.

2. Backend Functionality

• Create a Flask-based backend that:

o Exposes a /predict endpoint to accept a review in JSON format.

o Processes the review and predicts the sentiment for predefined aspects.

o Returns the result in JSON format.

3. Frontend Requirements

• Build a web interface using HTML and CSS:

o A textarea to input review text.

o A Check button to submit the review for prediction.

o A Result area to display the sentiment for each aspect (Food, Service, Ambience).

• Use JavaScript to:

o Handle form submission and communicate with the Flask backend.

o Dynamically update the Result section with predictions for each aspect.

4. Styling

• Create a professional look using CSS.

• Use appropriate colors for each sentiment:


o Positive: Green

o Negative: Red

o Neutral: Gray

Starter Code

Sample Training Data

Use the following dataset to train your model:

data = [

("The food was amazing, but the service was slow.", {"Food": "Positive", "Service":
"Negative", "Ambience": "Neutral"}),

("The ambience was delightful, but the food lacked flavor.", {"Food": "Negative",
"Service": "Neutral", "Ambience": "Positive"}),

("The service was excellent, but the place was too noisy.", {"Food": "Neutral",
"Service": "Positive", "Ambience": "Negative"}),

("Everything was perfect: food, service, and ambience!", {"Food": "Positive",


"Service": "Positive", "Ambience": "Positive"}),

("The food was okay, but the service was terrible.", {"Food": "Neutral", "Service":
"Negative", "Ambience": "Neutral"}),

Project Structure

Students must organize their project as follows:


project/

├── app.py # Flask Backend

├── templates/

│ └── index.html # HTML Frontend

├── static/

│ ├── styles.css # CSS Styling

│ └── scripts.js # JavaScript Logic

Sample Workflow

1. Flask Backend (app.py):

o Train a model that predicts the sentiment for predefined aspects (e.g., Food,
Service, Ambience).

o Define a /predict endpoint to process and predict the sentiments.

2. Frontend (index.html, styles.css, scripts.js):

o Provide an input box (textarea) for review text.

o Submit the review to the Flask backend using JavaScript (AJAX/fetch).

o Display the sentiment for each aspect with appropriate color-coded styling.

Grading Rubric (100 Points)

Category Points Criteria

1. Backend Implementation 40 - Functional /predict endpoint (15).

- Correct use of Naive Bayes model (15).


- Clear and well-documented code (10).

2. Frontend Implementation 40 - Functional web interface (15).

- Dynamic updates using JavaScript (15).

- Results styled appropriately with color


codes (10).

3. Presentation & Debugging 20 - Professional UI styling with CSS (10).

- Clear handling of edge cases and errors


during demonstration (10).

Hints

• Use TfidfVectorizer from scikit-learn for text preprocessing.

• Use MultinomialNB for training the Naive Bayes model.

• Implement preprocessing to extract and classify sentiments for specific aspects.

• Use fetch or XMLHttpRequest in JavaScript for communicating with the backend.

• Include meaningful comments to explain code.

Expected Deliverables

• A fully functional web application that predicts the sentiment for multiple aspects of a
given review.

• Source files organized as per the project structure.

• A short demonstration of the app's functionality.

You might also like