TextSentimentAnalysis
TextSentimentAnalysis copied to clipboard
Text Sentiment Analysis in Python using Natural Language Processing (NLP) for Negative/Positive Content Detection. Deployed on the Cloud using Streamlit on the Heroku Platform.
Text Sentiment Analysis
Text Sentiment Analysis in Python using Natural Language Processing (NLP) for Negative/Positive Content Predictions. Deployed on the Cloud using Streamlit on the Heroku Platform.
Winter of Code 2020 : View Project Ideas or View Issues to Solve.
Web Application Demo
View the deployed WebApp on Heroku.
Installation : Setting up the Application Locally
- Dependencies:
- Run the command
pip install -r requirements.txton your cmd/python terminal. - It is highly recommended to create a new Virtual Environment first before running the above commands. The instructions for doing the same is provided below.
- Run the command
- Deployment:
- Use Streamlit App :
streamlit run TextSentimentApp.py
- Use Streamlit App :
- If there is no popup window opening in the browser you can paste the following address : http://localhost:8501/.
Creating Virtual Environments for Python Development in Visual Studio Code for this Project
A Guide to Creating Virtual Environments into Python and Using them Effectively.
Clone the Text Sentiment Analysis Repo :
Head over to our github repository ,fork the repo to your github account & clone the repository into your local machine.
Initial Setup
Open CMD/PowerShell from the VSCode Terminal :
It should display an output like the following :
CMD
Microsoft Windows [Version 10.0.18363.1198]
(c) 2019 Microsoft Corporation. All rights reserved.
C:\Users\farha\Documents\GitHub\TextSentimentAnalysis>
or
Powershell
Windows PowerShell
Copyright (C) Microsoft Corporation. All rights reserved.
Try the new cross-platform PowerShell https://aka.ms/pscore6
Check for the python version you're running :
C:\Users\farha\Documents\GitHub\TextSentimentAnalysis>python --version
Python 3.7.6
Check for the Python Packaging Index (Pypi) version you're running :
C:\Users\farha\Documents\GitHub\TextSentimentAnalysis>pip --version
pip 20.0.2 from C:\ProgramData\Anaconda3\lib\site-packages\pip (python 3.7)
Install the virtualenv module from pip :
C:\Users\farha\Documents\GitHub\TextSentimentAnalysis>pip install virtualenv
Create a project environment directory with YourAwesomeProjectNameEnvironment :
C:\Users\farha\Documents\GitHub\TextSentimentAnalysis>mkdir TextSentimentEnv
Create a new (empty) virtual environment in YourAwesomeProjectNameEnvironment :
C:\Users\farha\Documents\GitHub\TextSentimentAnalysis>virtualenv TextSentimentEnv
Users for other python versions may Install Python 3.7.6 first and then run the following command to choose the correct python interpreter with the correct path :
virtualenv --python=python3.7.6 TextSentimentEnv
Note : If you have problems with this step, try followng the debugging options provided below.
Enter into the newly created (empty) virtual environment in YourAwesomeProjectNameEnvironment :
C:\Users\farha\Documents\GitHub\TextSentimentAnalysis>TextSentimentEnv\Scripts\activate
You will notice a (YourAwesomeProjectNameEnvironment) appearing in the Command Line Interface :
(TextSentimentEnv) C:\Users\farha\Documents\GitHub\TextSentimentAnalysis>
Wohoooo! You're now in your virtual environment.
Install Dependencies :
Okay Great! We've got our virtualenv setup, but it's empty right now. Lets install some modules into it.
For this we will be needing a .txt file noting all the dependency requirements for a project under the project directory.
This file contains packages in the following naming fashion and can be obtained using
pip freeze > requirements.txt
or using
conda list --explicit > reqs.txt
When you've obtained the requirements file, do the following with your Environment Activated :
pip install -r requirements.txt
You are now happy to go forth coding and running your app with :
streamlit run TextSentimentApp.py
Useful Links for Debugging :
- https://github.com/ContinuumIO/anaconda-issues/issues/10822
- https://dev.to/idrisrampurawala/setting-up-python-workspace-in-visual-studio-code-vscode-149p
- https://dev.to/idrisrampurawala/flask-boilerplate-structuring-flask-app-3kcd
Voila Magic!
If you have further issues/queries regarding the project, feel free to contact us :
- Farhan Hai Khan : [email protected]
- Tannistha Pal : [email protected]
Using the Streamlit App
To start using the streamlit application follow these steps:
- Clone the repo:
git clone https://github.com/khanfarhan10/TextSentimentAnalysis.git
- Start the streamlit app:
cd TextSentimentAnalysis/streamlit
streamlit run sentiment.py
- Start the flask server:
cd TextSentimentAnalysis/server
python server.py
Usage of Paraphrase and Summarization Utilities
In the streamlit application, you can enter the text, and in the sidebar you can choose the task you want to perform, and hit the button for the corresponding inference.
CLI Tool Usage
Please follow the steps to use the CLI Tool for text sentiment analysis and for summarization.
- Clone the repo:
git clone https://github.com/khanfarhan10/TextSentimentAnalysis.git
- Change directory into the application folder:
cd TextSentimentAnalysis/TxT-CLI
- Install the CLI through pip:
pip3 install .
- Usage of the CLI:
TxT <option> <inputfilepath> <outputfilepath>
- Options
<option> = "tsa" (Text Sentiment Analysis)
= "sum" (Summarization)
<inputfilepath> = Path to a csv file containing texts in the first column
<outputfilepath> = Path to an empty csv file