/
basic.test.js
89 lines (71 loc) · 2.68 KB
/
basic.test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
var test = require('tape');
var nlp = require('../../lib/nlp');
test('basic is contractions', function(t) {
var r = nlp(`he is cool.`);
r.contractions().expand();
t.equal(r.out('text'), `he is cool.`, 'expanded-expand');
r = nlp(`he's cool.`);
r.contractions().expand();
t.equal(r.out('text'), `he is cool.`, 'contracted-expand');
r = nlp(`he is cool.`);
r.contractions().contract();
t.equal(r.out('text'), `he's cool.`, 'expanded-contract');
r = nlp(`he's cool.`);
r.contractions().contract();
t.equal(r.out('text'), `he's cool.`, 'contracted-contract');
t.end();
});
test('do-not contractions', function(t) {
var r = nlp(`please do not eat the marshmellow`);
r.contractions().expand();
t.equal(r.out('text'), `please do not eat the marshmellow`, 'expanded-expand');
r = nlp(`please don't eat the marshmellow`);
r.contractions().expand();
t.equal(r.out('text'), `please do not eat the marshmellow`, 'contracted-expand');
r = nlp(`please do not eat the marshmellow`);
r.contractions().contract();
t.equal(r.out('text'), `please don't eat the marshmellow`, 'expanded-contract');
r = nlp(`please don't eat the marshmellow`);
r.contractions().contract();
t.equal(r.out('text'), `please don't eat the marshmellow`, 'contracted-contract');
t.end();
});
test('have contractions', function(t) {
var r = nlp(`i have stood`);
r.contractions().expand();
t.equal(r.out('text'), `i have stood`, 'expanded-expand');
r = nlp(`i've stood`);
r.contractions().expand();
t.equal(r.out('text'), `i have stood`, 'contracted-expand');
r = nlp(`i have stood`);
r.contractions().contract();
t.equal(r.out('text'), `i've stood`, 'expanded-contract');
r = nlp(`i've stood`);
r.contractions().contract();
t.equal(r.out('text'), `i've stood`, 'contracted-contract');
t.end();
});
test('repeated contract-expand', function(t) {
var r = nlp(`i'm good`);
r.contractions().expand();
t.equal(r.out('text'), `i am good`, 'expand-1');
r.contractions().contract();
t.equal(r.out('text'), `i'm good`, 'contract-1');
r.contractions().expand();
t.equal(r.out('text'), `i am good`, 'expand-2');
r.contractions().contract();
t.equal(r.out('text'), `i'm good`, 'contract-2');
r.contractions().contract().contract().contract();
t.equal(r.out('text'), `i'm good`, 'contract-n');
r.contractions().expand().expand().expand();
t.equal(r.out('text'), `i am good`, 'expand-n');
t.end();
});
test('contracted', function(t) {
var r = nlp(`I'll go to Toronto. I will see.`);
var str = r.contractions().contracted().out('text');
t.equal(str, `I'll`, 'contracted');
str = r.contractions().expanded().out('text');
t.equal(str, `I will`, 'expanded');
t.end();
});