Security News
The Unpaid Backbone of Open Source: Solo Maintainers Face Increasing Security Demands
Solo open source maintainers face burnout and security challenges, with 60% unpaid and 60% considering quitting.
en-inflectors
Advanced tools
For noun (plural to singular and singular to plural) and verb (gerund, present & past) transformations.
For noun (plural to singular and singular to plural) and verb (gerund, present & past) transformations.
First of all, unless you have a dictionary of all the words and verbs there are in the 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 form a lot of different languages (French, Greek and Latin for example) and each one these languages has it's own rules of pluralization and singularization.
Even with dictionaries you'll have the problem of complex and made up words like geo-location
, and you might have to add dictionaries for specialties (like medicine which does actually have it's 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 what I was anticipating. 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 9508 tests successfully.
npm install en-inflectors --save
const inflectors = require("en-inflectors");
inflectors.isSingular("nuclei");
// > false
inflectors.isPlural("plateaux");
// > true
inflectors.isCountable("steam");
// > false
How it works:
Note: All uncountable words like sheep, deer, tuna and steam will return
false
for both plural and singular detection.
const inflectors = require("en-inflectors");
inflectors.singularize("mice");
// > mouse
inflectors.singularize("geese");
// > goose
inflectors.singularize("rivers");
// > river
const inflectors = require("en-inflectors");
inflectors.pluralize("location");
// > locations
inflectors.pluralize("hoax");
// > hoaxes
inflectors.pluralize("wharf");
// > wharves
How it works:
Verb conjugation can take a verb (in any tense) and convert it into the required tense.
const inflectors = require("en-inflectors");
inflectors.conjugate("playing","VBP");
// > play
inflectors.conjugate("playing","VBZ");
// plays
inflectors.conjugate("transcribes","VBD");
// transcribed
inflectors.conjugate("goes","VBN");
// gone
inflectors.conjugate("went","VBG");
// going
where:
Or you can use the aliases:
const inflectors = require("en-inflectors");
inflectors.present("playing");
// > play
inflectors.presentS("playing");
// plays
inflectors.past("transcribes");
// transcribed
inflectors.pastParticiple("goes");
// gone
inflectors.gerund("went");
// going
Note For better, more accurate results, pass the verb in it's infinitive form (
go
instead ofgoes
). although this library has been written to be agnostic about the form of the inputs, but the test results has proven that it's quite hard to achieve that with full accuracy.
const inflectors = require("en-inflectors");
inflectors.uncountableWords;
// list all the uncountable words as an array
inflectors.verbsTable;
// verb table with all the tenses can be used for writing your own functionalities
inflectors.infinitives;
// an array of the most common English verbs
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,752 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
Solo open source maintainers face burnout and security challenges, with 60% unpaid and 60% considering quitting.
Security News
License exceptions modify the terms of open source licenses, impacting how software can be used, modified, and distributed. Developers should be aware of the legal implications of these exceptions.
Security News
A developer is accusing Tencent of violating the GPL by modifying a Python utility and changing its license to BSD, highlighting the importance of copyleft compliance.