natural 7.0.3 → 7.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.github/workflows/npm-publish.yml +2 -0
- package/.nycrc +9 -0
- package/package.json +3 -4
- package/tsconfig.json +1 -1
- package/ts_spec/MaxEntClassifier_spec.ts +0 -130
- package/ts_spec/SentimentAnalyzer_spec.ts +0 -232
- package/ts_spec/WordPunctTokenizer_spec.ts +0 -57
- package/ts_spec/aggressive_tokenizer_de_spec.ts +0 -36
- package/ts_spec/aggressive_tokenizer_es_spec.ts +0 -39
- package/ts_spec/aggressive_tokenizer_fr_spec.ts +0 -111
- package/ts_spec/aggressive_tokenizer_hi_spec.ts +0 -70
- package/ts_spec/aggressive_tokenizer_nl_spec.ts +0 -39
- package/ts_spec/aggressive_tokenizer_pt_spec.ts +0 -48
- package/ts_spec/aggressive_tokenizer_spec.ts +0 -57
- package/ts_spec/aggressive_tokenizer_sv_spec.ts +0 -52
- package/ts_spec/aggressive_tokenizer_vi_spec.ts +0 -48
- package/ts_spec/bayes_classifier_spec.ts +0 -165
- package/ts_spec/brill_pos_tagger_spec.ts +0 -79
- package/ts_spec/brill_pos_trainer_spec.ts +0 -107
- package/ts_spec/carry_stemmer_fr_spec.ts +0 -97
- package/ts_spec/classifier_spec.ts +0 -104
- package/ts_spec/count_inflector_fr_spec.ts +0 -47
- package/ts_spec/count_inflector_spec.ts +0 -76
- package/ts_spec/damerau_levenshtein_spec.ts +0 -53
- package/ts_spec/dice_coefficient_spec.ts +0 -37
- package/ts_spec/double_metaphone_spec.ts +0 -739
- package/ts_spec/hamming_distance_spec.ts +0 -66
- package/ts_spec/jaro-winkler_spec.ts +0 -79
- package/ts_spec/lancaster_stemmer_spec.ts +0 -63
- package/ts_spec/levenshtein_spec.ts +0 -107
- package/ts_spec/logistic_regression_classifier_spec.ts +0 -93
- package/ts_spec/longest_path_tree_spec.ts +0 -111
- package/ts_spec/metaphone_spec.ts +0 -258
- package/ts_spec/ngram_spec.ts +0 -145
- package/ts_spec/ngram_zh_spec.ts +0 -124
- package/ts_spec/normalizer_ja_spec.ts +0 -165
- package/ts_spec/normalizer_no_spec.ts +0 -112
- package/ts_spec/normalizer_spec.ts +0 -141
- package/ts_spec/noun_inflector_fr_spec.ts +0 -472
- package/ts_spec/noun_inflector_ja_spec.ts +0 -116
- package/ts_spec/noun_inflector_spec.ts +0 -369
- package/ts_spec/orthography_tokenizer_spec.ts +0 -47
- package/ts_spec/porter_stemmer_de_spec.ts +0 -53
- package/ts_spec/porter_stemmer_es_spec.ts +0 -63
- package/ts_spec/porter_stemmer_fr_spec.ts +0 -103
- package/ts_spec/porter_stemmer_it_spec.ts +0 -56
- package/ts_spec/porter_stemmer_nl_spec.ts +0 -73
- package/ts_spec/porter_stemmer_no_spec.ts +0 -148
- package/ts_spec/porter_stemmer_pt_spec.ts +0 -50
- package/ts_spec/porter_stemmer_ru_spec.ts +0 -67
- package/ts_spec/porter_stemmer_spec.ts +0 -202
- package/ts_spec/porter_stemmer_sv_spec.ts +0 -41
- package/ts_spec/present_verb_inflector_spec.ts +0 -127
- package/ts_spec/remove_diacritics_spec.ts +0 -30
- package/ts_spec/sentence_analyzer_spec.ts +0 -293
- package/ts_spec/sentence_tokenizer_parser_spec.ts +0 -200
- package/ts_spec/sentence_tokenizer_spec.ts +0 -189
- package/ts_spec/shortest_path_tree_spec.ts +0 -141
- package/ts_spec/soundex_spec.ts +0 -162
- package/ts_spec/spellcheck_spec.ts +0 -112
- package/ts_spec/stemmer_id_spec.ts +0 -374
- package/ts_spec/stemmer_ja_spec.ts +0 -69
- package/ts_spec/stemmer_token_spec.ts +0 -163
- package/ts_spec/tfidf_spec.ts +0 -275
- package/ts_spec/tokenizer_case_spec.ts +0 -242
- package/ts_spec/tokenizer_ja_spec.ts +0 -63
- package/ts_spec/transliterator_ja_spec.ts +0 -105
- package/ts_spec/treebank_word_tokenizer_spec.ts +0 -38
- package/ts_spec/trie_spec.ts +0 -197
|
@@ -1,111 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
Copyright (c) 2011, Chris Umbel
|
|
3
|
-
|
|
4
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
5
|
-
of this softwé and associated documentation files (the "Softwé"), to deal
|
|
6
|
-
in the Softwé without restriction, including without limitation the rights
|
|
7
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
8
|
-
copies of the Softwé, and to permit persons to whom the Softwé is
|
|
9
|
-
furnished to do so, subject to the following conditions:
|
|
10
|
-
|
|
11
|
-
The above copyright notice and this permission notice shall be included in
|
|
12
|
-
all copies or substantial portions of the Softwé.
|
|
13
|
-
|
|
14
|
-
THE SOFTWé IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
15
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
16
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
17
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
18
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
19
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWé OR THE USE OR OTHER DEALINGS IN
|
|
20
|
-
THE SOFTWARE
|
|
21
|
-
*/
|
|
22
|
-
|
|
23
|
-
'use strict'
|
|
24
|
-
|
|
25
|
-
import { AggressiveTokenizerFr } from 'lib/natural'
|
|
26
|
-
const tokenizer = new AggressiveTokenizerFr()
|
|
27
|
-
|
|
28
|
-
const text = "Affectueusement surnommé « Gabo » dans toute l'Amérique latine, le Colombien Gabriel Garcia Marquez, prix Nobel de littérature 1982, l'un des plus grands écrivains du XXe siècle, est mort À son domicile de Mexico jeudi 17 avril. Il était âgé de 87 ans. Son Œuvre a été traduite dans toutes les langues ou presque, et vendue à quelque 50 millions d'exemplaires."
|
|
29
|
-
|
|
30
|
-
const tokenized = ['Affectueusement',
|
|
31
|
-
'surnommé',
|
|
32
|
-
'Gabo',
|
|
33
|
-
'dans',
|
|
34
|
-
'toute',
|
|
35
|
-
'l',
|
|
36
|
-
'Amérique',
|
|
37
|
-
'latine',
|
|
38
|
-
'le',
|
|
39
|
-
'Colombien',
|
|
40
|
-
'Gabriel',
|
|
41
|
-
'Garcia',
|
|
42
|
-
'Marquez',
|
|
43
|
-
'prix',
|
|
44
|
-
'Nobel',
|
|
45
|
-
'de',
|
|
46
|
-
'littérature',
|
|
47
|
-
'1982',
|
|
48
|
-
'l',
|
|
49
|
-
'un',
|
|
50
|
-
'des',
|
|
51
|
-
'plus',
|
|
52
|
-
'grands',
|
|
53
|
-
'écrivains',
|
|
54
|
-
'du',
|
|
55
|
-
'XXe',
|
|
56
|
-
'siècle',
|
|
57
|
-
'est',
|
|
58
|
-
'mort',
|
|
59
|
-
'À',
|
|
60
|
-
'son',
|
|
61
|
-
'domicile',
|
|
62
|
-
'de',
|
|
63
|
-
'Mexico',
|
|
64
|
-
'jeudi',
|
|
65
|
-
'17',
|
|
66
|
-
'avril',
|
|
67
|
-
'Il',
|
|
68
|
-
'était',
|
|
69
|
-
'âgé',
|
|
70
|
-
'de',
|
|
71
|
-
'87',
|
|
72
|
-
'ans',
|
|
73
|
-
'Son',
|
|
74
|
-
'Œuvre',
|
|
75
|
-
'a',
|
|
76
|
-
'été',
|
|
77
|
-
'traduite',
|
|
78
|
-
'dans',
|
|
79
|
-
'toutes',
|
|
80
|
-
'les',
|
|
81
|
-
'langues',
|
|
82
|
-
'ou',
|
|
83
|
-
'presque',
|
|
84
|
-
'et',
|
|
85
|
-
'vendue',
|
|
86
|
-
'à',
|
|
87
|
-
'quelque',
|
|
88
|
-
'50',
|
|
89
|
-
'millions',
|
|
90
|
-
'd',
|
|
91
|
-
'exemplaires']
|
|
92
|
-
|
|
93
|
-
describe('aggressive_tokenizer_fr', function () {
|
|
94
|
-
it('should tokenize strings', function () {
|
|
95
|
-
expect(tokenizer.tokenize(text)).toEqual(tokenized)
|
|
96
|
-
})
|
|
97
|
-
|
|
98
|
-
it('should handle hyphens in words correctly', function () {
|
|
99
|
-
const sentence = 'Des sous-pages dans le sous-bois de la ville de Paris'
|
|
100
|
-
const res = tokenizer.tokenize(sentence)
|
|
101
|
-
const expectedRes = ['Des', 'sous-pages', 'dans', 'le', 'sous-bois', 'de', 'la', 'ville', 'de', 'Paris']
|
|
102
|
-
expect(res).toEqual(expectedRes)
|
|
103
|
-
})
|
|
104
|
-
|
|
105
|
-
/*
|
|
106
|
-
it('should tokenize strings via attached string method', function() {
|
|
107
|
-
tokenizer.attach();
|
|
108
|
-
expect(text.tokenize()).toEqual(tokenized);
|
|
109
|
-
});
|
|
110
|
-
*/
|
|
111
|
-
})
|
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
file aggressive_tokenizer_hi_spec.js , located at spec\aggressive_tokenizer_hi_spec.js is licensed as follows:
|
|
3
|
-
- (The MIT License)
|
|
4
|
-
- Copyright (c) 2023 Mukesh Singh Bisht
|
|
5
|
-
|
|
6
|
-
Permission is hereby granted, free of charge, to any person or entity obtaining a copy
|
|
7
|
-
of file aggressive_tokenizer_hi_spec.js and its content(the "Software"), to deal in the
|
|
8
|
-
Software without restriction, including without limitation the rights to use, copy,
|
|
9
|
-
modify, merge, publish, distribute, sublicense, and/or sell copies of the Software,
|
|
10
|
-
and to permit persons to whom the Software is furnished to do so, subject to the following
|
|
11
|
-
conditions:
|
|
12
|
-
|
|
13
|
-
1. The above copyright notice and this permission notice shall be included in all copies
|
|
14
|
-
or substantial portions of the Software.
|
|
15
|
-
|
|
16
|
-
2. Proper credit must be given to the original author Mukesh Singh Bisht, along with the
|
|
17
|
-
date of authorship specified as July 23, 2023, in any usage, distribution, or
|
|
18
|
-
modification of the Software.
|
|
19
|
-
|
|
20
|
-
THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
|
21
|
-
INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
|
|
22
|
-
PURPOSE, AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
|
|
23
|
-
FOR ANY CLAIM, DAMAGES, OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT, OR
|
|
24
|
-
OTHERWISE, ARISING FROM, OUT OF, OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
|
25
|
-
DEALINGS IN THE SOFTWARE.
|
|
26
|
-
*/
|
|
27
|
-
|
|
28
|
-
'use strict'
|
|
29
|
-
|
|
30
|
-
import { AggressiveTokenizerHi } from 'lib/natural'
|
|
31
|
-
const tokenizer = new AggressiveTokenizerHi()
|
|
32
|
-
|
|
33
|
-
describe('aggressive_tokenizer_hi', function () {
|
|
34
|
-
it('should tokenize strings', function () {
|
|
35
|
-
const string = 'स्वतंत्रता दिवस की हार्दिक शुभकामनाएं'
|
|
36
|
-
const expectedArray = ['स्वतंत्रता', 'दिवस', 'की', 'हार्दिक', 'शुभकामनाएं']
|
|
37
|
-
expect(tokenizer.tokenize(string)).toEqual(expectedArray)
|
|
38
|
-
})
|
|
39
|
-
it('should tokenize strings including english words', function () {
|
|
40
|
-
const string = 'स्वतंत्रता दिवस की हार्दिक शुभकामनाएं congrats mukesh'
|
|
41
|
-
const expectedArray = ['स्वतंत्रता', 'दिवस', 'की', 'हार्दिक', 'शुभकामनाएं', 'congrats', 'mukesh']
|
|
42
|
-
expect(tokenizer.tokenize(string)).toEqual(expectedArray)
|
|
43
|
-
})
|
|
44
|
-
|
|
45
|
-
it('should swallow viram(stop) symbols', function () {
|
|
46
|
-
const string = 'स्वतंत्रता दिवस की हार्दिक शुभकामनाएं । congrats mukesh'
|
|
47
|
-
const expectedArray = ['स्वतंत्रता', 'दिवस', 'की', 'हार्दिक', 'शुभकामनाएं', 'congrats', 'mukesh']
|
|
48
|
-
expect(tokenizer.tokenize(string)).toEqual(expectedArray)
|
|
49
|
-
})
|
|
50
|
-
it('should swallow dirgh viram(stop) symbols', function () {
|
|
51
|
-
const string = 'राजा बाजीराव ॥ '
|
|
52
|
-
const expectedArray = ['राजा', 'बाजीराव']
|
|
53
|
-
expect(tokenizer.tokenize(string)).toEqual(expectedArray)
|
|
54
|
-
})
|
|
55
|
-
it('should swallow trailing off symbols', function () {
|
|
56
|
-
const string = 'राजा बाजीराव ...'
|
|
57
|
-
const expectedArray = ['राजा', 'बाजीराव']
|
|
58
|
-
expect(tokenizer.tokenize(string)).toEqual(expectedArray)
|
|
59
|
-
})
|
|
60
|
-
it('should swallow question mark symbols', function () {
|
|
61
|
-
const string = 'राजा बाजीराव ?'
|
|
62
|
-
const expectedArray = ['राजा', 'बाजीराव']
|
|
63
|
-
expect(tokenizer.tokenize(string)).toEqual(expectedArray)
|
|
64
|
-
})
|
|
65
|
-
it('should swallow comma mark symbols', function () {
|
|
66
|
-
const string = 'राजा, बाजीराव'
|
|
67
|
-
const expectedArray = ['राजा', 'बाजीराव']
|
|
68
|
-
expect(tokenizer.tokenize(string)).toEqual(expectedArray)
|
|
69
|
-
})
|
|
70
|
-
})
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
Copyright (c) 2011, Chris Umbel, Martijn de Boer
|
|
3
|
-
|
|
4
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
5
|
-
of this softwé and associated documentation files (the "Softwé"), to deal
|
|
6
|
-
in the Softwé without restriction, including without limitation the rights
|
|
7
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
8
|
-
copies of the Softwé, and to permit persons to whom the Softwé is
|
|
9
|
-
furnished to do so, subject to the following conditions:
|
|
10
|
-
|
|
11
|
-
The above copyright notice and this permission notice shall be included in
|
|
12
|
-
all copies or substantial portions of the Softwé.
|
|
13
|
-
|
|
14
|
-
THE SOFTWé IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
15
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
16
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
17
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
18
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
19
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWé OR THE USE OR OTHER DEALINGS IN
|
|
20
|
-
THE SOFTWé.
|
|
21
|
-
*/
|
|
22
|
-
|
|
23
|
-
'use strict'
|
|
24
|
-
|
|
25
|
-
import { AggressiveTokenizerNl } from 'lib/natural'
|
|
26
|
-
const tokenizer = new AggressiveTokenizerNl()
|
|
27
|
-
|
|
28
|
-
describe('aggressive_tokenizer_nl', function () {
|
|
29
|
-
it('should tokenize strings', function () {
|
|
30
|
-
expect(tokenizer.tokenize('\'s Morgens is het nog erg koud, vertelde de weerman over een van de radio\'s')).toEqual(['\'s', 'Morgens', 'is', 'het', 'nog', 'erg', 'koud', 'vertelde', 'de', 'weerman', 'over', 'een', 'van', 'de', 'radio\'s'])
|
|
31
|
-
})
|
|
32
|
-
|
|
33
|
-
it('should handle hyphens in words correctly', function () {
|
|
34
|
-
const sentence = 'clearing-systeem front-office-automatisering christelijk-historisch mond-op-mond, kant-en-klaar, kruidje-roer-me-niet, doe-het-zelver'
|
|
35
|
-
const res = tokenizer.tokenize(sentence)
|
|
36
|
-
const expectedRes = ['clearing-systeem', 'front-office-automatisering', 'christelijk-historisch', 'mond-op-mond', 'kant-en-klaar', 'kruidje-roer-me-niet', 'doe-het-zelver']
|
|
37
|
-
expect(res).toEqual(expectedRes)
|
|
38
|
-
})
|
|
39
|
-
})
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
Copyright (c) 2011, Chris Umbel
|
|
3
|
-
|
|
4
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
5
|
-
of this softwé and associated documentation files (the "Softwé"), to deal
|
|
6
|
-
in the Softwé without restriction, including without limitation the rights
|
|
7
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
8
|
-
copies of the Softwé, and to permit persons to whom the Softwé is
|
|
9
|
-
furnished to do so, subject to the following conditions:
|
|
10
|
-
|
|
11
|
-
The above copyright notice and this permission notice shall be included in
|
|
12
|
-
all copies or substantial portions of the Softwé.
|
|
13
|
-
|
|
14
|
-
THE SOFTWé IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
15
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
16
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
17
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
18
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
19
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWé OR THE USE OR OTHER DEALINGS IN
|
|
20
|
-
THE SOFTWé.
|
|
21
|
-
*/
|
|
22
|
-
|
|
23
|
-
'use strict'
|
|
24
|
-
|
|
25
|
-
import { AggressiveTokenizerPt } from 'lib/natural'
|
|
26
|
-
const tokenizer = new AggressiveTokenizerPt()
|
|
27
|
-
|
|
28
|
-
describe('aggressive_tokenizer_pt', function () {
|
|
29
|
-
it('should tokenize strings', function () {
|
|
30
|
-
expect(tokenizer.tokenize('isso é coração')).toEqual(['isso', 'é', 'coração'])
|
|
31
|
-
})
|
|
32
|
-
|
|
33
|
-
it('should swallow punctuation', function () {
|
|
34
|
-
expect(tokenizer.tokenize('isso é coração, no')).toEqual(['isso', 'é', 'coração', 'no'])
|
|
35
|
-
})
|
|
36
|
-
|
|
37
|
-
it('should swallow final punctuation', function () {
|
|
38
|
-
expect(tokenizer.tokenize('isso é coração, no?')).toEqual(['isso', 'é', 'coração', 'no'])
|
|
39
|
-
})
|
|
40
|
-
|
|
41
|
-
it('should swallow initial punctuation', function () {
|
|
42
|
-
expect(tokenizer.tokenize('.isso é coração, no')).toEqual(['isso', 'é', 'coração', 'no'])
|
|
43
|
-
})
|
|
44
|
-
|
|
45
|
-
it('should swallow duplicate punctuation', function () {
|
|
46
|
-
expect(tokenizer.tokenize('eu vou... pause')).toEqual(['eu', 'vou', 'pause'])
|
|
47
|
-
})
|
|
48
|
-
})
|
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
Copyright (c) 2011, Chris Umbel
|
|
3
|
-
|
|
4
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
5
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
6
|
-
in the Software without restriction, including without limitation the rights
|
|
7
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
8
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
9
|
-
furnished to do so, subject to the following conditions:
|
|
10
|
-
|
|
11
|
-
The above copyright notice and this permission notice shall be included in
|
|
12
|
-
all copies or substantial portions of the Software.
|
|
13
|
-
|
|
14
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
15
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
16
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
17
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
18
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
19
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
20
|
-
THE SOFTWARE.
|
|
21
|
-
*/
|
|
22
|
-
|
|
23
|
-
'use strict'
|
|
24
|
-
|
|
25
|
-
import { AggressiveTokenizer } from 'lib/natural'
|
|
26
|
-
const tokenizer = new AggressiveTokenizer()
|
|
27
|
-
|
|
28
|
-
describe('aggressive_tokenizer', function () {
|
|
29
|
-
it('should tokenize strings', function () {
|
|
30
|
-
expect(tokenizer.tokenize('these are things')).toEqual(['these', 'are', 'things'])
|
|
31
|
-
})
|
|
32
|
-
|
|
33
|
-
it('should swallow punctuation', function () {
|
|
34
|
-
expect(tokenizer.tokenize('these are things, no')).toEqual(['these', 'are', 'things', 'no'])
|
|
35
|
-
})
|
|
36
|
-
|
|
37
|
-
it('should swallow final punctuation', function () {
|
|
38
|
-
expect(tokenizer.tokenize('these are things, no?')).toEqual(['these', 'are', 'things', 'no'])
|
|
39
|
-
})
|
|
40
|
-
|
|
41
|
-
it('should swallow initial punctuation', function () {
|
|
42
|
-
expect(tokenizer.tokenize('.these are things, no')).toEqual(['these', 'are', 'things', 'no'])
|
|
43
|
-
})
|
|
44
|
-
|
|
45
|
-
it('should swallow duplicate punctuation', function () {
|
|
46
|
-
expect(tokenizer.tokenize('i shal... pause')).toEqual(['i', 'shal', 'pause'])
|
|
47
|
-
})
|
|
48
|
-
|
|
49
|
-
it('should remove underscores', function () {
|
|
50
|
-
expect(tokenizer.tokenize('_ hi_this_is_a_test_case_ for__removing___underscores_')).toEqual(['hi', 'this', 'is', 'a', 'test', 'case', 'for', 'removing', 'underscores'])
|
|
51
|
-
})
|
|
52
|
-
|
|
53
|
-
it('should handle the use of hyphen inside words (issue #656)', function () {
|
|
54
|
-
expect(tokenizer.tokenize('links text-based opposed image-based links/CTA\'s')).toEqual(
|
|
55
|
-
['links', 'text-based', 'opposed', 'image-based', 'links/CTA\'s'])
|
|
56
|
-
})
|
|
57
|
-
})
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
Copyright (c) 2011, Chris Umbel
|
|
3
|
-
|
|
4
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
5
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
6
|
-
in the Software without restriction, including without limitation the rights
|
|
7
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
8
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
9
|
-
furnished to do so, subject to the following conditions:
|
|
10
|
-
|
|
11
|
-
The above copyright notice and this permission notice shall be included in
|
|
12
|
-
all copies or substantial portions of the Software.
|
|
13
|
-
|
|
14
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
15
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
16
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
17
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
18
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
19
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
20
|
-
THE SOFTWARE.
|
|
21
|
-
*/
|
|
22
|
-
|
|
23
|
-
'use strict'
|
|
24
|
-
|
|
25
|
-
import { AggressiveTokenizerSv } from 'lib/natural'
|
|
26
|
-
const tokenizer = new AggressiveTokenizerSv()
|
|
27
|
-
|
|
28
|
-
describe('aggressive_tokenizer_sv', function () {
|
|
29
|
-
it('should tokenize strings', function () {
|
|
30
|
-
expect(tokenizer.tokenize('Ett tu tre')).toEqual(['Ett', 'tu', 'tre'])
|
|
31
|
-
})
|
|
32
|
-
|
|
33
|
-
it('should swallow punctuation', function () {
|
|
34
|
-
expect(tokenizer.tokenize('Ett, tu, tre')).toEqual(['Ett', 'tu', 'tre'])
|
|
35
|
-
})
|
|
36
|
-
|
|
37
|
-
it('should swallow final punctuation', function () {
|
|
38
|
-
expect(tokenizer.tokenize('Ett, tu, tre?')).toEqual(['Ett', 'tu', 'tre'])
|
|
39
|
-
})
|
|
40
|
-
|
|
41
|
-
it('should swallow initial punctuation', function () {
|
|
42
|
-
expect(tokenizer.tokenize('.Ett, tu, tre')).toEqual(['Ett', 'tu', 'tre'])
|
|
43
|
-
})
|
|
44
|
-
|
|
45
|
-
it('should swallow duplicate punctuation', function () {
|
|
46
|
-
expect(tokenizer.tokenize('Ett, tu... tre')).toEqual(['Ett', 'tu', 'tre'])
|
|
47
|
-
})
|
|
48
|
-
|
|
49
|
-
it('should not split on hyphen or Swedish letters', function () {
|
|
50
|
-
expect(tokenizer.tokenize('It-bolaget ägs av en 30-åring')).toEqual(['It-bolaget', 'ägs', 'av', 'en', '30-åring'])
|
|
51
|
-
})
|
|
52
|
-
})
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
Copyright (c) 2018, Hugo W.L. ter Doest
|
|
3
|
-
|
|
4
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
5
|
-
of this softwé and associated documentation files (the "Softwé"), to deal
|
|
6
|
-
in the Softwé without restriction, including without limitation the rights
|
|
7
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
8
|
-
copies of the Softwé, and to permit persons to whom the Softwé is
|
|
9
|
-
furnished to do so, subject to the following conditions:
|
|
10
|
-
|
|
11
|
-
The above copyright notice and this permission notice shall be included in
|
|
12
|
-
all copies or substantial portions of the Softwé.
|
|
13
|
-
|
|
14
|
-
THE SOFTWé IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
15
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
16
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
17
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
18
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
19
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWé OR THE USE OR OTHER DEALINGS IN
|
|
20
|
-
THE SOFTWARE.
|
|
21
|
-
*/
|
|
22
|
-
|
|
23
|
-
'use strict'
|
|
24
|
-
|
|
25
|
-
import { AggressiveTokenizerVi } from 'lib/natural'
|
|
26
|
-
const tokenizer = new AggressiveTokenizerVi()
|
|
27
|
-
|
|
28
|
-
describe('aggressive_tokenizer_vi', function () {
|
|
29
|
-
it('should tokenize strings', function () {
|
|
30
|
-
expect(tokenizer.tokenize('Tôi bị lạc')).toEqual(['Tôi', 'bị', 'lạc'])
|
|
31
|
-
})
|
|
32
|
-
|
|
33
|
-
it('should swallow final punctuation', function () {
|
|
34
|
-
expect(tokenizer.tokenize('Làm ơn đợi một lát!')).toEqual(['Làm', 'ơn', 'đợi', 'một', 'lát'])
|
|
35
|
-
})
|
|
36
|
-
|
|
37
|
-
it('should swallow final punctuation', function () {
|
|
38
|
-
expect(tokenizer.tokenize('Tôi đang tìm John.')).toEqual(['Tôi', 'đang', 'tìm', 'John'])
|
|
39
|
-
})
|
|
40
|
-
|
|
41
|
-
it('should swallow initial punctuation', function () {
|
|
42
|
-
expect(tokenizer.tokenize('.Đi thẳng, sau đó rẽ trái / phải')).toEqual(['Đi', 'thẳng', 'sau', 'đó', 'rẽ', 'trái', 'phải'])
|
|
43
|
-
})
|
|
44
|
-
|
|
45
|
-
it('should swallow duplicate punctuation', function () {
|
|
46
|
-
expect(tokenizer.tokenize('.Xin giữ máy!')).toEqual(['Xin', 'giữ', 'máy'])
|
|
47
|
-
})
|
|
48
|
-
})
|
|
@@ -1,165 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
Copyright (c) 2011, Chris Umbel
|
|
3
|
-
|
|
4
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
5
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
6
|
-
in the Software without restriction, including without limitation the rights
|
|
7
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
8
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
9
|
-
furnished to do so, subject to the following conditions:
|
|
10
|
-
|
|
11
|
-
The above copyright notice and this permission notice shall be included in
|
|
12
|
-
all copies or substantial portions of the Software.
|
|
13
|
-
|
|
14
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
15
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
16
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
17
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
18
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
19
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
20
|
-
THE SOFTWARE.
|
|
21
|
-
*/
|
|
22
|
-
|
|
23
|
-
'use strict'
|
|
24
|
-
|
|
25
|
-
import { BayesClassifier, PorterStemmer } from 'lib/natural'
|
|
26
|
-
|
|
27
|
-
function setupClassifier (): BayesClassifier {
|
|
28
|
-
const classifier = new BayesClassifier()
|
|
29
|
-
classifier.addDocument(['fix', 'box'], 'computing')
|
|
30
|
-
classifier.addDocument(['write', 'code'], 'computing')
|
|
31
|
-
classifier.addDocument(['script', 'code'], 'computing')
|
|
32
|
-
classifier.addDocument(['write', 'book'], 'literature')
|
|
33
|
-
classifier.addDocument(['read', 'book'], 'literature')
|
|
34
|
-
classifier.addDocument(['study', 'book'], 'literature')
|
|
35
|
-
return classifier
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
describe('bayes classifier', function () {
|
|
39
|
-
describe('classifier', function () {
|
|
40
|
-
it('should classify with arrays', function () {
|
|
41
|
-
const classifier = setupClassifier()
|
|
42
|
-
classifier.train()
|
|
43
|
-
expect(classifier.classify(['bug', 'code'])).toBe('computing')
|
|
44
|
-
expect(classifier.classify(['read', 'thing'])).toBe('literature')
|
|
45
|
-
})
|
|
46
|
-
|
|
47
|
-
it('should classify with parallel training', function () {
|
|
48
|
-
const classifier = setupClassifier()
|
|
49
|
-
// Check for parallel method
|
|
50
|
-
if (classifier.Threads !== null) {
|
|
51
|
-
classifier.trainParallel(2, function (err) {
|
|
52
|
-
if (err !== null) {
|
|
53
|
-
console.log(err)
|
|
54
|
-
return
|
|
55
|
-
}
|
|
56
|
-
expect(classifier.classify(['bug', 'code'])).toBe('computing')
|
|
57
|
-
expect(classifier.classify(['read', 'thing'])).toBe('literature')
|
|
58
|
-
})
|
|
59
|
-
}
|
|
60
|
-
})
|
|
61
|
-
|
|
62
|
-
it('should classify with parallel batched training', function () {
|
|
63
|
-
const classifier = setupClassifier()
|
|
64
|
-
// Check for parallel method
|
|
65
|
-
if (classifier.Threads !== null) {
|
|
66
|
-
classifier.on('doneTraining', function () {
|
|
67
|
-
expect(classifier.classify(['bug', 'code'])).toBe('computing')
|
|
68
|
-
expect(classifier.classify(['read', 'thing'])).toBe('literature')
|
|
69
|
-
// asyncSpecDone();
|
|
70
|
-
})
|
|
71
|
-
classifier.trainParallelBatches({ numThreads: 2, batchSize: 2 })
|
|
72
|
-
}
|
|
73
|
-
})
|
|
74
|
-
|
|
75
|
-
it('should provide all classification scores', function () {
|
|
76
|
-
const classifier = setupClassifier()
|
|
77
|
-
classifier.train()
|
|
78
|
-
|
|
79
|
-
expect(classifier.getClassifications('i write code')[0].label).toBe('computing')
|
|
80
|
-
expect(classifier.getClassifications('i write code')[1].label).toBe('literature')
|
|
81
|
-
})
|
|
82
|
-
|
|
83
|
-
function setupClassifierWithSentences (): BayesClassifier {
|
|
84
|
-
const classifier = new BayesClassifier()
|
|
85
|
-
classifier.addDocument('i fixed the box', 'computing')
|
|
86
|
-
classifier.addDocument('i write code', 'computing')
|
|
87
|
-
classifier.addDocument('nasty script code', 'computing')
|
|
88
|
-
classifier.addDocument('write a book', 'literature')
|
|
89
|
-
classifier.addDocument('read a book', 'literature')
|
|
90
|
-
classifier.addDocument('study the books', 'literature')
|
|
91
|
-
return classifier
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
it('should classify with strings', function () {
|
|
95
|
-
const classifier = setupClassifierWithSentences()
|
|
96
|
-
classifier.train()
|
|
97
|
-
expect(classifier.classify('a bug in the code')).toBe('computing')
|
|
98
|
-
expect(classifier.classify('read all the books')).toBe('literature')
|
|
99
|
-
})
|
|
100
|
-
|
|
101
|
-
it('should classify and re-classify after document-removal', function () {
|
|
102
|
-
const classifier = new BayesClassifier()
|
|
103
|
-
const classifications = new Map<string, number>()
|
|
104
|
-
|
|
105
|
-
// Add some good/bad docs and train
|
|
106
|
-
classifier.addDocument('foo bar baz', 'good')
|
|
107
|
-
classifier.addDocument('qux zooby', 'bad')
|
|
108
|
-
classifier.addDocument('asdf qwer', 'bad')
|
|
109
|
-
classifier.train()
|
|
110
|
-
|
|
111
|
-
expect(classifier.classify('foo')).toBe('good')
|
|
112
|
-
expect(classifier.classify('qux')).toBe('bad')
|
|
113
|
-
|
|
114
|
-
// Remove one of the bad docs, retrain
|
|
115
|
-
classifier.removeDocument('qux zooby', 'bad')
|
|
116
|
-
classifier.retrain()
|
|
117
|
-
|
|
118
|
-
// Simple `classify` will still return a single result, even if
|
|
119
|
-
// ratio for each side is equal -- have to compare actual values in
|
|
120
|
-
// the classifications, should be equal since qux is unclassified
|
|
121
|
-
const arr = classifier.getClassifications('qux')
|
|
122
|
-
let item: { label: string, value: number }
|
|
123
|
-
for (let i = 0, ii = arr.length; i < ii; i++) {
|
|
124
|
-
item = arr[i]
|
|
125
|
-
classifications.set(item.label, item.value)
|
|
126
|
-
}
|
|
127
|
-
expect(classifications.get('good')).toEqual(classifications.get('bad'))
|
|
128
|
-
|
|
129
|
-
// Re-classify as good, retrain
|
|
130
|
-
classifier.addDocument('qux zooby', 'good')
|
|
131
|
-
classifier.retrain()
|
|
132
|
-
|
|
133
|
-
// Should now be good, original docs should be unaffected
|
|
134
|
-
expect(classifier.classify('foo')).toBe('good')
|
|
135
|
-
expect(classifier.classify('qux')).toBe('good')
|
|
136
|
-
})
|
|
137
|
-
|
|
138
|
-
it('should serialize and deserialize a working classifier', function () {
|
|
139
|
-
const classifier = setupClassifierWithSentences()
|
|
140
|
-
const objAsString = JSON.stringify(classifier)
|
|
141
|
-
const obj: Record<string, unknown> = JSON.parse(objAsString)
|
|
142
|
-
const newClassifier = BayesClassifier.restore(obj)
|
|
143
|
-
|
|
144
|
-
newClassifier.addDocument('kick a ball', 'sports')
|
|
145
|
-
newClassifier.addDocument('hit some balls', 'sports')
|
|
146
|
-
newClassifier.addDocument('kick and punch', 'sports')
|
|
147
|
-
|
|
148
|
-
newClassifier.train()
|
|
149
|
-
|
|
150
|
-
expect(newClassifier.classify('a bug in the code')).toBe('computing')
|
|
151
|
-
expect(newClassifier.classify('read all the books')).toBe('literature')
|
|
152
|
-
expect(newClassifier.classify('kick butt')).toBe('sports')
|
|
153
|
-
})
|
|
154
|
-
|
|
155
|
-
it('should accept an optional smoothing parameter for the Bayesian estimates', function () {
|
|
156
|
-
const defaultClassifier = new BayesClassifier()
|
|
157
|
-
const newClassifier1 = new BayesClassifier(PorterStemmer)
|
|
158
|
-
const newClassifier2 = new BayesClassifier(PorterStemmer, 0.1)
|
|
159
|
-
|
|
160
|
-
expect(defaultClassifier.classifier.smoothing).toBe(1.0)
|
|
161
|
-
expect(newClassifier1.classifier.smoothing).toBe(1.0)
|
|
162
|
-
expect(newClassifier2.classifier.smoothing).toBe(0.1)
|
|
163
|
-
})
|
|
164
|
-
})
|
|
165
|
-
})
|
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
Unit test for Brill's POS Tagger: test against the pos module
|
|
3
|
-
Copyright (C) 2019 Hugo W.L. ter Doest
|
|
4
|
-
|
|
5
|
-
This program is free software: you can redistribute it and/or modify
|
|
6
|
-
it under the terms of the GNU General Public License as published by
|
|
7
|
-
the Free Software Foundation, either version 3 of the License, or
|
|
8
|
-
(at your option) any later version.
|
|
9
|
-
|
|
10
|
-
This program is distributed in the hope that it will be useful,
|
|
11
|
-
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
12
|
-
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
13
|
-
GNU General Public License for more details.
|
|
14
|
-
|
|
15
|
-
You should have received a copy of the GNU General Public License
|
|
16
|
-
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
17
|
-
*/
|
|
18
|
-
|
|
19
|
-
'use strict'
|
|
20
|
-
|
|
21
|
-
import { WordTokenizer, Lexicon, RuleSet, BrillPOSTagger } from 'lib/natural'
|
|
22
|
-
import type { Sentence, TagResults } from 'lib/natural'
|
|
23
|
-
|
|
24
|
-
import * as englishSentences from '../spec/test_data/NYT-20150205-picassos-granddaughter-plans-to-sell-art-worrying-the-market.json'
|
|
25
|
-
|
|
26
|
-
import jsonData from '../spec/test_data/NYT-20150205-picassos-granddaughter-plans_expected_tag_results.json'
|
|
27
|
-
|
|
28
|
-
import * as dutchSentences from '../spec/test_data/Volkskrant-20150205-Knot-geldpers-aanzetten-is-paardenmiddel-voor-half-procent-inflatie.json'
|
|
29
|
-
|
|
30
|
-
const englishTagResults: TagResults = jsonData as TagResults
|
|
31
|
-
const DEBUG = false
|
|
32
|
-
|
|
33
|
-
// Compares two tagged sentences. First one is in the old POSJS format, i.e.
|
|
34
|
-
// an array of two position arrays. The second one is a Sentence object
|
|
35
|
-
// that holds an array of objects for each position {token: "string", tag: "string"}
|
|
36
|
-
function compareTaggedSentences (sentenceInOldFormat: string[][], sentenceInNewFormat: Sentence): boolean {
|
|
37
|
-
let equal = true
|
|
38
|
-
sentenceInOldFormat.forEach(function (wordPlusTag: string[], index: number) {
|
|
39
|
-
equal = equal &&
|
|
40
|
-
(wordPlusTag[1] === sentenceInNewFormat.taggedWords[index].tag)
|
|
41
|
-
DEBUG && console.log(wordPlusTag[1] + ' ' + sentenceInNewFormat.taggedWords[index].tag)
|
|
42
|
-
})
|
|
43
|
-
return equal
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
describe('Brill\'s POS Tagger', function () {
|
|
47
|
-
let brillPOSTagger: BrillPOSTagger
|
|
48
|
-
let lexicon: Lexicon
|
|
49
|
-
let ruleSet: RuleSet
|
|
50
|
-
const tokenizer = new WordTokenizer()
|
|
51
|
-
|
|
52
|
-
it('should process an English newspaper article just like the dariusk/pos-js module', function () {
|
|
53
|
-
lexicon = new Lexicon('EN', 'NN')
|
|
54
|
-
expect(lexicon.nrEntries()).toBeGreaterThan(0)
|
|
55
|
-
ruleSet = new RuleSet('EN')
|
|
56
|
-
expect(ruleSet.nrRules()).toBeGreaterThan(0)
|
|
57
|
-
brillPOSTagger = new BrillPOSTagger(lexicon, ruleSet)
|
|
58
|
-
|
|
59
|
-
englishSentences.sentences.forEach(function (sentence: string, index: number) {
|
|
60
|
-
const tokenizedSentence = tokenizer.tokenize(sentence)
|
|
61
|
-
const taggedSentence = brillPOSTagger.tag(tokenizedSentence)
|
|
62
|
-
expect(compareTaggedSentences(englishTagResults.results[index], taggedSentence)).toBe(true)
|
|
63
|
-
})
|
|
64
|
-
})
|
|
65
|
-
|
|
66
|
-
it('should tag a Dutch news paper article', function () {
|
|
67
|
-
lexicon = new Lexicon('DU', 'N')
|
|
68
|
-
expect(lexicon.nrEntries()).toBeGreaterThan(0)
|
|
69
|
-
const ruleSet = new RuleSet('DU')
|
|
70
|
-
expect(ruleSet.nrRules()).toBeGreaterThan(0)
|
|
71
|
-
brillPOSTagger = new BrillPOSTagger(lexicon, ruleSet)
|
|
72
|
-
|
|
73
|
-
dutchSentences.sentences.forEach(function (sentence, index) {
|
|
74
|
-
const tokenizedSentence = tokenizer.tokenize(sentence)
|
|
75
|
-
const taggedSentence = brillPOSTagger.tag(tokenizedSentence)
|
|
76
|
-
expect(tokenizedSentence.length).toEqual(taggedSentence.taggedWords.length)
|
|
77
|
-
})
|
|
78
|
-
})
|
|
79
|
-
})
|