natural 0.2.1 → 0.4.0

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 (106) hide show
  1. package/.npmignore +4 -11
  2. package/README.md +156 -41
  3. package/bayes_classifier.json +1 -0
  4. package/lib/natural/brill_pos_tagger/data/Dutch/README.txt +2 -0
  5. package/lib/natural/brill_pos_tagger/data/Dutch/brill_CONTEXTRULES.jg +285 -0
  6. package/lib/natural/brill_pos_tagger/data/Dutch/brill_LEXICON.jg +11699 -0
  7. package/lib/natural/brill_pos_tagger/data/English/README.txt +8 -0
  8. package/lib/natural/brill_pos_tagger/data/English/lexicon_from_posjs.json +297827 -0
  9. package/lib/natural/brill_pos_tagger/data/English/tr_from_brill_paper.txt +10 -0
  10. package/lib/natural/brill_pos_tagger/data/English/tr_from_posjs.txt +18 -0
  11. package/lib/natural/brill_pos_tagger/lib/Brill_POS_Tagger.js +136 -0
  12. package/lib/natural/brill_pos_tagger/lib/Predicate.js +410 -0
  13. package/lib/natural/brill_pos_tagger/lib/TF_Parser.js +717 -0
  14. package/lib/natural/brill_pos_tagger/lib/TF_Parser.pegjs +55 -0
  15. package/lib/natural/brill_pos_tagger/lib/TransformationRule.js +49 -0
  16. package/lib/natural/classifiers/bayes_classifier.js +6 -5
  17. package/lib/natural/classifiers/classifier.js +3 -2
  18. package/lib/natural/classifiers/logistic_regression_classifier.js +9 -5
  19. package/lib/natural/distance/dice_coefficient.js +22 -12
  20. package/lib/natural/index.js +6 -0
  21. package/lib/natural/ngrams/ngrams.js +4 -0
  22. package/lib/natural/stemmers/stemmer.js +31 -6
  23. package/lib/natural/tokenizers/regexp_tokenizer.js +3 -3
  24. package/{examples/inflection/noun.js → lib/natural/tokenizers/sentence_tokenizer.js} +14 -10
  25. package/lib/natural/tokenizers/tokenizer_case.js +58 -0
  26. package/lib/natural/util/bag.js +1 -0
  27. package/lib/natural/wordnet/wordnet.js +2 -2
  28. package/lib/natural/wordnet/wordnet_file.js +1 -1
  29. package/lr_classifier.json +1 -0
  30. package/package.json +6 -3
  31. package/package.json~ +66 -0
  32. package/benchmarks/index.js +0 -32
  33. package/benchmarks/metaphone.js +0 -27
  34. package/benchmarks/soundex.js +0 -27
  35. package/examples/classification/basic.js +0 -35
  36. package/examples/classification/recall.js +0 -28
  37. package/examples/classification/store.js +0 -37
  38. package/examples/inflection/count.js +0 -35
  39. package/examples/inflection/noun_attach.js +0 -33
  40. package/examples/phonetics/compare.js +0 -39
  41. package/examples/phonetics/sounds_like.js +0 -40
  42. package/examples/phonetics/tokenize_and_phoneticize.js +0 -54
  43. package/examples/stemming/stem_corpus.js +0 -29
  44. package/examples/stemming/stem_word.js +0 -26
  45. package/examples/tfidf/array_example.js +0 -34
  46. package/examples/tfidf/multiple_terms.js +0 -33
  47. package/examples/tfidf/tfidf_example.js +0 -44
  48. package/io_spec/test_data/tfidf/one +0 -1
  49. package/io_spec/test_data/tfidf/two +0 -1
  50. package/io_spec/tfidf_spec.js +0 -50
  51. package/io_spec/wordnet_spec.js +0 -81
  52. package/spec/aggressive_tokenizer_es_spec.js +0 -36
  53. package/spec/aggressive_tokenizer_fr_spec.js +0 -101
  54. package/spec/aggressive_tokenizer_nl_spec.js +0 -36
  55. package/spec/aggressive_tokenizer_pt_spec.js +0 -56
  56. package/spec/aggressive_tokenizer_spec.js +0 -56
  57. package/spec/bayes_classifier_spec.js +0 -173
  58. package/spec/classifier_spec.js +0 -175
  59. package/spec/count_inflector_fr_spec.js +0 -44
  60. package/spec/count_inflector_spec.js +0 -73
  61. package/spec/dice_coefficient_spec.js +0 -26
  62. package/spec/double_metaphone_spec.js +0 -752
  63. package/spec/jaro-winkler_spec.js +0 -53
  64. package/spec/lancaster_stemmer_spec.js +0 -73
  65. package/spec/levenshtein_spec.js +0 -66
  66. package/spec/logistic_regression_classifier_spec.js +0 -122
  67. package/spec/longest_path_tree_spec.js +0 -102
  68. package/spec/metaphone_spec.js +0 -252
  69. package/spec/ngram_spec.js +0 -130
  70. package/spec/ngram_zh_spec.js +0 -122
  71. package/spec/normalizer_ja_spec.js +0 -160
  72. package/spec/normalizer_no_spec.js +0 -111
  73. package/spec/normalizer_spec.js +0 -140
  74. package/spec/noun_inflector_fr_spec.js +0 -476
  75. package/spec/noun_inflector_ja_spec.js +0 -112
  76. package/spec/noun_inflector_spec.js +0 -270
  77. package/spec/porter_stemmer_fr_spec.js +0 -101
  78. package/spec/porter_stemmer_it_spec.js +0 -44
  79. package/spec/porter_stemmer_no_spec.js +0 -143
  80. package/spec/porter_stemmer_pt_spec.js +0 -50
  81. package/spec/porter_stemmer_ru_spec.js +0 -63
  82. package/spec/porter_stemmer_spec.js +0 -182
  83. package/spec/present_verb_inflector_spec.js +0 -128
  84. package/spec/remove_diacritics_spec.js +0 -31
  85. package/spec/sentence_analyzer_spec.js +0 -277
  86. package/spec/shortest_path_tree_spec.js +0 -132
  87. package/spec/soundex_spec.js +0 -158
  88. package/spec/spellcheck_spec.js +0 -92
  89. package/spec/stemmer_ja_spec.js +0 -66
  90. package/spec/stemmer_token_spec.js +0 -161
  91. package/spec/test_data/snowball_fr.txt +0 -20402
  92. package/spec/test_data/snowball_it.txt +0 -35482
  93. package/spec/test_data/snowball_no.txt +0 -20628
  94. package/spec/test_data/snowball_pt.txt +0 -32016
  95. package/spec/test_data/tfdif_testcorpus.txt +0 -7
  96. package/spec/test_data/tfidf_document1.txt +0 -1
  97. package/spec/test_data/tfidf_document2.txt +0 -1
  98. package/spec/test_data/tfidf_document3.txt +0 -1
  99. package/spec/test_data/tfidf_document4.txt +0 -1
  100. package/spec/test_data/tfidf_teststopwords.txt +0 -1
  101. package/spec/test_data/wordnet_mini.sql +0 -95
  102. package/spec/tfidf_spec.js +0 -323
  103. package/spec/tokenizer_ja_spec.js +0 -58
  104. package/spec/transliterator_ja_spec.js +0 -103
  105. package/spec/treebank_word_tokenizer_spec.js +0 -36
  106. package/spec/trie_spec.js +0 -206
@@ -1,50 +0,0 @@
1
- /*
2
- Copyright (c) 2014, Luís Rodrigues
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
- var PorterStemmer = require('../lib/natural/stemmers/porter_stemmer_pt'),
24
- fs = require('fs');
25
-
26
- describe('porter_stemmer_pt', function() {
27
-
28
- it('should perform stemming on a lot of words', function() {
29
- var errors = [];
30
-
31
- fs.readFileSync('spec/test_data/snowball_pt.txt').toString().split('\n').forEach(function(line) {
32
- if (line) {
33
- var fields = line.replace(/\s+/g, ' ').split(' '),
34
- stemmed = PorterStemmer.stem(fields[0]);
35
-
36
- if (stemmed !== fields[1]) {
37
- console.log('Error:', fields[0], 'Expected:', fields[1], 'Got:', stemmed);
38
- errors.push({
39
- word: fields[0],
40
- expected: fields[1],
41
- actual: stemmed
42
- });
43
- }
44
- }
45
- });
46
-
47
- expect(errors.length).toBe(0);
48
- });
49
-
50
- });
@@ -1,63 +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
- var stemmer = require('../lib/natural/stemmers/porter_stemmer_ru');
23
-
24
- var test = [
25
- 'в', 'вавиловка', 'вагнера', 'вагон', 'вагона', 'вагоне', 'вагонов', 'вагоном', 'вагоны',
26
- 'важная', 'важнее', 'важнейшие', 'важнейшими', 'важничал', 'важно', 'важного', 'важное',
27
- 'важной', 'важном', 'важному', 'важности', 'важностию', 'важность', 'важностью', 'важную',
28
- 'важны', 'важные', 'важный', 'важным', 'важных', 'вазах', 'вазы', 'вакса', 'вакханка', 'вал',
29
- 'валандался', 'валентина', 'валериановых', 'валерию', 'валетами', 'вали', 'валил', 'валился',
30
- 'валится', 'валов', 'вальдшнепа', 'вальс', 'вальса', 'вальсе', 'вальсишку', 'вальтера', 'валяется',
31
- 'валялась', 'валялись', 'валялось', 'валялся', 'валять', 'валяются', 'вам', 'вами', 'п', 'па', 'пава',
32
- 'павел', 'павильон', 'павильонам', 'павла', 'павлиний', 'павлиньи', 'павлиньим', 'павлович', 'павловна',
33
- 'павловне', 'павловной', 'павловну', 'павловны', 'павловцы', 'павлыч', 'павлыча', 'пагубная', 'падает',
34
- 'падай', 'падал', 'падала', 'падаль', 'падать', 'падаю', 'падают', 'падающего', 'падающие', 'падеж', 'падение',
35
- 'падением', 'падении', 'падений', 'падения', 'паденье', 'паденья', 'падет', 'падут', 'падучая', 'падчерицей',
36
- 'падчерицы', 'падшая', 'падшей', 'падшему', 'падший', 'падшим', 'падших', 'падшую', 'паек', 'пазухи', 'пазуху',
37
- 'пай', 'пакет', 'пакетом', 'пакеты', 'пакостей', 'пакостно', 'пал'];
38
-
39
- var testResult = [
40
- 'в', 'вавиловк', 'вагнер', 'вагон', 'вагон', 'вагон', 'вагон', 'вагон', 'вагон', 'важн', 'важн', 'важн',
41
- 'важн', 'важнича', 'важн', 'важн', 'важн', 'важн', 'важн', 'важн', 'важност', 'важност', 'важност',
42
- 'важност', 'важн', 'важн', 'важн', 'важн', 'важн', 'важн', 'ваз', 'ваз', 'вакс', 'вакханк', 'вал',
43
- 'валанда', 'валентин', 'валерианов', 'валер', 'валет', 'вал', 'вал', 'вал', 'вал', 'вал', 'вальдшнеп',
44
- 'вальс', 'вальс', 'вальс', 'вальсишк', 'вальтер', 'валя', 'валя', 'валя', 'валя', 'валя', 'валя', 'валя',
45
- 'вам', 'вам', 'п', 'па', 'пав', 'павел', 'павильон', 'павильон', 'павл', 'павлин', 'павлин', 'павлин',
46
- 'павлович', 'павловн', 'павловн', 'павловн', 'павловн', 'павловн', 'павловц', 'павлыч', 'павлыч', 'пагубн',
47
- 'пада', 'пада', 'пада', 'пада', 'падал', 'пада', 'пада', 'пада', 'пада', 'пада', 'падеж', 'паден', 'паден',
48
- 'паден', 'паден', 'паден', 'паден', 'паден', 'падет', 'падут', 'падуч', 'падчериц', 'падчериц', 'падш', 'падш',
49
- 'падш', 'падш', 'падш', 'падш', 'падш', 'паек', 'пазух', 'пазух', 'па', 'пакет', 'пакет', 'пакет', 'пакост',
50
- 'пакостн', 'пал'];
51
-
52
- describe('porter_stemmer', function() {
53
- it('should permof stem', function() {
54
- for (var i = 0; i < test.length; i++) {
55
- expect(stemmer.stem(test[i])).toBe(testResult[i]);
56
- }
57
- }),
58
- it('should tokenize and stem attached', function() {
59
- stemmer.attach();
60
- expect('мама мыла раму'.tokenizeAndStem()).toEqual(['мам', 'мыл', 'рам']);
61
- expect('МАМА МЫЛА РАМУ'.tokenizeAndStem()).toEqual(['мам', 'мыл', 'рам']);
62
- });
63
- });
@@ -1,182 +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
- var stemmer = require('../lib/natural/stemmers/porter_stemmer');
24
-
25
- describe('porter_stemmer', function() {
26
- it('should categorizeGroups', function() {
27
- expect(stemmer.categorizeGroups('syllog')).toBe('CVCVC');
28
- expect(stemmer.categorizeGroups('gypsy')).toBe('CVCV');
29
- });
30
-
31
- it('should measure', function() {
32
- expect(stemmer.measure('syllog')).toBe(2);
33
- });
34
-
35
- it('should perform step 1a', function() {
36
- expect(stemmer.step1a('caresses')).toBe('caress');
37
- expect(stemmer.step1a('ponies')).toBe('poni');
38
- expect(stemmer.step1a('ties')).toBe('ti');
39
- expect(stemmer.step1a('caress')).toBe('caress');
40
- expect(stemmer.step1a('cats')).toBe('cat');
41
- });
42
-
43
- it('should perform step 1b', function() {
44
- expect(stemmer.step1b('feed')).toBe('feed');
45
- expect(stemmer.step1b('agreed')).toBe('agree');
46
- expect(stemmer.step1b('plastered')).toBe('plaster');
47
- expect(stemmer.step1b('bled')).toBe('bled');
48
- expect(stemmer.step1b('motoring')).toBe('motor');
49
- expect(stemmer.step1b('sing')).toBe('sing');
50
- });
51
-
52
- it('should perform step 1c', function() {
53
- expect(stemmer.step1c('happy')).toBe('happi');
54
- expect(stemmer.step1c('sky')).toBe('sky');
55
- });
56
-
57
- it('should perform step 2', function() {
58
- expect(stemmer.step2('relational')).toBe('relate');
59
- expect(stemmer.step2('conditional')).toBe('condition');
60
- expect(stemmer.step2('rational')).toBe('rational');
61
- expect(stemmer.step2('valenci')).toBe('valence');
62
- expect(stemmer.step2('hesitanci')).toBe('hesitance');
63
- expect(stemmer.step2('digitizer')).toBe('digitize');
64
- expect(stemmer.step2('conformabli')).toBe('conformable');
65
- expect(stemmer.step2('radicalli')).toBe('radical');
66
- expect(stemmer.step2('differentli')).toBe('different');
67
- expect(stemmer.step2('vileli')).toBe('vile');
68
- expect(stemmer.step2('analogousli')).toBe('analogous');
69
- expect(stemmer.step2('vietnamization')).toBe('vietnamize');
70
- expect(stemmer.step2('predication')).toBe('predicate');
71
- expect(stemmer.step2('operator')).toBe('operate');
72
- expect(stemmer.step2('feudalism')).toBe('feudal');
73
- expect(stemmer.step2('decisiveness')).toBe('decisive');
74
- expect(stemmer.step2('hopefulness')).toBe('hopeful');
75
- expect(stemmer.step2('callousness')).toBe('callous');
76
- expect(stemmer.step2('formaliti')).toBe('formal');
77
- expect(stemmer.step2('sensitiviti')).toBe('sensitive');
78
- expect(stemmer.step2('sensibiliti')).toBe('sensible');
79
- });
80
-
81
- it('should perform step 3', function() {
82
- expect(stemmer.step3('triplicate')).toBe('triplic');
83
- expect(stemmer.step3('formative')).toBe('form');
84
- expect(stemmer.step3('formalize')).toBe('formal');
85
- expect(stemmer.step3('electriciti')).toBe('electric');
86
- expect(stemmer.step3('electrical')).toBe('electric');
87
- expect(stemmer.step3('hopeful')).toBe('hope');
88
- expect(stemmer.step3('goodness')).toBe('good');
89
- });
90
-
91
- it('should perform step 4', function() {
92
- expect(stemmer.step4('revival')).toBe('reviv');
93
- expect(stemmer.step4('allowance')).toBe('allow');
94
- expect(stemmer.step4('inference')).toBe('infer');
95
- expect(stemmer.step4('airliner')).toBe('airlin');
96
- expect(stemmer.step4('gyroscopic')).toBe('gyroscop');
97
- expect(stemmer.step4('adjustable')).toBe('adjust');
98
- expect(stemmer.step4('defensible')).toBe('defens');
99
- expect(stemmer.step4('irritant')).toBe('irrit');
100
- expect(stemmer.step4('replacement')).toBe('replac');
101
- expect(stemmer.step4('adjustment')).toBe('adjust');
102
- expect(stemmer.step4('dependent')).toBe('depend');
103
- expect(stemmer.step4('adoption')).toBe('adopt');
104
- expect(stemmer.step4('homologou')).toBe('homolog');
105
- expect(stemmer.step4('communism')).toBe('commun');
106
- expect(stemmer.step4('activate')).toBe('activ');
107
- expect(stemmer.step4('angulariti')).toBe('angular');
108
- expect(stemmer.step4('homologous')).toBe('homolog');
109
- expect(stemmer.step4('effective')).toBe('effect');
110
- expect(stemmer.step4('bowdlerize')).toBe('bowdler');
111
- });
112
-
113
- it('should perform step 5a', function() {
114
- expect(stemmer.step5a('probate')).toBe('probat');
115
- expect(stemmer.step5a('rate')).toBe('rate');
116
- expect(stemmer.step5a('cease')).toBe('ceas');
117
- });
118
-
119
- it('should perform step5b', function() {
120
- expect(stemmer.step5b('controll')).toBe('control');
121
- expect(stemmer.step5b('roll')).toBe('roll');
122
- });
123
-
124
- it('should perform complete stemming', function() {
125
- expect(stemmer.stem('scoring')).toBe('score');
126
- expect(stemmer.stem('scored')).toBe('score');
127
- expect(stemmer.stem('scores')).toBe('score');
128
- expect(stemmer.stem('score')).toBe('score');
129
- expect(stemmer.stem('SCORING')).toBe('score');
130
- expect(stemmer.stem('SCORED')).toBe('score');
131
- expect(stemmer.stem('SCORES')).toBe('score');
132
- expect(stemmer.stem('SCORE')).toBe('score');
133
- expect(stemmer.stem('nationals')).toBe('nation');
134
- expect(stemmer.stem('doing')).toBe('do');
135
- });
136
-
137
- it('should perform stem animated to anim', function() {
138
- expect(stemmer.stem('animated')).toBe('anim');
139
- });
140
-
141
- it('issue 176 - attemptReplace ed|ing', function() {
142
- expect(stemmer.stem('aedile')).toBe('aedil');
143
- expect(stemmer.stem('adoptedly')).toBe('adoptedli');
144
- });
145
-
146
- it('issue 176 - minimum length for final e', function() {
147
- expect(stemmer.stem('ace')).toBe('ac');
148
- });
149
-
150
- it('issue 176 - minimum length for final s', function() {
151
- expect(stemmer.stem('yes')).toBe('ye');
152
- });
153
-
154
- it('issue 176 - s/tion measure', function() {
155
- expect(stemmer.stem('invasion')).toBe('invas');
156
- });
157
-
158
- it('issue 176 - vehement - step 4', function() {
159
- expect(stemmer.stem('vehement')).toBe('vehement');
160
- expect(stemmer.stem('syllogism')).toBe('syllog');
161
- expect(stemmer.stem('gypsy')).toBe('gypsi');
162
- });
163
-
164
- it('issue 176 step 2', function() {
165
- expect(stemmer.stem('terribly')).toBe('terribl');
166
- expect(stemmer.stem('apology')).toBe('apolog');
167
- });
168
-
169
- it('issue 176 - step 5a', function() {
170
- expect(stemmer.stem('type')).toBe('type');
171
- });
172
-
173
- it('issue 176 - corruptiblity', function() {
174
- expect(stemmer.stem('corruptibility')).toBe('corrupt');
175
- });
176
-
177
- it('should tokenize and stem attached', function() {
178
- stemmer.attach();
179
- expect('scoring stinks'.tokenizeAndStem()).toEqual(['score', 'stink']);
180
- expect('SCORING STINKS'.tokenizeAndStem()).toEqual(['score', 'stink']);
181
- });
182
- });
@@ -1,128 +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
- var VerbInflector = require('../lib/natural/inflectors/present_verb_inflector'),
24
- inflector = new VerbInflector ();
25
-
26
- describe('present verb inflector', function() {
27
- describe('singularization', function() {
28
- it('should singularize regular ES forms', function() {
29
- expect(inflector.singularize('catch')).toBe('catches');
30
- expect(inflector.singularize('do')).toBe('does');
31
- expect(inflector.singularize('go')).toBe('goes');
32
- });
33
-
34
- it('should handle [CS]HES forms', function () {
35
- expect(inflector.singularize('cash')).toBe('cashes');
36
- expect(inflector.singularize('ach')).toBe('aches');
37
- });
38
-
39
- it('should ignore XES forms', function() {
40
- expect(inflector.singularize('annex')).toBe('annexes');
41
- });
42
-
43
- it('should handle SSES forms', function() {
44
- expect(inflector.singularize('access')).toBe('accesses');
45
- });
46
-
47
- it('should ignore ZZES forms', function() {
48
- expect(inflector.singularize('buzz')).toBe('buzzes');
49
- });
50
-
51
- it('should singularize regular S forms', function() {
52
- expect(inflector.singularize('claim')).toBe('claims');
53
- expect(inflector.singularize('drink')).toBe('drinks');
54
- expect(inflector.singularize('become')).toBe('becomes');
55
- });
56
-
57
- it('should singularize irregular forms', function() {
58
- expect(inflector.singularize('are')).toBe('is');
59
- expect(inflector.singularize('were')).toBe('was');
60
- expect(inflector.singularize('have')).toBe('has');
61
- });
62
-
63
- it('should singularize ies forms', function() {
64
- expect(inflector.singularize('fly')).toBe('flies');
65
- expect(inflector.singularize('try')).toBe('tries');
66
- });
67
-
68
- it('should handle ambiguous forms', function() {
69
- expect(inflector.singularize('will')).toBe('will');
70
- });
71
- });
72
-
73
- describe('pluralization', function() {
74
- it('should pluralize regular ES forms', function() {
75
- expect(inflector.pluralize('catches')).toBe('catch');
76
- expect(inflector.pluralize('does')).toBe('do');
77
- expect(inflector.pluralize('goes')).toBe('go');
78
- });
79
-
80
- it('should handle [CS]HES forms', function () {
81
- expect(inflector.pluralize('cashes')).toBe('cash');
82
- expect(inflector.pluralize('aches')).toBe('ach');
83
- });
84
-
85
- it('should handle XES forms', function() {
86
- expect(inflector.pluralize('annexes')).toBe('annex');
87
- });
88
-
89
- it('should handle SSES forms', function() {
90
- expect(inflector.pluralize('accesses')).toBe('access');
91
- });
92
-
93
- it('should handle ZZES forms', function() {
94
- expect(inflector.pluralize('buzzes')).toBe('buzz');
95
- });
96
-
97
- it('should pluralize regular S forms that done drop e', function() {
98
- expect(inflector.pluralize('becomes')).toBe('become');
99
- });
100
-
101
- it('should pluralize regular S forms', function() {
102
- expect(inflector.pluralize('drinks')).toBe('drink');
103
- expect(inflector.pluralize('claims')).toBe('claim');
104
- });
105
-
106
- it('should pluralize irregular forms', function() {
107
- expect(inflector.pluralize('was')).toBe('were');
108
- expect(inflector.pluralize('is')).toBe('are');
109
- expect(inflector.pluralize('am')).toBe('are');
110
- expect(inflector.pluralize('has')).toBe('have');
111
- });
112
-
113
- it('should pluralize ies forms', function() {
114
- expect(inflector.pluralize('flies')).toBe('fly');
115
- expect(inflector.pluralize('tries')).toBe('try');
116
- });
117
-
118
- it('should handle ambiguous forms', function() {
119
- expect(inflector.pluralize('will')).toBe('will');
120
- });
121
- });
122
-
123
- describe('should pluralize and singularize string from patch', function() {
124
- inflector.attach();
125
- expect('becomes'.pluralizePresentVerb()).toBe('become');
126
- expect('become'.singularizePresentVerb()).toBe('becomes');
127
- });
128
- });
@@ -1,31 +0,0 @@
1
- /*
2
- Copyright (c) 2013, Ken Koch
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
- var removeDiacritics = require("../lib/natural/normalizers/remove_diacritics.js");
24
-
25
- describe('remove_diacritics', function() {
26
-
27
- it('should correctly remove diacritics', function () {
28
- var original_phrase = 'piñon ça va über résumé';
29
- expect(removeDiacritics(original_phrase)).toEqual('pinon ca va uber resume');
30
- });
31
- });