diff --git a/lib/natural/inflectors/noun_inflector.js b/lib/natural/inflectors/noun_inflector.js index 1b01e49cb..c14ba35d6 100644 --- a/lib/natural/inflectors/noun_inflector.js +++ b/lib/natural/inflectors/noun_inflector.js @@ -137,6 +137,10 @@ const NounInflector = function () { // handkerchief - handkerchiefs / handkerchieves this.singularForms.regularForms.push([/(.*)ves$/i, '$1f']) + // expenses - expense + // defenses - defense + this.singularForms.regularForms.push([/(.*)nses$/i, '$1nse']) + this.singularForms.regularForms.push([/([^v])ies$/i, '$1y']) this.singularForms.regularForms.push([/ives$/i, 'ife']) this.singularForms.regularForms.push([/(antenn|formul|nebul|vertebr|vit)ae$/i, '$1a']) diff --git a/spec/noun_inflector_spec.js b/spec/noun_inflector_spec.js index 26203dcfc..18d23d4f6 100644 --- a/spec/noun_inflector_spec.js +++ b/spec/noun_inflector_spec.js @@ -357,5 +357,13 @@ describe('noun inflector', function () { expect(myInflector.singularize('wharves')).toBe('wharf') expect(myInflector.singularize('handkerchieves')).toBe('handkerchief') }) + + it('should handle words ending in rf', function () { + const myInflector = new NounInflector() + expect(myInflector.singularize('expenses')).toBe('expense') + expect(myInflector.singularize('defenses')).toBe('defense') + expect(myInflector.pluralize('expense')).toBe('expenses') + expect(myInflector.pluralize('defense')).toBe('defenses') + }) }) })