UNPKG
sentiment
Version:
latest (5.0.2)
5.0.2
5.0.1
5.0.0
4.2.0
4.1.0
4.0.1
4.0.0
3.0.1
3.0.0
2.1.0
2.0.1
2.0.0
1.0.6
1.0.5
1.0.4
1.0.3
1.0.2
1.0.1
1.0.0-alpha
0.2.4
0.2.3
0.2.1
0.2.0
0.1.0
AFINN-based sentiment analysis for Node.js
github.com/thisandagain/sentiment
thisandagain/sentiment
sentiment
/
languages
/
en
/
scoring-strategy.js
14 lines
(12 loc)
•
328 B
JavaScript
View Raw
1
2
3
4
5
6
7
8
9
10
11
12
13
14
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; } };