A simple web application for performing sentiment analysis on text input. The app has two main components:
- Frontend: Built with React.
- Backend: Powered by Python, FastAPI, and Hugging Face Transformers.
- Analyze text sentiment (Positive/Negative/Neutral).
- Confidence score for the sentiment analysis.
- Interactive and user-friendly UI.
- Node.js (version 16+)
- Python (version 3.8+)
- Virtual Environment (recommended)
fastapiuvicorntransformerspydanticpytest(for testing)
axios
git clone https://github.com/thefutureseer/python_sentiment_analysis.git
cd python_sentiment_analysiscd sentiment-backendpython3 -m venv venv
source venv/bin/activate # MacOS/Linux
venv\Scripts\activate # Windowspip install -r requirements.txtuvicorn main:app --reloadThe backend will start on http://127.0.0.1:8000.
cd python_sentiment_analysis [root]npm installnpm startThe frontend will start on http://localhost:3000.
- Open your browser and navigate to
http://localhost:3000. - Enter text in the input box and click "Analyze Sentiment."
- View the sentiment results, including the confidence score.
python_sentiment_analysis root directory/
│
├── sentiment-backend/ # Backend code (FastAPI)
│ ├── main.py # FastAPI entry point
│ ├── models.py # Pydantic models
│ ├── requirements.txt # Python dependencies
│ ├── test_main.py # Unit tests for the backend
│
├── # Frontend code (React)
|-- public
│── src/
│ ├── App.js # Main React component
│ ├── index.js # React entry point
│── package.json # Node.js dependencies
│
└── README.md # Project documentation
Ensure your virtual environment is active, then run:
python3 -m unittest test_main.pyAdd tests as needed using your preferred testing framework (e.g., Jest, React Testing Library).
- Deploy using services like AWS, Azure, Heroku, or Render.
- Build the production-ready files using:
npm run build
- Deploy using Vercel, Netlify, or any other static site hosting service.
- Add more detailed error handling.
- Implement support for other languages.
- Enhance UI with additional features.
This project is licensed under the MIT License. See LICENSE for details.
- FastAPI for backend framework.
- Hugging Face for sentiment analysis models.
- React for frontend development.