Comparing version 0.0.4 to 0.0.5
/*jshint node:true, laxcomma:true */ | ||
"use strict"; | ||
var sugar = require('sugar'); | ||
var sanitizeHtml = require('sanitize-html'); | ||
@@ -32,7 +31,7 @@ | ||
// Split the text into words | ||
var words = text.words(); | ||
var words = text.match(/\S+/g); // see http://blog.tompawlak.org/split-string-into-tokens-javascript | ||
var sentences = []; | ||
var current = []; | ||
for (i in words) { | ||
for (i=0; i<words.length; i++) { | ||
// Add the word to current sentence | ||
@@ -39,0 +38,0 @@ current.push(words[i]); |
{ | ||
"name": "sbd", | ||
"version": "0.0.4", | ||
"version": "0.0.5", | ||
"description": "Split text into sentences", | ||
@@ -30,5 +30,7 @@ "main": "lib/tokenizer.js", | ||
"dependencies": { | ||
"sanitize-html": "^1.4.3", | ||
"sugar": "~1.4.1" | ||
"sanitize-html": "^1.4.3" | ||
}, | ||
"browser": { | ||
"sanitize-html": "./lib/sanitize-html-browser.js" | ||
} | ||
} |
@@ -18,2 +18,12 @@ /*jshint node:true, laxcomma:true */ | ||
describe('Difficult single sentence', function () { | ||
var entry = "On Jan. 20, former Sen. Barack Obama became the 44th President of the U.S."; | ||
var sentences = tokenizer.sentences(entry); | ||
it('should get one sentence', function () { | ||
console.log(sentences); | ||
assert.equal(sentences.length, 1); | ||
}); | ||
}); | ||
describe('Two sentences', function () { | ||
@@ -28,2 +38,12 @@ var entry = "Hello this is my first sentence . There is also a second."; | ||
describe('Difficult two sentences', function () { | ||
var entry = "On Jan. 20, former Sen. Barack Obama became the 44th President of the U.S. Millions attended the Inauguration."; | ||
var sentences = tokenizer.sentences(entry); | ||
it('should get one sentence', function () { | ||
console.log(sentences); | ||
assert.equal(sentences.length, 2); | ||
}); | ||
}); | ||
describe('Dot in middle of word is skipped', function () { | ||
@@ -160,3 +180,2 @@ var entry = "Hello.this is my first sentence."; | ||
it("should get 2 sentences", function () { | ||
console.log(sentences); | ||
assert.equal(sentences.length, 2); | ||
@@ -163,0 +182,0 @@ }); |
28547
1
10
1481
- Removedsugar@~1.4.1
- Removedsugar@1.4.1(transitive)