-
Notifications
You must be signed in to change notification settings - Fork 855
/
Copy pathnoun_inflector_ja_spec.ts
116 lines (98 loc) · 4.81 KB
/
noun_inflector_ja_spec.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
/*
Copyright (c) 2012, Guillaume Marty
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
'use strict'
import { NounInflectorJa } from 'lib/natural'
const inflector = new NounInflectorJa()
describe('NounInflector', function () {
describe('.pluralize()', function () {
it('should pluralize nouns', function () {
expect(inflector.pluralize('ひと')).toBe('ひとたち')
expect(inflector.pluralize('わたし')).toBe('わたしたち')
expect(inflector.pluralize('私')).toBe('私たち')
})
it('should not pluralize exceptions', function () {
expect(inflector.pluralize('ともだち')).toBe('ともだち')
expect(inflector.pluralize('友だち')).toBe('友だち')
expect(inflector.pluralize('友達')).toBe('友達')
})
it('should pluralize archaic forms', function () {
expect(inflector.pluralize('神')).toBe('神神')
expect(inflector.pluralize('人')).toBe('人人')
expect(inflector.pluralize('我')).toBe('我我')
})
})
describe('.singularize()', function () {
it('should singularize regular nouns ending by -tachi in Hiragana', function () {
expect(inflector.singularize('わたしたち')).toBe('わたし')
expect(inflector.singularize('人たち')).toBe('人')
expect(inflector.singularize('りかたち')).toBe('りか')
})
it('should not singularize exception nouns ending by -tachi in Hiragana', function () {
expect(inflector.singularize('ついたち')).toBe('ついたち')
expect(inflector.singularize('かたち')).toBe('かたち')
expect(inflector.singularize('はたち')).toBe('はたち')
})
it('should singularize regular nouns ending by -tachi in Kanji', function () {
expect(inflector.singularize('わたし達')).toBe('わたし')
expect(inflector.singularize('人達')).toBe('人')
expect(inflector.singularize('日伊達')).toBe('日伊')
})
it('should not singularize exception nouns ending by -tachi in Kanji', function () {
expect(inflector.singularize('上達')).toBe('上達')
expect(inflector.singularize('配達')).toBe('配達')
expect(inflector.singularize('発達')).toBe('発達')
})
it('should singularize regular nouns ending by -ra in Kanji', function () {
expect(inflector.singularize('僕等')).toBe('僕')
expect(inflector.singularize('貴様等')).toBe('貴様')
expect(inflector.singularize('圭一等')).toBe('圭一')
})
it('should not singularize exception nouns ending by -ra in Kanji', function () {
expect(inflector.singularize('下等')).toBe('下等')
expect(inflector.singularize('初等')).toBe('初等')
expect(inflector.singularize('一等')).toBe('一等')
})
it('should singularize regular nouns ending by -gata', function () {
expect(inflector.singularize('神様方')).toBe('神様')
expect(inflector.singularize('先生方')).toBe('先生')
expect(inflector.singularize('あなたがた')).toBe('あなた')
})
it('should singularize regular nouns ending by -domo', function () {
expect(inflector.singularize('人間共')).toBe('人間')
expect(inflector.singularize('野郎共')).toBe('野郎')
expect(inflector.singularize('ガキども')).toBe('ガキ')
})
it('should pluralize archaic forms', function () {
expect(inflector.singularize('神神')).toBe('神')
expect(inflector.singularize('人人')).toBe('人')
expect(inflector.singularize('我我')).toBe('我')
})
})
/*
describe('.attach()', function() {
it('should attach new methods to String', function() {
inflector.attach();
expect('私'.pluralizeNoun()).toBe('私たち');
expect('私たち'.singularizeNoun()).toBe('私');
expect('人'.pluralizeNoun()).toBe('人人');
expect('人人'.singularizeNoun()).toBe('人');
});
});
*/
})