natural 7.0.2 → 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.
Files changed (72) hide show
  1. package/.github/workflows/npm-publish.yml +2 -0
  2. package/.nycrc +9 -0
  3. package/lib/natural/analyzers/sentence_analyzer.js +115 -113
  4. package/lib/natural/spellcheck/spellcheck.js +63 -61
  5. package/lib/natural/util/bag.js +27 -25
  6. package/package.json +3 -4
  7. package/tsconfig.json +1 -1
  8. package/ts_spec/MaxEntClassifier_spec.ts +0 -130
  9. package/ts_spec/SentimentAnalyzer_spec.ts +0 -232
  10. package/ts_spec/WordPunctTokenizer_spec.ts +0 -57
  11. package/ts_spec/aggressive_tokenizer_de_spec.ts +0 -36
  12. package/ts_spec/aggressive_tokenizer_es_spec.ts +0 -39
  13. package/ts_spec/aggressive_tokenizer_fr_spec.ts +0 -111
  14. package/ts_spec/aggressive_tokenizer_hi_spec.ts +0 -70
  15. package/ts_spec/aggressive_tokenizer_nl_spec.ts +0 -39
  16. package/ts_spec/aggressive_tokenizer_pt_spec.ts +0 -48
  17. package/ts_spec/aggressive_tokenizer_spec.ts +0 -57
  18. package/ts_spec/aggressive_tokenizer_sv_spec.ts +0 -52
  19. package/ts_spec/aggressive_tokenizer_vi_spec.ts +0 -48
  20. package/ts_spec/bayes_classifier_spec.ts +0 -165
  21. package/ts_spec/brill_pos_tagger_spec.ts +0 -79
  22. package/ts_spec/brill_pos_trainer_spec.ts +0 -107
  23. package/ts_spec/carry_stemmer_fr_spec.ts +0 -97
  24. package/ts_spec/classifier_spec.ts +0 -104
  25. package/ts_spec/count_inflector_fr_spec.ts +0 -47
  26. package/ts_spec/count_inflector_spec.ts +0 -76
  27. package/ts_spec/damerau_levenshtein_spec.ts +0 -53
  28. package/ts_spec/dice_coefficient_spec.ts +0 -37
  29. package/ts_spec/double_metaphone_spec.ts +0 -739
  30. package/ts_spec/hamming_distance_spec.ts +0 -66
  31. package/ts_spec/jaro-winkler_spec.ts +0 -79
  32. package/ts_spec/lancaster_stemmer_spec.ts +0 -63
  33. package/ts_spec/levenshtein_spec.ts +0 -107
  34. package/ts_spec/logistic_regression_classifier_spec.ts +0 -93
  35. package/ts_spec/longest_path_tree_spec.ts +0 -111
  36. package/ts_spec/metaphone_spec.ts +0 -258
  37. package/ts_spec/ngram_spec.ts +0 -145
  38. package/ts_spec/ngram_zh_spec.ts +0 -124
  39. package/ts_spec/normalizer_ja_spec.ts +0 -165
  40. package/ts_spec/normalizer_no_spec.ts +0 -112
  41. package/ts_spec/normalizer_spec.ts +0 -141
  42. package/ts_spec/noun_inflector_fr_spec.ts +0 -472
  43. package/ts_spec/noun_inflector_ja_spec.ts +0 -116
  44. package/ts_spec/noun_inflector_spec.ts +0 -369
  45. package/ts_spec/orthography_tokenizer_spec.ts +0 -47
  46. package/ts_spec/porter_stemmer_de_spec.ts +0 -53
  47. package/ts_spec/porter_stemmer_es_spec.ts +0 -63
  48. package/ts_spec/porter_stemmer_fr_spec.ts +0 -103
  49. package/ts_spec/porter_stemmer_it_spec.ts +0 -56
  50. package/ts_spec/porter_stemmer_nl_spec.ts +0 -73
  51. package/ts_spec/porter_stemmer_no_spec.ts +0 -148
  52. package/ts_spec/porter_stemmer_pt_spec.ts +0 -50
  53. package/ts_spec/porter_stemmer_ru_spec.ts +0 -67
  54. package/ts_spec/porter_stemmer_spec.ts +0 -202
  55. package/ts_spec/porter_stemmer_sv_spec.ts +0 -41
  56. package/ts_spec/present_verb_inflector_spec.ts +0 -127
  57. package/ts_spec/remove_diacritics_spec.ts +0 -30
  58. package/ts_spec/sentence_analyzer_spec.ts +0 -293
  59. package/ts_spec/sentence_tokenizer_parser_spec.ts +0 -200
  60. package/ts_spec/sentence_tokenizer_spec.ts +0 -189
  61. package/ts_spec/shortest_path_tree_spec.ts +0 -141
  62. package/ts_spec/soundex_spec.ts +0 -162
  63. package/ts_spec/spellcheck_spec.ts +0 -112
  64. package/ts_spec/stemmer_id_spec.ts +0 -374
  65. package/ts_spec/stemmer_ja_spec.ts +0 -69
  66. package/ts_spec/stemmer_token_spec.ts +0 -163
  67. package/ts_spec/tfidf_spec.ts +0 -275
  68. package/ts_spec/tokenizer_case_spec.ts +0 -242
  69. package/ts_spec/tokenizer_ja_spec.ts +0 -63
  70. package/ts_spec/transliterator_ja_spec.ts +0 -105
  71. package/ts_spec/treebank_word_tokenizer_spec.ts +0 -38
  72. package/ts_spec/trie_spec.ts +0 -197
@@ -1,472 +0,0 @@
1
- /*
2
- Copyright (c) 2012, Guillaume Marty
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 { NounInflectorFr } from 'lib/natural'
26
- const inflector = new NounInflectorFr()
27
-
28
- describe('NounInflector', function () {
29
- describe('.pluralize()', function () {
30
- it('should pluralize exception nouns ending by -al', function () {
31
- expect(inflector.pluralize('carnaval')).toBe('carnavals')
32
- expect(inflector.pluralize('narval')).toBe('narvals')
33
- expect(inflector.pluralize('récital')).toBe('récitals')
34
- })
35
-
36
- it('should pluralize regular nouns ending by -al', function () {
37
- expect(inflector.pluralize('amiral')).toBe('amiraux')
38
- expect(inflector.pluralize('cheval')).toBe('chevaux')
39
- expect(inflector.pluralize('général')).toBe('généraux')
40
- })
41
-
42
- it('should pluralize exception nouns ending by -ail', function () {
43
- expect(inflector.pluralize('bail')).toBe('baux')
44
- expect(inflector.pluralize('vitrail')).toBe('vitraux')
45
- expect(inflector.pluralize('émail')).toBe('émaux')
46
- })
47
-
48
- it('should pluralize regular nouns ending by -ail', function () {
49
- expect(inflector.pluralize('détail')).toBe('détails')
50
- expect(inflector.pluralize('poitrail')).toBe('poitrails')
51
- expect(inflector.pluralize('chandail')).toBe('chandails')
52
- })
53
-
54
- it('should pluralize exception nouns ending by -il', function () {
55
- expect(inflector.pluralize('ciel')).toBe('cieux')
56
- expect(inflector.pluralize('œil')).toBe('yeux')
57
- })
58
-
59
- it('should pluralize exception nouns ending by -ou', function () {
60
- expect(inflector.pluralize('bijou')).toBe('bijoux')
61
- expect(inflector.pluralize('joujou')).toBe('joujoux')
62
- expect(inflector.pluralize('hibou')).toBe('hiboux')
63
- })
64
-
65
- it('should pluralize regular nouns ending by -ou', function () {
66
- expect(inflector.pluralize('trou')).toBe('trous')
67
- expect(inflector.pluralize('bambou')).toBe('bambous')
68
- expect(inflector.pluralize('toutou')).toBe('toutous')
69
- })
70
-
71
- it('should pluralize exception nouns ending by -au', function () {
72
- expect(inflector.pluralize('berimbau')).toBe('berimbaus')
73
- expect(inflector.pluralize('landau')).toBe('landaus')
74
- expect(inflector.pluralize('pilau')).toBe('pilaus')
75
- })
76
-
77
- it('should pluralize regular nouns ending by -au', function () {
78
- expect(inflector.pluralize('cadeau')).toBe('cadeaux')
79
- expect(inflector.pluralize('beau')).toBe('beaux')
80
- expect(inflector.pluralize('étau')).toBe('étaux')
81
- })
82
-
83
- it('should pluralize exception nouns ending by -eu', function () {
84
- expect(inflector.pluralize('bleu')).toBe('bleus')
85
- expect(inflector.pluralize('émeu')).toBe('émeus')
86
- expect(inflector.pluralize('pneu')).toBe('pneus')
87
- })
88
-
89
- it('should pluralize regular nouns ending by -eu', function () {
90
- expect(inflector.pluralize('pieu')).toBe('pieux')
91
- expect(inflector.pluralize('lieu')).toBe('lieux')
92
- expect(inflector.pluralize('feu')).toBe('feux')
93
- })
94
-
95
- it('should pluralize regular nouns ending by -eau', function () {
96
- expect(inflector.pluralize('eau')).toBe('eaux')
97
- expect(inflector.pluralize('manteau')).toBe('manteaux')
98
- expect(inflector.pluralize('arbrisseau')).toBe('arbrisseaux')
99
- })
100
-
101
- it('should pluralize regular nouns ending by -œu', function () {
102
- expect(inflector.pluralize('vœu')).toBe('vœux')
103
- })
104
-
105
- it('should pluralize regular nouns ending by -s, -x or -z', function () {
106
- expect(inflector.pluralize('os')).toBe('os')
107
- expect(inflector.pluralize('cas')).toBe('cas')
108
- expect(inflector.pluralize('rhinocéros')).toBe('rhinocéros')
109
-
110
- expect(inflector.pluralize('houx')).toBe('houx')
111
- expect(inflector.pluralize('lynx')).toBe('lynx')
112
- expect(inflector.pluralize('roux')).toBe('roux')
113
-
114
- expect(inflector.pluralize('gaz')).toBe('gaz')
115
- expect(inflector.pluralize('quartz')).toBe('quartz')
116
- expect(inflector.pluralize('quiz')).toBe('quiz')
117
- })
118
-
119
- it('should pluralize exception nouns', function () {
120
- expect(inflector.pluralize('ail')).toBe('aulx')
121
- expect(inflector.pluralize('bétail')).toBe('bestiaux')
122
- })
123
-
124
- it('should pluralize regular nouns', function () {
125
- expect(inflector.pluralize('chai')).toBe('chais')
126
- expect(inflector.pluralize('vérité')).toBe('vérités')
127
- expect(inflector.pluralize('orange')).toBe('oranges')
128
- })
129
- })
130
-
131
- describe('.singularize()', function () {
132
- it('should singularize regular nouns ending by -aux', function () {
133
- expect(inflector.singularize('amiraux')).toBe('amiral')
134
- expect(inflector.singularize('chevaux')).toBe('cheval')
135
- expect(inflector.singularize('généraux')).toBe('général')
136
- })
137
-
138
- it('should singularize exception nouns ending by -aux', function () {
139
- expect(inflector.singularize('baux')).toBe('bail')
140
- expect(inflector.singularize('vitraux')).toBe('vitrail')
141
- expect(inflector.singularize('émaux')).toBe('émail')
142
- })
143
-
144
- it('should singularize regular nouns ending by -aux', function () {
145
- expect(inflector.singularize('cadeaux')).toBe('cadeau')
146
- expect(inflector.singularize('beaux')).toBe('beau')
147
- expect(inflector.singularize('étaux')).toBe('étau')
148
- })
149
-
150
- it('should singularize nouns with multiple plural forms', function () {
151
- expect(inflector.singularize('ails')).toBe('ail')
152
- expect(inflector.singularize('aulx')).toBe('ail')
153
- expect(inflector.singularize('ciels')).toBe('ciel')
154
- expect(inflector.singularize('cieux')).toBe('ciel')
155
- expect(inflector.singularize('œils')).toBe('œil')
156
- expect(inflector.singularize('yeux')).toBe('œil')
157
- expect(inflector.singularize('aïeuls')).toBe('aïeul') // Regular
158
- expect(inflector.singularize('aïeux')).toBe('aïeul')
159
- expect(inflector.singularize('bisaïeuls')).toBe('bisaïeul') // Regular
160
- expect(inflector.singularize('bisaïeux')).toBe('bisaïeul')
161
- expect(inflector.singularize('craus')).toBe('crau')
162
- expect(inflector.singularize('craux')).toBe('crau')
163
- expect(inflector.singularize('graus')).toBe('grau')
164
- expect(inflector.singularize('graux')).toBe('grau')
165
- expect(inflector.singularize('sénaus')).toBe('sénau')
166
- expect(inflector.singularize('sénaux')).toBe('sénau')
167
- expect(inflector.singularize('tussaus')).toBe('tussau')
168
- expect(inflector.singularize('tussaux')).toBe('tussau')
169
- expect(inflector.singularize('emposieus')).toBe('emposieu')
170
- expect(inflector.singularize('emposieux')).toBe('emposieu')
171
- expect(inflector.singularize('richelieus')).toBe('richelieu')
172
- expect(inflector.singularize('richelieux')).toBe('richelieu')
173
- // expect(inflector.singularize('feus')).toBe('feu'); // This one is an adjective.
174
- expect(inflector.singularize('feux')).toBe('feu')
175
- expect(inflector.singularize('lieus')).toBe('lieu') // Fish
176
- expect(inflector.singularize('lieux')).toBe('lieu')
177
- expect(inflector.singularize('corails')).toBe('corail')
178
- expect(inflector.singularize('coraux')).toBe('corail')
179
- })
180
-
181
- it('should singularize exception nouns ending by -oux', function () {
182
- expect(inflector.singularize('bijoux')).toBe('bijou')
183
- expect(inflector.singularize('joujoux')).toBe('joujou')
184
- expect(inflector.singularize('hiboux')).toBe('hibou')
185
- })
186
-
187
- it('should singularize exception nouns ending by -eus', function () {
188
- expect(inflector.singularize('bleus')).toBe('bleu')
189
- expect(inflector.singularize('émeus')).toBe('émeu')
190
- expect(inflector.singularize('pneus')).toBe('pneu')
191
- })
192
-
193
- it('should singularize regular nouns ending by -eux', function () {
194
- expect(inflector.singularize('pieux')).toBe('pieu')
195
- expect(inflector.singularize('lieux')).toBe('lieu')
196
- expect(inflector.singularize('feux')).toBe('feu')
197
- })
198
-
199
- it('should singularize regular nouns ending by -eaux', function () {
200
- expect(inflector.singularize('eaux')).toBe('eau')
201
- expect(inflector.singularize('manteaux')).toBe('manteau')
202
- expect(inflector.singularize('arbrisseaux')).toBe('arbrisseau')
203
- })
204
-
205
- it('should singularize regular nouns ending by -œux', function () {
206
- expect(inflector.singularize('vœux')).toBe('vœu')
207
- })
208
-
209
- it('should singularize regular nouns ending by -s, -x or -z', function () {
210
- expect(inflector.singularize('cas')).toBe('cas')
211
- expect(inflector.singularize('os')).toBe('os')
212
- expect(inflector.singularize('rhinocéros')).toBe('rhinocéros')
213
-
214
- expect(inflector.singularize('houx')).toBe('houx')
215
- expect(inflector.singularize('lynx')).toBe('lynx')
216
- expect(inflector.singularize('roux')).toBe('roux')
217
-
218
- expect(inflector.singularize('gaz')).toBe('gaz')
219
- expect(inflector.singularize('quartz')).toBe('quartz')
220
- expect(inflector.singularize('quiz')).toBe('quiz')
221
- })
222
-
223
- it('should singularize exception nouns', function () {
224
- expect(inflector.singularize('bestiaux')).toBe('bétail')
225
- })
226
-
227
- it('should singularize regular nouns', function () {
228
- expect(inflector.singularize('chais')).toBe('chai')
229
- expect(inflector.singularize('vérités')).toBe('vérité')
230
- expect(inflector.singularize('oranges')).toBe('orange')
231
-
232
- // Exception nouns ending by -als
233
- expect(inflector.singularize('carnavals')).toBe('carnaval')
234
- expect(inflector.singularize('narvals')).toBe('narval')
235
- expect(inflector.singularize('récitals')).toBe('récital')
236
-
237
- // Regular nouns ending by -ails
238
- expect(inflector.singularize('détails')).toBe('détail')
239
- expect(inflector.singularize('poitrails')).toBe('poitrail')
240
- expect(inflector.singularize('chandails')).toBe('chandail')
241
-
242
- // Regular nouns ending by -ous
243
- expect(inflector.singularize('trous')).toBe('trou')
244
- expect(inflector.singularize('bambous')).toBe('bambou')
245
- expect(inflector.singularize('toutous')).toBe('toutou')
246
-
247
- // Exception nouns ending by -aus
248
- expect(inflector.singularize('berimbaus')).toBe('berimbau')
249
- expect(inflector.singularize('landaus')).toBe('landau')
250
- expect(inflector.singularize('pilaus')).toBe('pilau')
251
- })
252
- })
253
-
254
- /*
255
- These tests ensure pluralizing plurals or singularizing singulars
256
- won't lead to wrong results.
257
- */
258
- describe('pluralize()', function () {
259
- it('should pluralize exception nouns ending by -al', function () {
260
- expect(inflector.pluralize('carnavals')).toBe('carnavals')
261
- expect(inflector.pluralize('narvals')).toBe('narvals')
262
- expect(inflector.pluralize('récitals')).toBe('récitals')
263
- })
264
-
265
- it('should pluralize regular nouns ending by -al', function () {
266
- expect(inflector.pluralize('amiraux')).toBe('amiraux')
267
- expect(inflector.pluralize('chevaux')).toBe('chevaux')
268
- expect(inflector.pluralize('généraux')).toBe('généraux')
269
- })
270
-
271
- it('should pluralize exception nouns ending by -ail', function () {
272
- expect(inflector.pluralize('baux')).toBe('baux')
273
- expect(inflector.pluralize('vitraux')).toBe('vitraux')
274
- expect(inflector.pluralize('émaux')).toBe('émaux')
275
- })
276
-
277
- it('should pluralize regular nouns ending by -ail', function () {
278
- expect(inflector.pluralize('détails')).toBe('détails')
279
- expect(inflector.pluralize('poitrails')).toBe('poitrails')
280
- expect(inflector.pluralize('chandails')).toBe('chandails')
281
- })
282
-
283
- it('should pluralize exception nouns ending by -il', function () {
284
- expect(inflector.pluralize('cieux')).toBe('cieux')
285
- expect(inflector.pluralize('yeux')).toBe('yeux')
286
- })
287
-
288
- it('should pluralize exception nouns ending by -ou', function () {
289
- expect(inflector.pluralize('bijoux')).toBe('bijoux')
290
- expect(inflector.pluralize('joujoux')).toBe('joujoux')
291
- expect(inflector.pluralize('hiboux')).toBe('hiboux')
292
- })
293
-
294
- it('should pluralize regular nouns ending by -ou', function () {
295
- expect(inflector.pluralize('trous')).toBe('trous')
296
- expect(inflector.pluralize('bambous')).toBe('bambous')
297
- expect(inflector.pluralize('toutous')).toBe('toutous')
298
- })
299
-
300
- it('should pluralize exception nouns ending by -au', function () {
301
- expect(inflector.pluralize('berimbaus')).toBe('berimbaus')
302
- expect(inflector.pluralize('landaus')).toBe('landaus')
303
- expect(inflector.pluralize('pilaus')).toBe('pilaus')
304
- })
305
-
306
- it('should pluralize regular nouns ending by -au', function () {
307
- expect(inflector.pluralize('cadeaux')).toBe('cadeaux')
308
- expect(inflector.pluralize('beaux')).toBe('beaux')
309
- expect(inflector.pluralize('étaux')).toBe('étaux')
310
- })
311
-
312
- it('should pluralize exception nouns ending by -eu', function () {
313
- expect(inflector.pluralize('bleus')).toBe('bleus')
314
- expect(inflector.pluralize('émeus')).toBe('émeus')
315
- expect(inflector.pluralize('pneus')).toBe('pneus')
316
- })
317
-
318
- it('should pluralize regular nouns ending by -eu', function () {
319
- expect(inflector.pluralize('pieux')).toBe('pieux')
320
- expect(inflector.pluralize('lieux')).toBe('lieux')
321
- expect(inflector.pluralize('feux')).toBe('feux')
322
- })
323
-
324
- it('should pluralize regular nouns ending by -eau', function () {
325
- expect(inflector.pluralize('eaux')).toBe('eaux')
326
- expect(inflector.pluralize('manteaux')).toBe('manteaux')
327
- expect(inflector.pluralize('arbrisseaux')).toBe('arbrisseaux')
328
- })
329
-
330
- it('should pluralize regular nouns ending by -œu', function () {
331
- expect(inflector.pluralize('vœux')).toBe('vœux')
332
- })
333
-
334
- /*
335
- it('should pluralize regular nouns ending by -s, -x or -z', function () {
336
- expect(inflector.pluralize('os')).toBe('os')
337
- expect(inflector.pluralize('cas')).toBe('cas')
338
- expect(inflector.pluralize('rhinocéros')).toBe('rhinocéros')
339
-
340
- expect(inflector.pluralize('houx')).toBe('houx')
341
- expect(inflector.pluralize('lynx')).toBe('lynx')
342
- expect(inflector.pluralize('roux')).toBe('roux')
343
-
344
- expect(inflector.pluralize('gaz')).toBe('gaz')
345
- expect(inflector.pluralize('quartz')).toBe('quartz')
346
- expect(inflector.pluralize('quiz')).toBe('quiz')
347
- })
348
- */
349
-
350
- it('should pluralize exception nouns', function () {
351
- expect(inflector.pluralize('aulx')).toBe('aulx')
352
- expect(inflector.pluralize('bestiaux')).toBe('bestiaux')
353
- })
354
-
355
- it('should pluralize regular nouns', function () {
356
- expect(inflector.pluralize('chais')).toBe('chais')
357
- expect(inflector.pluralize('vérités')).toBe('vérités')
358
- expect(inflector.pluralize('oranges')).toBe('oranges')
359
- })
360
- })
361
-
362
- describe('.singularize()', function () {
363
- it('should singularize regular nouns ending by -aux', function () {
364
- expect(inflector.singularize('amiral')).toBe('amiral')
365
- expect(inflector.singularize('cheval')).toBe('cheval')
366
- expect(inflector.singularize('général')).toBe('général')
367
- })
368
-
369
- it('should singularize exception nouns ending by -aux', function () {
370
- expect(inflector.singularize('bail')).toBe('bail')
371
- expect(inflector.singularize('vitrail')).toBe('vitrail')
372
- expect(inflector.singularize('émail')).toBe('émail')
373
- })
374
-
375
- it('should singularize regular nouns ending by -aux', function () {
376
- expect(inflector.singularize('cadeau')).toBe('cadeau')
377
- expect(inflector.singularize('beau')).toBe('beau')
378
- expect(inflector.singularize('étau')).toBe('étau')
379
- })
380
-
381
- it('should singularize nouns with multiple plural forms', function () {
382
- expect(inflector.singularize('ail')).toBe('ail')
383
- expect(inflector.singularize('ciel')).toBe('ciel')
384
- expect(inflector.singularize('œil')).toBe('œil')
385
- expect(inflector.singularize('aïeul')).toBe('aïeul')
386
- expect(inflector.singularize('bisaïeul')).toBe('bisaïeul')
387
- expect(inflector.singularize('crau')).toBe('crau')
388
- expect(inflector.singularize('grau')).toBe('grau')
389
- expect(inflector.singularize('sénau')).toBe('sénau')
390
- expect(inflector.singularize('tussau')).toBe('tussau')
391
- expect(inflector.singularize('emposieu')).toBe('emposieu')
392
- expect(inflector.singularize('richelieu')).toBe('richelieu')
393
- expect(inflector.singularize('feu')).toBe('feu')
394
- expect(inflector.singularize('lieu')).toBe('lieu') // Fish
395
- expect(inflector.singularize('corail')).toBe('corail')
396
- })
397
-
398
- it('should singularize exception nouns ending by -oux', function () {
399
- expect(inflector.singularize('bijou')).toBe('bijou')
400
- expect(inflector.singularize('joujou')).toBe('joujou')
401
- expect(inflector.singularize('hibou')).toBe('hibou')
402
- })
403
-
404
- it('should singularize exception nouns ending by -eus', function () {
405
- expect(inflector.singularize('bleu')).toBe('bleu')
406
- expect(inflector.singularize('émeu')).toBe('émeu')
407
- expect(inflector.singularize('pneu')).toBe('pneu')
408
- })
409
-
410
- it('should singularize regular nouns ending by -eux', function () {
411
- expect(inflector.singularize('pieu')).toBe('pieu')
412
- expect(inflector.singularize('lieu')).toBe('lieu')
413
- expect(inflector.singularize('feu')).toBe('feu')
414
- })
415
-
416
- it('should singularize regular nouns ending by -eaux', function () {
417
- expect(inflector.singularize('eau')).toBe('eau')
418
- expect(inflector.singularize('manteau')).toBe('manteau')
419
- expect(inflector.singularize('arbrisseau')).toBe('arbrisseau')
420
- })
421
-
422
- it('should singularize regular nouns ending by -œux', function () {
423
- expect(inflector.singularize('vœu')).toBe('vœu')
424
- })
425
-
426
- /*
427
- it('should singularize regular nouns ending by -s, -x or -z', function () {
428
- expect(inflector.singularize('cas')).toBe('cas')
429
- expect(inflector.singularize('os')).toBe('os')
430
- expect(inflector.singularize('rhinocéros')).toBe('rhinocéros')
431
-
432
- expect(inflector.singularize('houx')).toBe('houx')
433
- expect(inflector.singularize('lynx')).toBe('lynx')
434
- expect(inflector.singularize('roux')).toBe('roux')
435
-
436
- expect(inflector.singularize('gaz')).toBe('gaz')
437
- expect(inflector.singularize('quartz')).toBe('quartz')
438
- expect(inflector.singularize('quiz')).toBe('quiz')
439
- })
440
- */
441
-
442
- it('should singularize exception nouns', function () {
443
- expect(inflector.singularize('bétail')).toBe('bétail')
444
- })
445
-
446
- it('should singularize regular nouns', function () {
447
- expect(inflector.singularize('chai')).toBe('chai')
448
- expect(inflector.singularize('vérité')).toBe('vérité')
449
- expect(inflector.singularize('orange')).toBe('orange')
450
-
451
- // Exception nouns ending by -als
452
- expect(inflector.singularize('carnaval')).toBe('carnaval')
453
- expect(inflector.singularize('narval')).toBe('narval')
454
- expect(inflector.singularize('récital')).toBe('récital')
455
-
456
- // Regular nouns ending by -ails
457
- expect(inflector.singularize('détail')).toBe('détail')
458
- expect(inflector.singularize('poitrail')).toBe('poitrail')
459
- expect(inflector.singularize('chandail')).toBe('chandail')
460
-
461
- // Regular nouns ending by -ous
462
- expect(inflector.singularize('trou')).toBe('trou')
463
- expect(inflector.singularize('bambou')).toBe('bambou')
464
- expect(inflector.singularize('toutou')).toBe('toutou')
465
-
466
- // Exception nouns ending by -aus
467
- expect(inflector.singularize('berimbau')).toBe('berimbau')
468
- expect(inflector.singularize('landau')).toBe('landau')
469
- expect(inflector.singularize('pilau')).toBe('pilau')
470
- })
471
- })
472
- })
@@ -1,116 +0,0 @@
1
- /*
2
- Copyright (c) 2012, Guillaume Marty
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 { NounInflectorJa } from 'lib/natural'
26
- const inflector = new NounInflectorJa()
27
-
28
- describe('NounInflector', function () {
29
- describe('.pluralize()', function () {
30
- it('should pluralize nouns', function () {
31
- expect(inflector.pluralize('ひと')).toBe('ひとたち')
32
- expect(inflector.pluralize('わたし')).toBe('わたしたち')
33
- expect(inflector.pluralize('私')).toBe('私たち')
34
- })
35
-
36
- it('should not pluralize exceptions', function () {
37
- expect(inflector.pluralize('ともだち')).toBe('ともだち')
38
- expect(inflector.pluralize('友だち')).toBe('友だち')
39
- expect(inflector.pluralize('友達')).toBe('友達')
40
- })
41
-
42
- it('should pluralize archaic forms', function () {
43
- expect(inflector.pluralize('神')).toBe('神神')
44
- expect(inflector.pluralize('人')).toBe('人人')
45
- expect(inflector.pluralize('我')).toBe('我我')
46
- })
47
- })
48
-
49
- describe('.singularize()', function () {
50
- it('should singularize regular nouns ending by -tachi in Hiragana', function () {
51
- expect(inflector.singularize('わたしたち')).toBe('わたし')
52
- expect(inflector.singularize('人たち')).toBe('人')
53
- expect(inflector.singularize('りかたち')).toBe('りか')
54
- })
55
-
56
- it('should not singularize exception nouns ending by -tachi in Hiragana', function () {
57
- expect(inflector.singularize('ついたち')).toBe('ついたち')
58
- expect(inflector.singularize('かたち')).toBe('かたち')
59
- expect(inflector.singularize('はたち')).toBe('はたち')
60
- })
61
-
62
- it('should singularize regular nouns ending by -tachi in Kanji', function () {
63
- expect(inflector.singularize('わたし達')).toBe('わたし')
64
- expect(inflector.singularize('人達')).toBe('人')
65
- expect(inflector.singularize('日伊達')).toBe('日伊')
66
- })
67
-
68
- it('should not singularize exception nouns ending by -tachi in Kanji', function () {
69
- expect(inflector.singularize('上達')).toBe('上達')
70
- expect(inflector.singularize('配達')).toBe('配達')
71
- expect(inflector.singularize('発達')).toBe('発達')
72
- })
73
-
74
- it('should singularize regular nouns ending by -ra in Kanji', function () {
75
- expect(inflector.singularize('僕等')).toBe('僕')
76
- expect(inflector.singularize('貴様等')).toBe('貴様')
77
- expect(inflector.singularize('圭一等')).toBe('圭一')
78
- })
79
-
80
- it('should not singularize exception nouns ending by -ra in Kanji', function () {
81
- expect(inflector.singularize('下等')).toBe('下等')
82
- expect(inflector.singularize('初等')).toBe('初等')
83
- expect(inflector.singularize('一等')).toBe('一等')
84
- })
85
-
86
- it('should singularize regular nouns ending by -gata', function () {
87
- expect(inflector.singularize('神様方')).toBe('神様')
88
- expect(inflector.singularize('先生方')).toBe('先生')
89
- expect(inflector.singularize('あなたがた')).toBe('あなた')
90
- })
91
-
92
- it('should singularize regular nouns ending by -domo', function () {
93
- expect(inflector.singularize('人間共')).toBe('人間')
94
- expect(inflector.singularize('野郎共')).toBe('野郎')
95
- expect(inflector.singularize('ガキども')).toBe('ガキ')
96
- })
97
-
98
- it('should pluralize archaic forms', function () {
99
- expect(inflector.singularize('神神')).toBe('神')
100
- expect(inflector.singularize('人人')).toBe('人')
101
- expect(inflector.singularize('我我')).toBe('我')
102
- })
103
- })
104
-
105
- /*
106
- describe('.attach()', function() {
107
- it('should attach new methods to String', function() {
108
- inflector.attach();
109
- expect('私'.pluralizeNoun()).toBe('私たち');
110
- expect('私たち'.singularizeNoun()).toBe('私');
111
- expect('人'.pluralizeNoun()).toBe('人人');
112
- expect('人人'.singularizeNoun()).toBe('人');
113
- });
114
- });
115
- */
116
- })