This Flutter application provides a user-friendly interface for interacting with a sentiment analysis system. Users can predict sentiments, add comments, and view existing comments from a remote server.
- Predict the sentiment of a given comment.
- Add a new comment to the database.
- View all comments in the database along with their sentiment predictions.
Before running the application, ensure you have the following installed:
- Flutter SDK
- Dart SDK
- An active internet connection for API calls
-
Clone the repository:
git clone https://github.com/embarki34/your-repo-name.git cd your-repo-name
-
Install dependencies:
Run the following command to install the required packages:
flutter pub get
Run the application using the following command:
flutter run
The app will launch in your connected device or emulator.
Ensure to set the base URL for the API in the HomePage
class:
static const String _baseUrl = 'https://honeybee-prime-supposedly.ngrok-free.app';
The main screen serves as the entry point of the application, providing navigation to different functionalities:
- Home: Overview of the app's capabilities.
- Predict Sentiment: Input a comment to predict its sentiment.
- Add Comment: Submit a new comment to the database.
- View Comments: Display all comments stored in the database.
- HomeScreen: Displays the main features of the app.
- PredictSentimentScreen: Allows users to input text and receive a sentiment prediction.
- AddCommentScreen: Enables users to add a comment and their name to the database.
- ViewCommentsScreen: Retrieves and displays all comments from the database.
The app interacts with the following endpoints:
Endpoint: /predict
Method: POST
Request Body:
{
"text": "Your comment here"
}
Response:
{
"predicted_class": 1,
"prediction_label": "positive"
}
Endpoint: /add_comment
Method: POST
Request Body:
{
"comment_text": "Your comment here",
"commenter_name": "Your name"
}
Response:
{
"message": "Comment added successfully"
}
Endpoint: /comments
Method: GET
Response:
[
{
"commenter_name": "Name",
"comment_text": "Your comment",
"prediction": "positive",
"creation_time": "2023-01-01T00:00:00Z"
},
...
]
The application displays appropriate error messages for various failure scenarios, such as missing parameters or API errors.
This project is licensed under the MIT License. See the LICENSE file for more details.
Omar