-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.js
55 lines (48 loc) · 2 KB
/
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
import test from 'ava';
import extract from './index.js';
test('text preprocessing', t => {
const words = extract(`that is an email shirazy.sajjad@gmail.com and this is a url: [github.com].`);
t.is(words.length, 2);
t.is(words[0].vocabulary, 'email');
t.is(words[1].vocabulary, 'url');
});
test('removing stop words', t => {
const words = extract(`that is great!`);
t.is(words[0].vocabulary, 'great');
});
test('handling contractions', t => {
const words = extract(`that's great! but don’t take to long okay?`);
t.is(words[0].vocabulary, 'great');
t.is(words[2].vocabulary, 'long');
});
test('converting plural nouns to singular', t => {
const words = extract(`it's his pens and here are my categories. Drink up, me hearties, yo ho`);
t.is(words[0].vocabulary, 'pen');
t.is(words[1].vocabulary, 'category');
t.is(words[3].vocabulary, 'hearty');
t.is(extract(`hearties`)[0].vocabulary, 'hearty');
});
test('handling present form (3rd person) of verbs', t => {
const words = extract(`he throws!`);
t.is(words[0].vocabulary, 'throw');
});
test('handling gerund form of verbs', t => {
const words = extract(`he is running! i'm gonna scape.`);
t.is(words[0].vocabulary, 'run');
t.is(words[1].vocabulary, 'go');
t.is(extract(`hunting`)[0].vocabulary, 'hunting');
t.is(extract(`bring`)[0].vocabulary, 'bring');
t.is(extract(`wing`)[0].vocabulary, 'wing');
});
test('handling regular past tense of verbs', t => {
const words = extract(`he created this thing!`);
t.is(words[0].vocabulary, 'create');
t.is(extract(`limited`)[0].vocabulary, 'limit');
t.is(extract(`interested`)[0].vocabulary, 'interest');
t.is(extract(`proceed`)[0].vocabulary, 'proceed');
t.is(extract(`sacred`)[0].vocabulary, 'sacred');
t.is(extract(`preferred`)[0].vocabulary, 'prefer');
t.is(extract(`colored`)[0].vocabulary, 'color');
t.is(extract(`beloved`)[0].vocabulary, 'beloved');
t.is(extract(`sophisticated`)[0].vocabulary, 'sophisticate');
});