UNPKG

sentiment

Version:

AFINN-based sentiment analysis for Node.js

14 lines (12 loc) 328 B
var negators = require('./negators.json'); module.exports = { apply: function(tokens, cursor, tokenScore) { if (cursor > 0) { var prevtoken = tokens[cursor - 1]; if (negators[prevtoken]) { tokenScore = -tokenScore; } } return tokenScore; } };