This application goes through 14er hiking trip reports and analyzes the tone of the reports, grouped by peak.
The Watson Natural Language Processing API is used for the tone analysis.
The nightmare JavaScript library was used for web scraping. The web scraping files are in the scrapers directory, and the raw data from web scraping is in the data directory.
If you want to run this code on your own, then you will have to create an IBM Watson API account, get your API keys, and set them as environment variables (WATSON_USERNAME and WATSON_PASSWORD as seen in the analyzer.js file). For this, I like to use the npm package dot-env. Once you have those environment variables set up:
-
Change into the
tone-analyzerdirectory root level. -
Scrape data from the trip report sites using the command
node scrapers/trip-reports.jsin your terminal. -
Analyze the trip report data using the command
node analyzer.jsfrom your terminal. -
To view sorted tone data, there is a sample script you can run from your terminal:
node results/sort-peaks.js
Thanks to this blog post, which helped guide me through using async/await with Nightmare.