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/esm/rules.js
CHANGED
|
@@ -73,11 +73,18 @@ export const F_STEM_PLURALS = [
|
|
|
73
73
|
['wolf', 'wolves'],
|
|
74
74
|
];
|
|
75
75
|
/**
|
|
76
|
-
*
|
|
77
|
-
*
|
|
78
|
-
*
|
|
76
|
+
* Adjectives, never plurals: anxious, various, porous. No noun stem ends in
|
|
77
|
+
* "ou", so nothing here is ever a dropped-s away from a singular.
|
|
78
|
+
*
|
|
79
|
+
* There is no equivalent rule for the rest of "-is"/"-us", because none exists:
|
|
80
|
+
* "apis" and "iris" are both a vowel plus "s" (api + s, iri + s), so no suffix
|
|
81
|
+
* tells the plural from the singular. Whether a word is one or the other is a
|
|
82
|
+
* dictionary fact, and the dictionary-proven singulars live in
|
|
83
|
+
* SINGULAR_EXCEPTIONS as self-mappings (status -> status, analysis -> analysis).
|
|
84
|
+
* Words the dictionary does not know fall through to the generic "drop the s",
|
|
85
|
+
* which is what coined identifiers want: apis -> api, cpus -> cpu, uris -> uri.
|
|
79
86
|
*/
|
|
80
|
-
const
|
|
87
|
+
const ADJECTIVE_OUS_REGEX = /ous$/i;
|
|
81
88
|
/**
|
|
82
89
|
* The only -ice plurals. The inflection library's rule is written `([m|l])ice`,
|
|
83
90
|
* whose character class also matches "|", and it fires on any word ending in
|
|
@@ -184,7 +191,7 @@ function applyGenericSingularRules(word) {
|
|
|
184
191
|
export function singularizeByRules(word) {
|
|
185
192
|
const normalizedWord = normalizeMalformedDoubleS(word);
|
|
186
193
|
const lowerWord = normalizedWord.toLowerCase();
|
|
187
|
-
if (
|
|
194
|
+
if (ADJECTIVE_OUS_REGEX.test(normalizedWord)) {
|
|
188
195
|
return normalizedWord;
|
|
189
196
|
}
|
|
190
197
|
if (ICE_REGEX.test(normalizedWord)) {
|