Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

en-inflectors

Package Overview
Dependencies
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

en-inflectors

For noun (plural to singular and singular to plural) and verb (gerund, present & past) transformations.

  • 1.0.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
2.9K
decreased by-16.58%
Maintainers
1
Weekly downloads
 
Created
Source

English Inflectors Library

For noun (plural to singular and singular to plural) and verb (gerund, present & past) transformations.

Installation and Usage

npm install en-inflectors --save

Plural and singular detection

const inflectors = require("en-inflectors");
inflectors.isSingular("nuclei");
// > false
inflectors.isPlural("plateaux");
// > true
inflectors.isCountable("steam");
// > false

How it works:

  • Search for the given word in the uncountable words.
  • Search for the given word against a dictionary of known and common exceptions.
  • Detect the given word against a set of RegExp rules.

Note: All uncountable words like sheep, deer, tuna and steam will return true for both plural and singular detection.

Plural to singular transformation

const inflectors = require("en-inflectors");
inflectors.pluralize("mouse");
// > mice
inflectors.pluralize("goose");
// > geese
inflectors.pluralize("river");
// > rivers

Singular to plural transformation

const inflectors = require("en-inflectors");
inflectors.pluralize("location");
// > locations
inflectors.pluralize("hoax");
// > hoaxes
inflectors.pluralize("wharf");
// > wharves

How it works:

  • Search for the given word in the uncountable words.
  • Search for the given word against a dictionary of known and common exceptions.
  • Apply singularization/pluralization rules.

Verb conjugation

const inflectors = require("en-inflectors");
inflectors.conjugate("playing","VBP");
// > play
inflectors.conjugate("playing","VBZ");
// plays
inflectors.conjugate("transcribes","VBP");
// transcribed
inflectors.conjugate("goes","VBN");
// gone
inflectors.conjugate("went","VBG");
// going

where:

  • VBP: is the present/infinitive form.
  • VBZ: is the present with the third person "s".
  • VBP: is the past form.
  • VBD: is the past participle form.
  • VBG: is the gerund form.

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 of goes). 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.

Additional functionalities

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

License: The MIT License (MIT) - Copyright (c) 2017 Alex Corvi

FAQs

Package last updated on 04 Jan 2017

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc