Skip to content

Commit

Permalink
Merge pull request #4 from thinkroth/properly_handle_punctuation
Browse files Browse the repository at this point in the history
properly handle punctuation
  • Loading branch information
thinkroth committed May 15, 2013
2 parents 9234bf6 + 77c12ea commit 015dd1c
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 6 deletions.
4 changes: 2 additions & 2 deletions lib/sentimental.js
Expand Up @@ -27,7 +27,7 @@ function negativity (phrase) {
adjectives.push(t);
};

var noPunctuation = phrase.replace(/[^a-zA-Z ]+/g, '').replace('/ {2,}/',' '),
var noPunctuation = phrase.replace(/[^a-zA-Z ]+/g, ' ').replace('/ {2,}/',' '),
tokens = noPunctuation.toLowerCase().split(" "),
hits = 0,
words = [],
Expand Down Expand Up @@ -79,7 +79,7 @@ function positivity (phrase) {
adjectives.push(t);
};

var noPunctuation = phrase.replace(/[^a-zA-Z ]+/g, '').replace('/ {2,}/',' '),
var noPunctuation = phrase.replace(/[^a-zA-Z ]+/g, ' ').replace('/ {2,}/',' '),
tokens = noPunctuation.toLowerCase().split(" "),
hits = 0,
words = [],
Expand Down
8 changes: 4 additions & 4 deletions package.json
Expand Up @@ -2,15 +2,15 @@
"name": "Sentimental",
"description": "Sentiment Analysis module",
"repository": "git://github.com/thinkroth/Sentimental",
"version": "0.0.2",
"version": "0.0.3",
"author": "Kevin M Roth",
"dependencies": {
},
"scripts": {
"test": "make test"
},
"devDependencies": {
"mocha": "0.10.0",
"should": "0.6.0"
"mocha": "1.9.0",
"should": "1.2.2"
}
}
}
12 changes: 12 additions & 0 deletions test/test.js
Expand Up @@ -99,6 +99,12 @@ describe('Negativity', function () {
done();
});
});
describe('#negativeComparative', function () {
it('should properly handle punctuation', function (done) {
negativity("I'll be here till 5").score.should.equal(0);
done();
});
});
});


Expand Down Expand Up @@ -197,6 +203,12 @@ describe('Positivity', function () {
done();
});
});
describe('#positiveComparative', function () {
it('should properly handle punctuation', function (done) {
positivity("I'll be here till 5").score.should.equal(0);
done();
});
});
});

describe('Analyze', function () {
Expand Down

0 comments on commit 015dd1c

Please sign in to comment.