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β
- Past Tense
- Past Participle
- Base Form
- Form Checks
verbalizer.toPast('run'); // "ran"
verbalizer.toPast('walk'); // "walked"
verbalizer.toParticiple('go'); // "gone"
verbalizer.toParticiple('walk'); // "walked"
verbalizer.toBase('went'); // "go"
verbalizer.toBase('walked'); // "walk"
verbalizer.isPast('ran'); // true
verbalizer.isPastParticiple('gone'); // true
verbalizer.isBase('run'); // true
π§ 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β
- Verbalizer class β lowβlevel API for custom instances.
- Pluralizer β Utility for noun pluralization.
Summaryβ
Use verbalizer
for common useβcases.
Create new Verbalizer()
for isolated/custom rules.
[file content end]