Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions lib/sentimental.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
var afinn = require('../wordLists/afinn.json');

var tokenizeWithNoPunctuation = function (phrase) {
var noPunctuation = phrase.replace(/[^a-zA-Z ]+/g, ' ').replace('/ {2,}/',' ');
return noPunctuation.toLowerCase().split(" ");
};

// Calculates the negative sentiment of a sentence
// -------------------------------------------------- //
Expand All @@ -10,8 +14,7 @@ function negativity (phrase) {
words.push(t);
};

var noPunctuation = phrase.replace(/[^a-zA-Z ]+/g, ' ').replace('/ {2,}/',' '),
tokens = noPunctuation.toLowerCase().split(" "),
var tokens = tokenizeWithNoPunctuation(phrase),
hits = 0,
words = [];

Expand Down Expand Up @@ -40,8 +43,7 @@ function positivity (phrase) {
words.push(t);
};

var noPunctuation = phrase.replace(/[^a-zA-Z ]+/g, ' ').replace('/ {2,}/',' '),
tokens = noPunctuation.toLowerCase().split(" "),
var tokens = tokenizeWithNoPunctuation(phrase),
hits = 0,
words = [];

Expand Down