This API provides sentiment analysis for text inputs using a pre-trained machine learning model.
- Python 3.x
- Django
- Django Rest Framework
- Transformers
-
Clone the repository:
git clone https://github.com/ShahAman/sentiment-analysis-api.git
-
Change into the project directory:
cd sentiment-analysis-api
-
Install the required packages:
pip install -r requirements.txt
-
Run the Django development server:
python manage.py runserver
-
The API will be accessible at
http://localhost:8000/api/analyze/
. -
Send a POST request to the
/analyze
endpoint with a JSON payload containing thetext
parameter:curl -X POST -H "Content-Type: application/json" -d '{"text": "I love this product!"}' http://localhost:8000/api/analyze/
-
The API will respond with a JSON object containing the sentiment analysis result:
{ "sentiment": "positive" }
- To change the port on which the API runs, modify the
runserver
command in themanage.py
file. - You can modify the sentiment analysis model by changing the
model_name
variable insentiment/views.py
. - Additional customization options are available in Django and Django Rest Framework. Refer to their documentation for more details.
This project is licensed under the MIT License. Feel free to use and modify it for your own purposes.
- The sentiment analysis model used in this API is provided by StatsGary.
- This project was developed by Shahnewaz.
Contributions are welcome! If you find any issues or have suggestions for improvements, please open an issue or submit a pull request.