/
toPlural.test.js
145 lines (139 loc) · 4.25 KB
/
toPlural.test.js
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
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
import test from 'tape'
import nlp from '../_lib.js'
const here = '[three/noun-toPlural] '
test('toPlural:', function (t) {
let arr = [
['snake', 'snakes'],
['ski', 'skis'],
// ["Barrymore", "Barrymores"],
['witch', 'witches'],
['box', 'boxes'],
['gas', 'gases'],
['kiss', 'kisses'],
['index', 'indices'],
['appendix', 'appendices'],
['criterion', 'criteria'],
['berry', 'berries'],
['activity', 'activities'],
['daisy', 'daisies'],
['church', 'churches'],
['fox', 'foxes'],
['stomach', 'stomachs'],
['epoch', 'epochs'],
['knife', 'knives'],
['half', 'halves'],
['scarf', 'scarves'],
['chief', 'chiefs'],
['spoof', 'spoofs'],
['cafe', 'cafes'],
['gulf', 'gulfs'],
['alternative', 'alternatives'],
['solo', 'solos'],
// ['zero', 'zeros'],
['avocado', 'avocados'],
['studio', 'studios'],
['zoo', 'zoos'],
['embryo', 'embryos'],
['hero', 'heroes'],
['banjo', 'banjos'],
['cargo', 'cargos'],
['flamingo', 'flamingos'],
['fresco', 'frescos'],
['ghetto', 'ghettos'],
['halo', 'halos'],
['mango', 'mangos'],
['memento', 'mementos'],
['motto', 'mottos'],
['tornado', 'tornados'],
['tuxedo', 'tuxedos'],
['volcano', 'volcanos'],
['bus', 'buses'],
['crisis', 'crises'],
['analysis', 'analyses'],
['neurosis', 'neuroses'],
['aircraft', 'aircraft'],
['halibut', 'halibut'],
['moose', 'moose'],
['salmon', 'salmon'],
['sheep', 'sheep'],
['spacecraft', 'spacecraft'],
['tuna', 'tuna'],
['trout', 'trout'],
['armadillo', 'armadillos'],
['auto', 'autos'],
['bravo', 'bravos'],
['bronco', 'broncos'],
['casino', 'casinos'],
['combo', 'combos'],
['gazebo', 'gazebos'],
//test that plural.pluralize()==plural..
['snake', 'snakes'],
['ski', 'skis'],
// ['mayor of chicago', 'mayors of chicago'],
['witch', 'witches'],
['box', 'boxes'],
['gas', 'gases'],
['spoof', 'spoofs'],
['solo', 'solos'],
['avocado', 'avocados'],
['studio', 'studios'],
['zoo', 'zoos'],
['characteristic', 'characteristics'],
['skeptic', 'skeptics'],
['fabric', 'fabrics'],
['menu', 'menus'],
['tactic', 'tactics'],
['cause', 'causes'],
['bowl', 'bowls'],
['purpose', 'purposes'],
['dose', 'doses'],
['the size', 'the sizes'],
['the prize', 'the prizes'],
['the promise', 'the promises'],
['noise', 'noises'],
['the raise', 'the raises'],
['the exercise', 'the exercises'],
['the bruise', 'the bruises'],
// ['swim', 'swims'],
]
arr.forEach(function (a) {
let doc = nlp(a[0])
doc.tag('Noun').compute('chunks')
let str = doc.nouns().toPlural().text()
t.equal(str, a[1], here + '[toPlural] ' + a[0])
doc = nlp(a[1])
doc.tag('Noun').compute('chunks')
str = doc.nouns().toSingular().text()
t.equal(str, a[0], here + '[toSingular] ' + a[0])
doc = nlp(a[0])
doc.tag('Noun').compute('chunks')
str = doc.nouns().toSingular().text()
t.equal(str, a[0], here + '[stay-singular] ' + a[0])
})
t.end()
})
test('toPlural - longer:', function (t) {
let arr = [
[`we commended him for his hamburger`, `we commended him for his hamburgers`],
[`everything i say, he liked`, `everything i say, he liked`],
[`the tornado in Barrie swept through downtown`, `the tornados in Barrie swept through downtown`],
[`no cookie until after dinner`, `no cookies until after dinners`],
[`my finger looked green afterwards`, `my fingers looked green afterwards`],
// ["keep a cool head", "keep cool heads"],
["petsmart application?", "petsmart applications?"],
["attacked by a bear?", "attacked by bears?"],
// ["Gal's DIARY: He ws quiet 2dy.", "Gal's DIARY: He ws quiet 2dy."],
// ["All right relax.", "All right relax."],
["HP to be self-sufficient by 2010", "HP to be self-sufficient by 2010"],
["the woman", "the women"],
["the woman isn't dead.", "the women are not dead."],
[`my finger was green afterwards`, `my fingers were green afterwards`],
]
arr.forEach(function (a) {
let doc = nlp(a[0])
doc.compute('chunks')
doc.nouns().toPlural()
t.equal(doc.text(), a[1], here + '[toPlural] ' + a[0])
})
t.end()
})