natural 7.0.3 → 7.0.6

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.
Files changed (70) hide show
  1. package/.github/workflows/npm-publish.yml +2 -0
  2. package/.nycrc +9 -0
  3. package/lib/natural/classifiers/logistic_regression_classifier.js +1 -1
  4. package/package.json +3 -4
  5. package/tsconfig.json +1 -1
  6. package/ts_spec/MaxEntClassifier_spec.ts +0 -130
  7. package/ts_spec/SentimentAnalyzer_spec.ts +0 -232
  8. package/ts_spec/WordPunctTokenizer_spec.ts +0 -57
  9. package/ts_spec/aggressive_tokenizer_de_spec.ts +0 -36
  10. package/ts_spec/aggressive_tokenizer_es_spec.ts +0 -39
  11. package/ts_spec/aggressive_tokenizer_fr_spec.ts +0 -111
  12. package/ts_spec/aggressive_tokenizer_hi_spec.ts +0 -70
  13. package/ts_spec/aggressive_tokenizer_nl_spec.ts +0 -39
  14. package/ts_spec/aggressive_tokenizer_pt_spec.ts +0 -48
  15. package/ts_spec/aggressive_tokenizer_spec.ts +0 -57
  16. package/ts_spec/aggressive_tokenizer_sv_spec.ts +0 -52
  17. package/ts_spec/aggressive_tokenizer_vi_spec.ts +0 -48
  18. package/ts_spec/bayes_classifier_spec.ts +0 -165
  19. package/ts_spec/brill_pos_tagger_spec.ts +0 -79
  20. package/ts_spec/brill_pos_trainer_spec.ts +0 -107
  21. package/ts_spec/carry_stemmer_fr_spec.ts +0 -97
  22. package/ts_spec/classifier_spec.ts +0 -104
  23. package/ts_spec/count_inflector_fr_spec.ts +0 -47
  24. package/ts_spec/count_inflector_spec.ts +0 -76
  25. package/ts_spec/damerau_levenshtein_spec.ts +0 -53
  26. package/ts_spec/dice_coefficient_spec.ts +0 -37
  27. package/ts_spec/double_metaphone_spec.ts +0 -739
  28. package/ts_spec/hamming_distance_spec.ts +0 -66
  29. package/ts_spec/jaro-winkler_spec.ts +0 -79
  30. package/ts_spec/lancaster_stemmer_spec.ts +0 -63
  31. package/ts_spec/levenshtein_spec.ts +0 -107
  32. package/ts_spec/logistic_regression_classifier_spec.ts +0 -93
  33. package/ts_spec/longest_path_tree_spec.ts +0 -111
  34. package/ts_spec/metaphone_spec.ts +0 -258
  35. package/ts_spec/ngram_spec.ts +0 -145
  36. package/ts_spec/ngram_zh_spec.ts +0 -124
  37. package/ts_spec/normalizer_ja_spec.ts +0 -165
  38. package/ts_spec/normalizer_no_spec.ts +0 -112
  39. package/ts_spec/normalizer_spec.ts +0 -141
  40. package/ts_spec/noun_inflector_fr_spec.ts +0 -472
  41. package/ts_spec/noun_inflector_ja_spec.ts +0 -116
  42. package/ts_spec/noun_inflector_spec.ts +0 -369
  43. package/ts_spec/orthography_tokenizer_spec.ts +0 -47
  44. package/ts_spec/porter_stemmer_de_spec.ts +0 -53
  45. package/ts_spec/porter_stemmer_es_spec.ts +0 -63
  46. package/ts_spec/porter_stemmer_fr_spec.ts +0 -103
  47. package/ts_spec/porter_stemmer_it_spec.ts +0 -56
  48. package/ts_spec/porter_stemmer_nl_spec.ts +0 -73
  49. package/ts_spec/porter_stemmer_no_spec.ts +0 -148
  50. package/ts_spec/porter_stemmer_pt_spec.ts +0 -50
  51. package/ts_spec/porter_stemmer_ru_spec.ts +0 -67
  52. package/ts_spec/porter_stemmer_spec.ts +0 -202
  53. package/ts_spec/porter_stemmer_sv_spec.ts +0 -41
  54. package/ts_spec/present_verb_inflector_spec.ts +0 -127
  55. package/ts_spec/remove_diacritics_spec.ts +0 -30
  56. package/ts_spec/sentence_analyzer_spec.ts +0 -293
  57. package/ts_spec/sentence_tokenizer_parser_spec.ts +0 -200
  58. package/ts_spec/sentence_tokenizer_spec.ts +0 -189
  59. package/ts_spec/shortest_path_tree_spec.ts +0 -141
  60. package/ts_spec/soundex_spec.ts +0 -162
  61. package/ts_spec/spellcheck_spec.ts +0 -112
  62. package/ts_spec/stemmer_id_spec.ts +0 -374
  63. package/ts_spec/stemmer_ja_spec.ts +0 -69
  64. package/ts_spec/stemmer_token_spec.ts +0 -163
  65. package/ts_spec/tfidf_spec.ts +0 -275
  66. package/ts_spec/tokenizer_case_spec.ts +0 -242
  67. package/ts_spec/tokenizer_ja_spec.ts +0 -63
  68. package/ts_spec/transliterator_ja_spec.ts +0 -105
  69. package/ts_spec/treebank_word_tokenizer_spec.ts +0 -38
  70. package/ts_spec/trie_spec.ts +0 -197
@@ -1,56 +0,0 @@
1
- /*
2
- Copyright (c) 2019, Leonardo Fenu, Chris Umbel, Hugo W.L. ter Doest
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 { PorterStemmerIt as stemmer } from 'lib/natural'
26
- import rawJson from '../spec/test_data/snowball_it.json'
27
- const snowBallDict = rawJson as Record<string, string>
28
-
29
- describe('porter_stemmer_it', function () {
30
- it('should perform stem', function () {
31
- const errors = []
32
- Object.keys(snowBallDict).forEach(word => {
33
- const stemmed = stemmer.stem(word)
34
- const expectedStem = snowBallDict[word]
35
- if (stemmed !== snowBallDict[word]) {
36
- console.log('Error:', word, 'Expected:', expectedStem, 'Got:', stemmed)
37
- errors.push({
38
- word,
39
- expected: expectedStem,
40
- actual: stemmed
41
- })
42
- }
43
- })
44
-
45
- expect(errors.length).toEqual(0)
46
- })
47
-
48
- /*
49
- it('should tokenize and stem attached', function() {
50
- stemmer.attach();
51
-
52
- expect('SOPRA la panca la capra CAMPA'.tokenizeAndStem()).toEqual([ 'sopr', 'panc', 'capr', 'camp' ]);
53
- expect('SOTTO la panca la capra CREPA'.tokenizeAndStem()).toEqual([ 'sott', 'panc', 'capr', 'crep' ]);
54
- });
55
- */
56
- })
@@ -1,73 +0,0 @@
1
- /*
2
- Copyright (c) 2019, Hugo W.L. ter Doest
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 { PorterStemmerNl as stemmer } from 'lib/natural'
26
- import rawObj from '../spec/test_data/snowball_nl.json'
27
- const snowBallDict = rawObj as Record<string, string>
28
- // const dutchSentences = require('spec/test_data/Volkskrant-20150205-Knot-geldpers-aanzetten-is-paardenmiddel-voor-half-procent-inflatie.json')
29
- // const dutchStemResults = require('spec/test_data/dutchStemResults.json')
30
-
31
- const DEBUG = false
32
-
33
- describe('porter_stemmer_nl', function () {
34
- it('should perform stemming on a lot of words', function () {
35
- const errors = []
36
-
37
- Object.keys(snowBallDict).forEach(word => {
38
- const stemmed = stemmer.stem(word)
39
- const expectedStem = snowBallDict[word]
40
- if (stemmed !== snowBallDict[word]) {
41
- DEBUG && console.log('Error:', word, 'Expected:', expectedStem, 'Got:', stemmed)
42
- errors.push({
43
- word,
44
- expected: expectedStem,
45
- actual: stemmed
46
- })
47
- }
48
- })
49
-
50
- // The stemmer has an error count of 237 against the snowball list for nl that has 45669 entries
51
- expect(errors.length).toEqual(237)
52
- })
53
-
54
- // Commented out because hyphens are not processed correctly in the expected results
55
- /*
56
- it('should tokenize a piece of text', function () {
57
- dutchSentences.sentences.forEach((sentence, index) => {
58
- const result = stemmer.tokenizeAndStem(sentence, true)
59
- DEBUG && console.log(result)
60
- expect(result).toEqual(dutchStemResults.results[index])
61
- })
62
- })
63
- */
64
-
65
- /*
66
- it('should work with the attached notation', function() {
67
- stemmer.attach();
68
- expect("mogelijkheid".stem()).toEqual("mogelijk");
69
- expect("Knot: geldpers aanzetten is paardenmiddel voor half procent inflatie".tokenizeAndStem(true)).toEqual(
70
- [ 'knot', 'geldper', 'aanzet', 'is', 'paardenmiddel', 'vor', 'half', 'procent', 'inflatie' ]);
71
- });
72
- */
73
- })
@@ -1,148 +0,0 @@
1
- /*
2
- Copyright (c) 2019, Kristoffer Brabrand, Hugo W.L. ter Doest
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 { PorterStemmerNo as stemmer } from 'lib/natural'
26
- import rawObj from '../spec/test_data/snowball_no.json'
27
- const snowBallDict = rawObj as Record<string, string>
28
-
29
- describe('porter_stemmer_no', function () {
30
- it('should perform step 1a', function () {
31
- expect(stemmer.step1a('forenkla')).toBe('forenkl')
32
- expect(stemmer.step1a('aase')).toBe('aas')
33
- expect(stemmer.step1a('allerede')).toBe('aller')
34
- expect(stemmer.step1a('aukande')).toBe('auk')
35
- expect(stemmer.step1a('avbøtende')).toBe('avbøt')
36
- expect(stemmer.step1a('avdelingane')).toBe('avdeling')
37
- expect(stemmer.step1a('avgiftene')).toBe('avgift')
38
- expect(stemmer.step1a('havnevirksomhetene')).toBe('havnevirksom')
39
- expect(stemmer.step1a('heimelen')).toBe('heimel')
40
- expect(stemmer.step1a('hovedvirksomheten')).toBe('hovedvirksom')
41
- expect(stemmer.step1a('hovudreglar')).toBe('hovudregl')
42
- expect(stemmer.step1a('hugger')).toBe('hugg')
43
- expect(stemmer.step1a('importvirksomheter')).toBe('importvirksom')
44
- expect(stemmer.step1a('ivaretas')).toBe('ivaret')
45
- expect(stemmer.step1a('iverksettes')).toBe('iverksett')
46
- expect(stemmer.step1a('konsekvensutredes')).toBe('konsekvensutr')
47
- expect(stemmer.step1a('oversendes')).toBe('overs')
48
- expect(stemmer.step1a('pensjonenes')).toBe('pensjon')
49
- expect(stemmer.step1a('myndighetenes')).toBe('myndig')
50
- expect(stemmer.step1a('møteleiarens')).toBe('møteleiar')
51
- expect(stemmer.step1a('virksomhetens')).toBe('virksom')
52
- expect(stemmer.step1a('aktørers')).toBe('aktør')
53
- expect(stemmer.step1a('arbeidslivets')).toBe('arbeidsliv')
54
- expect(stemmer.step1a('arbeidskapasitet')).toBe('arbeidskapasit')
55
- expect(stemmer.step1a('arealknapphet')).toBe('arealknapp')
56
- expect(stemmer.step1a('attgjevast')).toBe('attgjev')
57
- })
58
-
59
- it('should perform step 1b', function () {
60
- expect(stemmer.step1b('hinder')).toBe('hinder')
61
- expect(stemmer.step1b('erwerbs')).toBe('erwerb')
62
- expect(stemmer.step1b('alltids')).toBe('alltid')
63
- })
64
-
65
- it('should perform step 1c', function () {
66
- expect(stemmer.step1c('akkumulerte')).toBe('akkumuler')
67
- expect(stemmer.step1c('akseptert')).toBe('aksepter')
68
- })
69
-
70
- it('should perform step 1 (a-c)', function () {
71
- expect(stemmer.step1('andelar')).toBe('andel')
72
- expect(stemmer.step1('andeleigar')).toBe('andeleig')
73
- expect(stemmer.step1('andeleigarane')).toBe('andeleigar')
74
- expect(stemmer.step1('andeleigarbok')).toBe('andeleigarbok')
75
- expect(stemmer.step1('andelen')).toBe('andel')
76
- expect(stemmer.step1('andelene')).toBe('andel')
77
- expect(stemmer.step1('andeler')).toBe('andel')
78
- expect(stemmer.step1('andelsbevis')).toBe('andelsbevis')
79
- expect(stemmer.step1('andelsbok')).toBe('andelsbok')
80
- expect(stemmer.step1('andelsboka')).toBe('andelsbok')
81
- expect(stemmer.step1('andelsboligforening')).toBe('andelsboligforening')
82
- expect(stemmer.step1('andelsboligforeninger')).toBe('andelsboligforening')
83
- expect(stemmer.step1('andelsboligorganisation')).toBe('andelsboligorganisation')
84
- expect(stemmer.step1('andelsboligorganisationer')).toBe('andelsboligorganisation')
85
- expect(stemmer.step1('andelsbrev')).toBe('andelsbrev')
86
- })
87
-
88
- it('should perform step 2', function () {
89
- expect(stemmer.step2('hvorvidt')).toBe('hvorvid')
90
- expect(stemmer.step2('innovativt')).toBe('innovativ')
91
- })
92
-
93
- it('should perform step 3', function () {
94
- expect(stemmer.step3('lovleg')).toBe('lov')
95
- expect(stemmer.step3('konkurranseskadeleg')).toBe('konkurranseskad')
96
- expect(stemmer.step3('lystig')).toBe('lyst')
97
- expect(stemmer.step3('utrolig')).toBe('utro')
98
- expect(stemmer.step3('utrøstelig')).toBe('utrøst')
99
- expect(stemmer.step3('boliglov')).toBe('bolig')
100
- expect(stemmer.step3('samvirkelov')).toBe('samvirk')
101
- expect(stemmer.step3('arveavgiftslov')).toBe('arveavgift')
102
- })
103
-
104
- it('should perform stemming on a lot of words', function () {
105
- const ok = []
106
- const ko = []
107
-
108
- Object.keys(snowBallDict).forEach(word => {
109
- const stemmed = stemmer.stem(word)
110
- const expectedStem = snowBallDict[word]
111
-
112
- if (stemmed === expectedStem) {
113
- ok.push(word)
114
- } else {
115
- ko.push({
116
- word,
117
- expected: expectedStem,
118
- actual: stemmed
119
- })
120
- }
121
- })
122
-
123
- expect(ko.length).toBe(0)
124
- })
125
-
126
- it('should perform complete stemming', function () {
127
- /*
128
- expect(stemmer.step1a('forenkla')).toBe('forenkl')
129
- expect(stemmer.step1a('aase')).toBe('aas')
130
- expect(stemmer.step1a('allerede')).toBe('aller')
131
- expect(stemmer.step1a('aukande')).toBe('auk')
132
- */
133
- expect(stemmer.step1a('avbøtende')).toBe('avbøt')
134
- expect(stemmer.step1b('hinder')).toBe('hinder')
135
- expect(stemmer.step1b('erwerbs')).toBe('erwerb')
136
- expect(stemmer.step3('boliglov')).toBe('bolig')
137
- expect(stemmer.step3('samvirkelov')).toBe('samvirk')
138
- expect(stemmer.step3('arveavgiftslov')).toBe('arveavgift')
139
- })
140
-
141
- /*
142
- it('should tokenize and stem attached', function() {
143
- stemmer.attach();
144
- expect('forebygger vedlikeholdsbehovene'.tokenizeAndStem()).toEqual(['forebygg', 'vedlikeholdsbehov']);
145
- expect('FOREBYGGER VEDLIKEHOLDSBEHOVENE'.tokenizeAndStem()).toEqual(['forebygg', 'vedlikeholdsbehov']);
146
- });
147
- */
148
- })
@@ -1,50 +0,0 @@
1
- /*
2
- Copyright (c) 2019, Luís Rodrigues, Hugo W.L. ter Doest
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 { PorterStemmerPt as stemmer } from 'lib/natural'
26
- import rawObj from '../spec/test_data/snowball_pt.json'
27
- const snowBallDict = rawObj as Record<string, string>
28
-
29
- const DEBUG = false
30
-
31
- describe('porter_stemmer_pt', function () {
32
- it('should perform stemming on a lot of words', function () {
33
- const errors = []
34
-
35
- Object.keys(snowBallDict).forEach(word => {
36
- const stemmed = stemmer.stem(word)
37
- const expectedStem = snowBallDict[word]
38
- if (stemmed !== snowBallDict[word]) {
39
- DEBUG && console.log('Error:', word, 'Expected:', expectedStem, 'Got:', stemmed)
40
- errors.push({
41
- word,
42
- expected: expectedStem,
43
- actual: stemmed
44
- })
45
- }
46
- })
47
-
48
- expect(errors.length).toEqual(0)
49
- })
50
- })
@@ -1,67 +0,0 @@
1
- /*
2
- Copyright (c) 2011, Polyakov Vladimir, 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 { PorterStemmerRu as stemmer } from 'lib/natural'
26
-
27
- const test = [
28
- 'в', 'вавиловка', 'вагнера', 'вагон', 'вагона', 'вагоне', 'вагонов', 'вагоном', 'вагоны',
29
- 'важная', 'важнее', 'важнейшие', 'важнейшими', 'важничал', 'важно', 'важного', 'важное',
30
- 'важной', 'важном', 'важному', 'важности', 'важностию', 'важность', 'важностью', 'важную',
31
- 'важны', 'важные', 'важный', 'важным', 'важных', 'вазах', 'вазы', 'вакса', 'вакханка', 'вал',
32
- 'валандался', 'валентина', 'валериановых', 'валерию', 'валетами', 'вали', 'валил', 'валился',
33
- 'валится', 'валов', 'вальдшнепа', 'вальс', 'вальса', 'вальсе', 'вальсишку', 'вальтера', 'валяется',
34
- 'валялась', 'валялись', 'валялось', 'валялся', 'валять', 'валяются', 'вам', 'вами', 'п', 'па', 'пава',
35
- 'павел', 'павильон', 'павильонам', 'павла', 'павлиний', 'павлиньи', 'павлиньим', 'павлович', 'павловна',
36
- 'павловне', 'павловной', 'павловну', 'павловны', 'павловцы', 'павлыч', 'павлыча', 'пагубная', 'падает',
37
- 'падай', 'падал', 'падала', 'падаль', 'падать', 'падаю', 'падают', 'падающего', 'падающие', 'падеж', 'падение',
38
- 'падением', 'падении', 'падений', 'падения', 'паденье', 'паденья', 'падет', 'падут', 'падучая', 'падчерицей',
39
- 'падчерицы', 'падшая', 'падшей', 'падшему', 'падший', 'падшим', 'падших', 'падшую', 'паек', 'пазухи', 'пазуху',
40
- 'пай', 'пакет', 'пакетом', 'пакеты', 'пакостей', 'пакостно', 'пал']
41
-
42
- const testResult = [
43
- 'в', 'вавиловк', 'вагнер', 'вагон', 'вагон', 'вагон', 'вагон', 'вагон', 'вагон', 'важн', 'важн', 'важн',
44
- 'важн', 'важнича', 'важн', 'важн', 'важн', 'важн', 'важн', 'важн', 'важност', 'важност', 'важност',
45
- 'важност', 'важн', 'важн', 'важн', 'важн', 'важн', 'важн', 'ваз', 'ваз', 'вакс', 'вакханк', 'вал',
46
- 'валанда', 'валентин', 'валерианов', 'валер', 'валет', 'вал', 'вал', 'вал', 'вал', 'вал', 'вальдшнеп',
47
- 'вальс', 'вальс', 'вальс', 'вальсишк', 'вальтер', 'валя', 'валя', 'валя', 'валя', 'валя', 'валя', 'валя',
48
- 'вам', 'вам', 'п', 'па', 'пав', 'павел', 'павильон', 'павильон', 'павл', 'павлин', 'павлин', 'павлин',
49
- 'павлович', 'павловн', 'павловн', 'павловн', 'павловн', 'павловн', 'павловц', 'павлыч', 'павлыч', 'пагубн',
50
- 'пада', 'пада', 'пада', 'пада', 'падал', 'пада', 'пада', 'пада', 'пада', 'пада', 'падеж', 'паден', 'паден',
51
- 'паден', 'паден', 'паден', 'паден', 'паден', 'падет', 'падут', 'падуч', 'падчериц', 'падчериц', 'падш', 'падш',
52
- 'падш', 'падш', 'падш', 'падш', 'падш', 'паек', 'пазух', 'пазух', 'па', 'пакет', 'пакет', 'пакет', 'пакост',
53
- 'пакостн', 'пал']
54
-
55
- describe('porter_stemmer', function () {
56
- it('should permof stem', function () {
57
- for (let i = 0; i < test.length; i++) {
58
- expect(stemmer.stem(test[i])).toBe(testResult[i])
59
- }
60
- })/*,
61
- it('should tokenize and stem attached', function() {
62
- stemmer.attach();
63
- expect('мама мыла раму'.tokenizeAndStem()).toEqual(['мам', 'мыл', 'рам']);
64
- expect('МАМА МЫЛА РАМУ'.tokenizeAndStem()).toEqual(['мам', 'мыл', 'рам']);
65
- });
66
- */
67
- })
@@ -1,202 +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 {
26
- PorterStemmer as stemmer,
27
- stopwords
28
- } from 'lib/natural'
29
-
30
- describe('porter_stemmer', function () {
31
- it('should categorizeGroups', function () {
32
- expect(stemmer.categorizeGroups('syllog')).toBe('CVCVC')
33
- expect(stemmer.categorizeGroups('gypsy')).toBe('CVCV')
34
- })
35
-
36
- it('should measure', function () {
37
- expect(stemmer.measure('syllog')).toBe(2)
38
- })
39
-
40
- it('should perform step 1a', function () {
41
- expect(stemmer.step1a('caresses')).toBe('caress')
42
- expect(stemmer.step1a('ponies')).toBe('poni')
43
- expect(stemmer.step1a('ties')).toBe('ti')
44
- expect(stemmer.step1a('caress')).toBe('caress')
45
- expect(stemmer.step1a('cats')).toBe('cat')
46
- })
47
-
48
- it('should perform step 1b', function () {
49
- expect(stemmer.step1b('feed')).toBe('feed')
50
- expect(stemmer.step1b('agreed')).toBe('agree')
51
- expect(stemmer.step1b('plastered')).toBe('plaster')
52
- expect(stemmer.step1b('bled')).toBe('bled')
53
- expect(stemmer.step1b('motoring')).toBe('motor')
54
- expect(stemmer.step1b('sing')).toBe('sing')
55
- })
56
-
57
- it('should perform step 1c', function () {
58
- expect(stemmer.step1c('happy')).toBe('happi')
59
- expect(stemmer.step1c('sky')).toBe('sky')
60
- })
61
-
62
- it('should perform step 2', function () {
63
- expect(stemmer.step2('relational')).toBe('relate')
64
- expect(stemmer.step2('conditional')).toBe('condition')
65
- expect(stemmer.step2('rational')).toBe('rational')
66
- expect(stemmer.step2('valenci')).toBe('valence')
67
- expect(stemmer.step2('hesitanci')).toBe('hesitance')
68
- expect(stemmer.step2('digitizer')).toBe('digitize')
69
- expect(stemmer.step2('conformabli')).toBe('conformable')
70
- expect(stemmer.step2('radicalli')).toBe('radical')
71
- expect(stemmer.step2('differentli')).toBe('different')
72
- expect(stemmer.step2('vileli')).toBe('vile')
73
- expect(stemmer.step2('analogousli')).toBe('analogous')
74
- expect(stemmer.step2('vietnamization')).toBe('vietnamize')
75
- expect(stemmer.step2('predication')).toBe('predicate')
76
- expect(stemmer.step2('operator')).toBe('operate')
77
- expect(stemmer.step2('feudalism')).toBe('feudal')
78
- expect(stemmer.step2('decisiveness')).toBe('decisive')
79
- expect(stemmer.step2('hopefulness')).toBe('hopeful')
80
- expect(stemmer.step2('callousness')).toBe('callous')
81
- expect(stemmer.step2('formaliti')).toBe('formal')
82
- expect(stemmer.step2('sensitiviti')).toBe('sensitive')
83
- expect(stemmer.step2('sensibiliti')).toBe('sensible')
84
- })
85
-
86
- it('should perform step 3', function () {
87
- expect(stemmer.step3('triplicate')).toBe('triplic')
88
- expect(stemmer.step3('formative')).toBe('form')
89
- expect(stemmer.step3('formalize')).toBe('formal')
90
- expect(stemmer.step3('electriciti')).toBe('electric')
91
- expect(stemmer.step3('electrical')).toBe('electric')
92
- expect(stemmer.step3('hopeful')).toBe('hope')
93
- expect(stemmer.step3('goodness')).toBe('good')
94
- })
95
-
96
- it('should perform step 4', function () {
97
- expect(stemmer.step4('revival')).toBe('reviv')
98
- expect(stemmer.step4('allowance')).toBe('allow')
99
- expect(stemmer.step4('inference')).toBe('infer')
100
- expect(stemmer.step4('airliner')).toBe('airlin')
101
- expect(stemmer.step4('gyroscopic')).toBe('gyroscop')
102
- expect(stemmer.step4('adjustable')).toBe('adjust')
103
- expect(stemmer.step4('defensible')).toBe('defens')
104
- expect(stemmer.step4('irritant')).toBe('irrit')
105
- expect(stemmer.step4('replacement')).toBe('replac')
106
- expect(stemmer.step4('adjustment')).toBe('adjust')
107
- expect(stemmer.step4('dependent')).toBe('depend')
108
- expect(stemmer.step4('adoption')).toBe('adopt')
109
- expect(stemmer.step4('homologou')).toBe('homolog')
110
- expect(stemmer.step4('communism')).toBe('commun')
111
- expect(stemmer.step4('activate')).toBe('activ')
112
- expect(stemmer.step4('angulariti')).toBe('angular')
113
- expect(stemmer.step4('homologous')).toBe('homolog')
114
- expect(stemmer.step4('effective')).toBe('effect')
115
- expect(stemmer.step4('bowdlerize')).toBe('bowdler')
116
- })
117
-
118
- it('should perform step 5a', function () {
119
- expect(stemmer.step5a('probate')).toBe('probat')
120
- expect(stemmer.step5a('rate')).toBe('rate')
121
- expect(stemmer.step5a('cease')).toBe('ceas')
122
- })
123
-
124
- it('should perform step5b', function () {
125
- expect(stemmer.step5b('controll')).toBe('control')
126
- expect(stemmer.step5b('roll')).toBe('roll')
127
- })
128
-
129
- it('should perform complete stemming', function () {
130
- expect(stemmer.stem('scoring')).toBe('score')
131
- expect(stemmer.stem('scored')).toBe('score')
132
- expect(stemmer.stem('scores')).toBe('score')
133
- expect(stemmer.stem('score')).toBe('score')
134
- expect(stemmer.stem('SCORING')).toBe('score')
135
- expect(stemmer.stem('SCORED')).toBe('score')
136
- expect(stemmer.stem('SCORES')).toBe('score')
137
- expect(stemmer.stem('SCORE')).toBe('score')
138
- expect(stemmer.stem('nationals')).toBe('nation')
139
- expect(stemmer.stem('doing')).toBe('do')
140
- })
141
-
142
- it('should perform stem animated to anim', function () {
143
- expect(stemmer.stem('animated')).toBe('anim')
144
- })
145
-
146
- it('issue 176 - attemptReplace ed|ing', function () {
147
- expect(stemmer.stem('aedile')).toBe('aedil')
148
- expect(stemmer.stem('adoptedly')).toBe('adoptedli')
149
- })
150
-
151
- it('issue 176 - minimum length for final e', function () {
152
- expect(stemmer.stem('ace')).toBe('ac')
153
- })
154
-
155
- it('issue 176 - minimum length for final s', function () {
156
- expect(stemmer.stem('yes')).toBe('ye')
157
- })
158
-
159
- it('issue 176 - s/tion measure', function () {
160
- expect(stemmer.stem('invasion')).toBe('invas')
161
- })
162
-
163
- it('issue 176 - vehement - step 4', function () {
164
- expect(stemmer.stem('vehement')).toBe('vehement')
165
- expect(stemmer.stem('syllogism')).toBe('syllog')
166
- expect(stemmer.stem('gypsy')).toBe('gypsi')
167
- })
168
-
169
- it('issue 176 step 2', function () {
170
- expect(stemmer.stem('terribly')).toBe('terribl')
171
- expect(stemmer.stem('apology')).toBe('apolog')
172
- })
173
-
174
- it('issue 176 - step 5a', function () {
175
- expect(stemmer.stem('type')).toBe('type')
176
- })
177
-
178
- it('issue 176 - corruptiblity', function () {
179
- expect(stemmer.stem('corruptibility')).toBe('corrupt')
180
- })
181
-
182
- /*
183
- it('should tokenize and stem attached', function() {
184
- stemmer.attach();
185
- expect('scoring stinks'.tokenizeAndStem()).toEqual(['score', 'stink']);
186
- expect('SCORING STINKS'.tokenizeAndStem()).toEqual(['score', 'stink']);
187
- });
188
- */
189
-
190
- it('should tokenize and stem ignoring stopwords', function () {
191
- expect(stemmer.tokenizeAndStem('My dog is very fun TO play with And another thing, he is A poodle.')).toEqual(['dog', 'fun', 'plai', 'thing', 'poodl'])
192
- })
193
-
194
- it('should tokenize and stem ignoring all capital stopwords', function () {
195
- const allCapitalStopwords: string = stopwords.join(' ').toUpperCase()
196
- expect(stemmer.tokenizeAndStem(allCapitalStopwords)).toEqual([])
197
- })
198
-
199
- it('should tokenize and stem including stopwords', function () {
200
- expect(stemmer.tokenizeAndStem('My dog is very fun TO play with And another thing, he is A poodle.', true)).toEqual(['my', 'dog', 'is', 'veri', 'fun', 'to', 'plai', 'with', 'and', 'anoth', 'thing', 'he', 'is', 'a', 'poodl'])
201
- })
202
- })
@@ -1,41 +0,0 @@
1
- /*
2
- Copyright (c) 2017, Dogan Yazar
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 { PorterStemmerSv as stemmer } from 'lib/natural'
26
- import { words, stemmedWords } from '../spec/test_data/sv_stemmer_sample.js'
27
-
28
- describe('porter_stemmer_sv', function () {
29
- it('Stem whole sample data', function () {
30
- const res = words.map(w => stemmer.stem(w))
31
- expect(res).toEqual(stemmedWords)
32
- })
33
-
34
- /*
35
- it('should tokenize and stem attached', function() {
36
- stemmer.attach();
37
- expect('björks jaktbössa'.tokenizeAndStem()).toEqual(['björk', 'jaktböss'])
38
- expect('bJöRks JaKtböSsa'.tokenizeAndStem()).toEqual(['björk', 'jaktböss'])
39
- })
40
- */
41
- })