Security News
GitHub Removes Malicious Pull Requests Targeting Open Source Repositories
GitHub removed 27 malicious pull requests attempting to inject harmful code across multiple open source repositories, in another round of low-effort attacks.
en-inflectors
Advanced tools
English Inflectors Library For noun (plural to singular and singular to plural), verb (gerund, present & past) and adjective (comparative, superlative) transformations
For noun (plural to singular and singular to plural), verb (gerund, present & past) and adjective (comparative, superlative) transformations.
Here's a quick demo: RunKit
npm install en-inflectors --save
// javascript
const Inflectors = require("en-inflectors").Inflectors;
// typescript
import { Inflectors } from "en-inflectors";
let instance = new Inflectors("book");
let instance = new Inflectors("big");
instance.comparative(); // bigger
instance.superlative(); // biggest
new Inflectors("rallied").conjugate("VBP"); // rally
new Inflectors("fly").conjugate("VBD"); // flew
new Inflectors("throw").conjugate("VBN"); // thrown
new Inflectors("rally").conjugate("VBS"); // rallies
new Inflectors("die").conjugate("VBP"); // dying
// or you can use the aliases
new Inflectors("rallied").toPresent(); // rally
new Inflectors("fly").toPast(); // flew
new Inflectors("throw").toPastParticiple(); // thrown
new Inflectors("rally").toPresentS(); // rallies
new Inflectors("die").toGerund(); // dying
const instanceA = new Inflectors("bus");
const instanceB = new Inflectors("ellipses");
const instanceC = new Inflectors("money");
instanceA.isCountable(); // true
instanceB.isCountable(); // true
instanceC.isCountable(); // false
instanceA.isNotCountable(); // false
instanceB.isNotCountable(); // false
instanceC.isNotCountable(); // true
instanceA.isSingular(); // true
instanceB.isSingular(); // false
instanceC.isSingular(); // true
instanceA.isPlural(); // false
instanceB.isPlural(); // true
instanceC.isPlural(); // true
// note that uncountable words return true
// on both plural and singular checks
instanceA.toSingular(); // bus (no change)
instanceB.toSingular(); // ellipsis
instanceC.toSingular(); // money (no change)
instanceA.toPlural(); // buses
instanceB.toPlural(); // ellipses (no change)
instanceC.toPlural(); // money (no change)
Adjective inflection
Noun inflection
Verb conjugation
First 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.
Even 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).
However, I think what you'll find in this library is what can be achieved with the least amount of compromise.
I've used a set of rules (for detection/transformation) in combination with an exceptions list.
However, testing the library was more challenging than anticipated. If you have any case inaccuracy or false positives please submit an issue.
And 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.
License: The MIT License (MIT) - Copyright (c) 2017 Alex Corvi
FAQs
English Inflectors Library For noun (plural to singular and singular to plural), verb (gerund, present & past) and adjective (comparative, superlative) transformations
The npm package en-inflectors receives a total of 2,344 weekly downloads. As such, en-inflectors popularity was classified as popular.
We found that en-inflectors demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
GitHub removed 27 malicious pull requests attempting to inject harmful code across multiple open source repositories, in another round of low-effort attacks.
Security News
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.
Security News
Node.js will be enforcing stricter semver-major PR policies a month before major releases to enhance stability and ensure reliable release candidates.