inflekt 0.7.2 → 0.8.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.
- package/esm/exceptions.js +208 -212
- package/esm/rules.js +12 -5
- package/exceptions.js +208 -212
- package/package.json +2 -2
- package/rules.js +12 -5
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "inflekt",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.8.0",
|
|
4
4
|
"description": "Inflection utilities for pluralization and singularization with PostGraphile-compatible Latin suffix handling",
|
|
5
5
|
"author": "Constructive <developers@constructive.io>",
|
|
6
6
|
"homepage": "https://github.com/constructive-io/dev-utils",
|
|
@@ -44,5 +44,5 @@
|
|
|
44
44
|
"inflection": "^3.0.0",
|
|
45
45
|
"komoji": "0.9.1"
|
|
46
46
|
},
|
|
47
|
-
"gitHead": "
|
|
47
|
+
"gitHead": "d8aeec3980221f7aeccc4c986e14d89a1270ab61"
|
|
48
48
|
}
|
package/rules.js
CHANGED
|
@@ -114,11 +114,18 @@ exports.F_STEM_PLURALS = [
|
|
|
114
114
|
['wolf', 'wolves'],
|
|
115
115
|
];
|
|
116
116
|
/**
|
|
117
|
-
*
|
|
118
|
-
*
|
|
119
|
-
*
|
|
117
|
+
* Adjectives, never plurals: anxious, various, porous. No noun stem ends in
|
|
118
|
+
* "ou", so nothing here is ever a dropped-s away from a singular.
|
|
119
|
+
*
|
|
120
|
+
* There is no equivalent rule for the rest of "-is"/"-us", because none exists:
|
|
121
|
+
* "apis" and "iris" are both a vowel plus "s" (api + s, iri + s), so no suffix
|
|
122
|
+
* tells the plural from the singular. Whether a word is one or the other is a
|
|
123
|
+
* dictionary fact, and the dictionary-proven singulars live in
|
|
124
|
+
* SINGULAR_EXCEPTIONS as self-mappings (status -> status, analysis -> analysis).
|
|
125
|
+
* Words the dictionary does not know fall through to the generic "drop the s",
|
|
126
|
+
* which is what coined identifiers want: apis -> api, cpus -> cpu, uris -> uri.
|
|
120
127
|
*/
|
|
121
|
-
const
|
|
128
|
+
const ADJECTIVE_OUS_REGEX = /ous$/i;
|
|
122
129
|
/**
|
|
123
130
|
* The only -ice plurals. The inflection library's rule is written `([m|l])ice`,
|
|
124
131
|
* whose character class also matches "|", and it fires on any word ending in
|
|
@@ -225,7 +232,7 @@ function applyGenericSingularRules(word) {
|
|
|
225
232
|
function singularizeByRules(word) {
|
|
226
233
|
const normalizedWord = normalizeMalformedDoubleS(word);
|
|
227
234
|
const lowerWord = normalizedWord.toLowerCase();
|
|
228
|
-
if (
|
|
235
|
+
if (ADJECTIVE_OUS_REGEX.test(normalizedWord)) {
|
|
229
236
|
return normalizedWord;
|
|
230
237
|
}
|
|
231
238
|
if (ICE_REGEX.test(normalizedWord)) {
|