Research
Security News
Malicious npm Package Targets Solana Developers and Hijacks Funds
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
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,848 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.
Research
Security News
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
Security News
Research
Socket researchers have discovered malicious npm packages targeting crypto developers, stealing credentials and wallet data using spyware delivered through typosquats of popular cryptographic libraries.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.