{"id":13847207,"url":"https://github.com/FinNLP/en-inflectors","last_synced_at":"2025-07-12T08:31:25.907Z","repository":{"id":54539783,"uuid":"77856408","full_name":"FinNLP/en-inflectors","owner":"FinNLP","description":"📦 English inflection library for noun (plural to singular and singular to plural), verb (gerund, present \u0026 past) and adjectives (comparative \u0026 superlative) transformations/conjugation.","archived":false,"fork":false,"pushed_at":"2021-02-11T22:51:57.000Z","size":331,"stargazers_count":346,"open_issues_count":10,"forks_count":19,"subscribers_count":6,"default_branch":"master","last_synced_at":"2025-06-17T11:56:58.173Z","etag":null,"topics":["conjugation","inflection","pluralization"],"latest_commit_sha":null,"homepage":"http://en-inflectors.surge.sh/","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/FinNLP.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-01-02T19:22:40.000Z","updated_at":"2025-05-29T20:32:19.000Z","dependencies_parsed_at":"2022-08-13T19:10:14.710Z","dependency_job_id":null,"html_url":"https://github.com/FinNLP/en-inflectors","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/FinNLP/en-inflectors","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FinNLP%2Fen-inflectors","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FinNLP%2Fen-inflectors/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FinNLP%2Fen-inflectors/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FinNLP%2Fen-inflectors/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/FinNLP","download_url":"https://codeload.github.com/FinNLP/en-inflectors/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FinNLP%2Fen-inflectors/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":264962211,"owners_count":23689761,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["conjugation","inflection","pluralization"],"created_at":"2024-08-04T18:01:13.176Z","updated_at":"2025-07-12T08:31:25.396Z","avatar_url":"https://github.com/FinNLP.png","language":"TypeScript","funding_links":[],"categories":["TypeScript"],"sub_categories":[],"readme":"# English Inflectors Library\r\nFor noun (plural to singular and singular to plural), verb (gerund, present \u0026 past) and adjective (comparative, superlative) transformations.\r\n\r\n![npm](https://img.shields.io/npm/dm/en-inflectors.svg)\r\n![npm](https://img.shields.io/npm/v/en-inflectors.svg)\r\n![license](https://img.shields.io/github/license/FinNLP/en-inflectors.svg)\r\n![David](https://img.shields.io/david/FinNLP/en-inflectors.svg)\r\n\r\n## Demo\r\nHere's a quick demo: [http://en-inflectors.surge.sh/](http://en-inflectors.surge.sh/)\r\n\r\n## Installation\r\n\r\n```\r\nnpm install en-inflectors --save\r\n```\r\n\r\n\r\n## Usage\r\n\r\n*  **Import the library**\r\n```javascript\r\n// javascript\r\nconst Inflectors = require(\"en-inflectors\").Inflectors;\r\n```\r\n```typescript\r\n// typescript\r\nimport { Inflectors } from \"en-inflectors\";\r\n```\r\n\r\n* **Instantiate the class**\r\n```javascript\r\nlet instance = new Inflectors(\"book\");\r\n``` \r\n\r\n* **Adjective Inflection**\r\n```javascript\r\nlet instance = new Inflectors(\"big\");\r\ninstance.comparative(); // bigger\r\ninstance.superlative(); // biggest\r\n``` \r\n\r\n* **Verb Conjugation**\r\n```javascript\r\nnew Inflectors(\"rallied\").conjugate(\"VBP\"); // rally\r\nnew Inflectors(\"fly\").conjugate(\"VBD\"); // flew\r\nnew Inflectors(\"throw\").conjugate(\"VBN\"); // thrown\r\nnew Inflectors(\"rally\").conjugate(\"VBS\"); // rallies\r\nnew Inflectors(\"die\").conjugate(\"VBP\"); // dying\r\n\r\n// or you can use the aliases\r\nnew Inflectors(\"rallied\").toPresent(); // rally\r\nnew Inflectors(\"fly\").toPast(); // flew\r\nnew Inflectors(\"throw\").toPastParticiple(); // thrown\r\nnew Inflectors(\"rally\").toPresentS(); // rallies\r\nnew Inflectors(\"die\").toGerund(); // dying\r\n``` \r\n\r\n* **Noun Inflection**\r\n```javascript\r\nconst instanceA = new Inflectors(\"bus\");\r\nconst instanceB = new Inflectors(\"ellipses\");\r\nconst instanceC = new Inflectors(\"money\");\r\n\r\ninstanceA.isCountable(); // true\r\ninstanceB.isCountable(); // true\r\ninstanceC.isCountable(); // false\r\n\r\ninstanceA.isNotCountable(); // false\r\ninstanceB.isNotCountable(); // false\r\ninstanceC.isNotCountable(); // true\r\n\r\ninstanceA.isSingular(); // true\r\ninstanceB.isSingular(); // false\r\ninstanceC.isSingular(); // true\r\n\r\ninstanceA.isPlural(); // false\r\ninstanceB.isPlural(); // true\r\ninstanceC.isPlural(); // true\r\n\r\n// note that uncountable words return true\r\n// on both plural and singular checks\r\n\r\n\r\ninstanceA.toSingular(); // bus (no change)\r\ninstanceB.toSingular(); // ellipsis\r\ninstanceC.toSingular(); // money (no change)\r\n\r\n\r\ninstanceA.toPlural(); // buses\r\ninstanceB.toPlural(); // ellipses (no change)\r\ninstanceC.toPlural(); // money (no change)\r\n\r\n```\r\n\r\n## How does it work\r\n\r\n* **Adjective inflection**\r\n\t1. Checks against a dictionary of known irregularities (e.g. little/less/least)\r\n\t2. Applies inflection based on:\r\n\t\t* Number of syllables\r\n\t\t* word ending\r\n\r\n* **Noun inflection**\r\n\t1. Dictionary lookup (known irregularities e.g. octopus/octopi \u0026 uncountable words)\r\n\t2. Identifies whether the word is plural or singular based on:\r\n\t\t* Dictionary\r\n\t\t* Machine learned regular expressions \r\n\t3. Applies transformation based on ending and word pattern (vowels, consonants and word endings)\r\n\r\n* **Verb conjugation**\r\n\t1. Dictionary lookup (known irregularities + 4000 common verbs)\r\n\t2. If the passed verb is identified as infinitive, it then applies regular expression transformations that are based on word endings, vowels and consonant phonetics.\r\n\t3. Tries to trim character from the beginning of the verb, thus solving prefixes (e.g. undergoes, overthrown)\r\n\t4. Tries to stem the word and get the infinitive form, then apply regular expression transformations.\r\n\t5. Applies regular expressions.\r\n\r\n\r\n## How accurate is it?\r\n\r\nFirst of all, unless you have a dictionary of all the words and verbs that exist in English, you can't really write a regular expression or an algorithm and expect to have a 100% success rate. English has been adopting words from a lot of different languages (French, Greek and Latin for example), and each one of these languages has its own rules of pluralization and singularization, let alone verb conjugation.\r\n\r\nEven with dictionaries you'll have the problem of complex and made up words like `maskedlocation`, and you might have to add dictionaries for specialties (like medicine which does actually have its own dictionary). \r\n\r\nHowever, I think what you'll find in this library is what can be achieved with the least amount of compromise.\r\n\r\nI've used a set of rules (for detection/transformation) in combination with an exceptions list.\r\n\r\nHowever, testing the library was more challenging than anticipated. If you have any case inaccuracy or false positives **please** submit an issue.\r\n\r\nAnd of course, You can clone this repository, install `mocha` and test it for yourself, and you'll see how it passes the **9900** tests successfully.\r\n\r\n\r\n## License\r\n\r\nLicense: The MIT License (MIT) - Copyright (c) 2017 Alex Corvi\r\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FFinNLP%2Fen-inflectors","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FFinNLP%2Fen-inflectors","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FFinNLP%2Fen-inflectors/lists"}