UNPKG

1.71 kBJavaScriptView Raw
1
2var mocha = require("mocha");
3var should = require("should");
4var norm = require("../index");
5
6describe('Normalizer', function(){
7
8 before(function(done){
9 norm.loadData(function(){
10 done();
11 });
12 });
13
14 describe('Should clean input', function() {
15
16 it("should replace subsitutes", function() {
17 norm.clean("Nov 1st I weighed 90 kgs. total").should.eql("November 1st I weighed 90 kilograms total");
18 norm.clean("I shared it on FB w/ friends, ie: you").should.eql("I shared it on Facebook with friends, for example : you");
19 });
20
21 it("should expand contractions", function() {
22 norm.clean("I'm on the yelow zebra").should.eql("I am on the yellow zebra");
23 norm.clean("I'll listen to y'all").should.eql("I will listen to you all");
24 norm.clean("do n't make it right").should.eql("do not make it right");
25 });
26
27 it("should swap british / canadian words", function() {
28 norm.clean("armour axe coloured gold").should.eql("armor ax colored gold");
29 });
30
31 it("should fix spelling", function() {
32 norm.clean("are we sceduled thrsday for teh restraunt").should.eql("are we scheduled Thursday for the restaurant");
33 });
34
35 it("should expand txt speak", function() {
36 norm.clean("n").should.eql("~no");
37 norm.clean("lol").should.eql("~emolaugh");
38 norm.clean("haha").should.eql("~emolaugh");
39 norm.clean(":)").should.eql("~emohappy");
40 });
41
42 it("should not remove +", function() {
43 norm.clean("3+4=7").should.eql("3+4=7");
44 });
45
46 it("should remove extra spaces", function() {
47 norm.clean("this is spaced out").should.eql("this is spaced out");
48 });
49
50 it("should remove punct", function() {
51 norm.clean("why do i care?").should.eql("why do I care");
52 });
53
54 });
55});
\No newline at end of file