This project retrieves all posts for a given Facebook page, performs both sentiment analysis and entity sentiment analysis, and then gathers that data into spreadsheets for valuable viewing.
- Get a facebook developer token
- Create
src/secrets.json
with the following:
{
"access_token": "This is the facebook developer token you retrieved earlier",
"page_name": "This is the page you plan on grabbing posts/comments from"
}
- Install dependencies
pip install -r requirements.txt
- Run it
python3 index.py
The Graph API is utitlized to traverse through the graph in the following fashion:
- Start with the node of a given page
- Get all connected post nodes
- Get all connected comment nodes
- page -> post(s) -> comment(s)
Google Cloud Platform's natural language processing API is used to retrieve:
- Sentiment data (from -1 to +1, how positive or negative is the given text)
- Entity sentiment data (extract entities from text and similar sentiment data)
If the network speed is fast enough when hitting these APIs, it is probable that the API quota 'DefaultRequestsPerMinutePerProject' will be exceeded.
If this happens, the requests can be manually throttled with a timer to stay within the default GCP bounds.
The current need for this was to extract comments containing a keyword, and separate positive and negative sentiment scoring comments. So two spreadsheets are created for each of those purposes.