forked from NaturalNode/natural
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathaggressive_tokenizer_vi_spec.js
More file actions
60 lines (48 loc) · 2.48 KB
/
Copy pathaggressive_tokenizer_vi_spec.js
File metadata and controls
60 lines (48 loc) · 2.48 KB
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
/*
Copyright (c) 2018, Hugo W.L. ter Doest
Permission is hereby granted, free of charge, to any person obtaining a copy
of this softwé and associated documentation files (the "Softwé"), to deal
in the Softwé without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Softwé, and to permit persons to whom the Softwé is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Softwé.
THE SOFTWé IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWé OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
'use strict'
const Tokenizer = require('../lib/natural/tokenizers/aggressive_tokenizer_vi')
const tokenizer = new Tokenizer()
describe('aggressive_tokenizer_vi', function () {
it('should tokenize strings', function () {
expect(tokenizer.tokenize('Tôi bị lạc')).toEqual(['Tôi', 'bị', 'lạc'])
})
/*
it('should tokenize strings via attached string method', function() {
tokenizer.attach();
expect('Bạn giúp tôi đựơc không?'.tokenize()).toEqual(['Bạn', 'giúp', 'tôi', 'đựơc', 'không']);
});
it('should tokenize strings via attached string method', function() {
tokenizer.attach();
expect('Phòng tắm ( nhà thuốc ) ở đâu?'.tokenize()).toEqual(['Phòng', 'tắm', 'nhà', 'thuốc', 'ở', 'đâu']);
});
*/
it('should swallow final punctuation', function () {
expect(tokenizer.tokenize('Làm ơn đợi một lát!')).toEqual(['Làm', 'ơn', 'đợi', 'một', 'lát'])
})
it('should swallow final punctuation', function () {
expect(tokenizer.tokenize('Tôi đang tìm John.')).toEqual(['Tôi', 'đang', 'tìm', 'John'])
})
it('should swallow initial punctuation', function () {
expect(tokenizer.tokenize('.Đi thẳng, sau đó rẽ trái / phải')).toEqual(['Đi', 'thẳng', 'sau', 'đó', 'rẽ', 'trái', 'phải'])
})
it('should swallow duplicate punctuation', function () {
expect(tokenizer.tokenize('.Xin giữ máy!')).toEqual(['Xin', 'giữ', 'máy'])
})
})