The function avg_sentiment returns the average sentiment of a topic (e.g. "Facebook") across several chosen news outlets (see code for details). This is a wrapper that combines the functionalities of NewsAPI, Newspaper, and FastText.
- Clone the project directory.
- If you haven't already, isntall virtualenv (not pipenv, but virtualenv - the lower level option in the link). Then set up a python3 virtualenv as follows:
virtualenv -p python3 venv_name
. Follow the link for more details. This will make sure installations go smoothly. pip install -r requirements.txt
- Install FastText (see installation directions in the link).
- Get a NewsAPI API key. Un-comment the variable 'newsapi_key' and set it at the top of sentinews.py
- See demo usage at the bottom of sentinews.py