Permalink
Browse files

Handles punctuation better

  • Loading branch information...
1 parent f29ff0f commit 32a78de962e290b7e94d21f60a262db5470e383c Kurt Symanzik committed Sep 5, 2012
Showing with 6 additions and 2 deletions.
  1. +1 −1 lib/reds.js
  2. +5 −1 test/index.js
View
@@ -80,7 +80,7 @@ exports.createSearch = function(key){
*/
exports.words = function(str){
- return String(str).trim().split(/\W+/);
+ return String(str).match(/\w+/g);
};
/**
View
@@ -14,10 +14,14 @@ var start = new Date;
reds.version.should.match(/^\d+\.\d+\.\d+$/);
reds
- .words('foo bar baz')
+ .words('foo bar baz ')
.should.eql(['foo', 'bar', 'baz']);
reds
+ .words(' Punctuation and whitespace; should be, handled.')
+ .should.eql(['Punctuation', 'and', 'whitespace', 'should', 'be', 'handled']);
+
+reds
.stripStopWords(['this', 'is', 'just', 'a', 'test'])
.should.eql(['just', 'test']);

0 comments on commit 32a78de

Please sign in to comment.