diff --git a/lib/sentimental.js b/lib/sentimental.js index 09c6958..cdaa437 100644 --- a/lib/sentimental.js +++ b/lib/sentimental.js @@ -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 = [], @@ -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 = [], diff --git a/package.json b/package.json index 24f65c3..1036ac6 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "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": { }, @@ -10,7 +10,7 @@ "test": "make test" }, "devDependencies": { - "mocha": "0.10.0", - "should": "0.6.0" + "mocha": "1.9.0", + "should": "1.2.2" } -} \ No newline at end of file +} diff --git a/test/test.js b/test/test.js index 9948d0c..b5165b8 100644 --- a/test/test.js +++ b/test/test.js @@ -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(); + }); + }); }); @@ -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 () {