Fix bugs in cleanText() and wordCount(), add some tests #13
Conversation
Fixed: - words with an apostrophe counted as a single word - counting empty string after a period as a word
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Really nice! Thanks so much for helping out — the library definitely needed it after I neglected it so much.
Test suite looks great — your contribution is much appreciated. I'll publish a new version to npm when I get to work. :)
@@ -0,0 +1 @@ | |||
--reporter nyan |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Heh.
assert.equal(ts.text, 'Hello hi friend.'); | ||
}); | ||
|
||
it('should replace em-dash with spaces'); // can I do that? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Em dash is usually used as a word terminator in my experience, rather than to create hyphenated pairs, so I don't see why not!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, my comment there is more about figuring out where to get the emdash. I was apparently in too much of a hurry to copy/paste it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, cool. Sorry, didn't intend to come across as patronising! Apologies if that was the case.
Not sure what OS you use, but I love em-dash, and there's a nice shortcut for it on Mac OS — option+shift+dash. Option+dash will give you an en-dash. :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No worries, I didn't read it as patronizing. My comment wasn't super clear.
Thanks for merging! |
@antislice No, thank you. :) |
I made some editorial decisions, mostly around how hyphenated words and email addresses should be handled. The behavior should be all documented in the mocha tests. This also resolves the issues brought up in PRs #9 and #11.