/
parser_tests.js
50 lines (44 loc) · 1.46 KB
/
parser_tests.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
describe('english parser', function() {
it('can tokenize two simple words', function() {
expect(parse('two words')).toEqual({
word_count: 2,
sentence_count: 1,
words: ['two', 'words']
});
});
it('can tokenize words with punctuation', function() {
expect(parse('two, words')).toEqual({
word_count: 2,
sentence_count: 1,
words: ['two', 'words']
});
});
it('can tokenize sentences with periods', function() {
expect(parse('first one. second one')).toEqual({
word_count: 4,
sentence_count: 2,
words: ['first', 'one', 'second', 'one']
});
});
it('can tokenize sentences with questions', function() {
expect(parse('first one? second one')).toEqual({
word_count: 4,
sentence_count: 2,
words: ['first', 'one', 'second', 'one']
});
});
it('can tokenize sentences with exclamations', function() {
expect(parse('first one! second one')).toEqual({
word_count: 4,
sentence_count: 2,
words: ['first', 'one', 'second', 'one']
});
});
it('can tokenize sentences with exclamations and punctuation', function() {
expect(parse('first, one! second: one')).toEqual({
word_count: 4,
sentence_count: 2,
words: ['first', 'one', 'second', 'one']
});
});
});