Simple sentiment analysis using multiple Node.js packages
-
Clone the repository:
git clone https://github.com/balain/survey-sentiment.git -
Install required Node packages:
npm install
- vaderSentiment-js: "Javascript port of the VADER sentiment analysis tool"
- sentiment: "AFINN-based sentiment analysis for Node.js"
- natural: "...general natural language facility for nodejs..."
- xlsx: to parse the Excel file
node process.js excelfilename where excelfilename is the name of the XLS file to process.
-
The source file:
-
Must have at least one worksheet.
-
The first worksheet must have three columns:
-
Column A is ignored.
-
Column B contains the survey question.
-
Column C contains the survey responses (free text).
-
-
-
Only the first worksheet/tab of the source XLS file will be processed.
-
Only the third column of that tab will be analyzed.
-
The processing script will:
-
Read in column C,
-
Analyze it using multiple Node packages, and
-
Output the tab-delimited results to STDOUT.
-
-
The user must save/redirect that output to a CSV file for further manipulation (e.g. import to Excel).
-
In addition to columns B and C from the original Excel file, the output contains the following columns:
- Score: sentiment score
- Comparative: sentiment comparative value
- Pos Terms: sentiment's list of positive words in the string
- Neg Terms: sentiment's list of negative words in the string
- Vader Pos: Vader's list of positive words in the string
- Vader Neutral: Vader's list of neutral words in the string
- Vader Neg: Vader's list of negative words in the string
- Vader Compound: Vader's list of positive words in the string
- Natural Sentiment: natural's list of sentiment analysis
The MIT License (MIT)
Copyright (c) 2020 John D. Lewis
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- Fork it (https://github.com/balain/survey-sentiment/fork)
- Create your feature branch (
git checkout -b feature/abc) - Commit your changes (
git commit -am 'Add some abc') - Push to the branch (
git push origin feature/abc) - Create a new Pull Request