Skip to main content

Manage Verb Forms

verbalizer​

The verbalizer is a default shared instance of the Verbalizer class.
It comes preloaded with standard English conjugation rules and irregular verbs.

When to Use
  • Use this instance when you don't need multiple configurations.
  • If you need isolated or custom rules, you can create your own Verbalizer instance.

✨ Features​

  • βœ… Convert verbs between base, past tense, and past participle forms
  • βœ… Built‑in support for irregular verbs (e.g. go β†’ went β†’ gone)
  • βœ… Preserves case sensitivity of input verbs
  • βœ… Modify rules dynamically at runtime:
    • Add conjugation rules for different verb forms
    • Add irregular verbs
Alert

All methods return the trimmed verb if the input has trailing spaces.


πŸ“¦ Import​

import { verbalizer } from 'nhb-toolbox';

πŸš€ Quick Usage​

verbalizer.toPast('run'); // "ran"
verbalizer.toPast('walk'); // "walked"

πŸ”§ Extending Rules​

Since verbalizer is an actual instance of Verbalizer, you can extend or modify it at runtime:

// Add a custom base rule
verbalizer.addBaseRule(/ied$/i, 'y');

// Add a custom past tense rule
verbalizer.addPastRule(/e$/i, 'ed');

// Add a custom past participle rule
verbalizer.addParticipleRule(/e$/i, 'ed');

// Add an irregular verb
verbalizer.addIrregular('swim', 'swam', 'swum');

These modifications affect all consumers of the shared instance.


πŸ— Need your own configuration?​

If you want an isolated instance with its own rules, instantiate the class directly:

import { Verbalizer } from 'nhb-toolbox';

const myVerbalizer = new Verbalizer();
myVerbalizer.addIrregular('dream', 'dreamt', 'dreamt');
console.log(myVerbalizer.toPast('dream')); // dreamt

See the Verbalizer class docs for full details.


See also​


Summary​

Use verbalizer for common use‑cases.
Create new Verbalizer() for isolated/custom rules. [file content end]