sentiment
Version:
AFINN-based sentiment analysis for Node.js
17 lines (15 loc) • 425 B
JavaScript
/*eslint no-useless-escape: "off"*/
/**
* Remove special characters and return an array of tokens (words).
* @param {string} input Input string
* @return {array} Array of tokens
*/
module.exports = function(input) {
return input
.toLowerCase()
.replace(/\n/g, ' ')
.replace(/[.,\/#!?$%\^&\*;:{}=_`\"~()]/g, ' ')
.replace(/\s\s+/g, ' ')
.trim()
.split(' ');
};