Skip to content

A verb conjugation, adjective inflection and noun pluralisation library

License

Notifications You must be signed in to change notification settings

MHewison/inflection

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Inflection

A library to inflect adjectives, conjugate verbs and pluralize/singularize nouns.

Usage

composer require hewison/inflection

use Hewison\Inflection\Word;

$word = Word::create("back");

$word->get();

Output

    [adjective] => Array
        (
            [standard] => back
            [comparative] => more back
            [superlative] => most back
        )
    [adverb] => back
    [noun] => Array
        (
            [singular] => back
            [plural] => backs
        )

    [verb] => Array
        (
            [entry] => back
            [tense] => Present
            [past] => backed
            [past_participle] => backed
            [present] => back
            [present_third] => backs
            [gerund] => backing
        )

It is also possible to return just the words you are interested in.

use Hewison\Inflection\Word;

$word = Word::create("back");

$word->getVerb(); // returns verb in all tenses.
$word->getAdverb(); // returns entered word if is adverb
$word->getNoun(); // returns singular and plural forms of entered, if it is a noun. Proper nouns and gibberish will still be processed here.
$word->getAdjective(); // returns adjective with superlative and comparative forms.

Additionally if you know what type of word you are working with, you can use the sub libraries on their own.

NOTE: the methods below to not undergo the same library checks as using the Word class.

Nouns

Hewison\Inflection\Noun\Noun::toSingular("tables"); // table
Hewison\Inflection\Noun\Noun::toPlural("bear")' // bears
Hewison\Inflection\Noun\Noun::isSingular("tables"); // false
Hewison\Inflection\Noun\Noun::isPlural("bears"); // true
Hewison\Inflection\Noun\Noun::isCountable("economics"); // false

Adjectives

Hewison\Inflection\Adjective\Adjective::resolveSuperlativeForm("boring"); // most boring
Hewison\Inflection\Adjective\Adjective::resolveComparativeForm("boring"); // more boring
Hewison\Inflection\Adjective\Adjective::resolveAllForms("boring"); // array

Verbs

Hewison\Inflection\Verb\Verb::create("go")->conjugate(); // array of all forms
Hewison\Inflection\Verb\Verb::create("go")->toGerund(); // Gerund form
Hewison\Inflection\Verb\Verb::create("go")->toPast(); // Past form
Hewison\Inflection\Verb\Verb::create("go")->toPastParticiple(); // Past Participle form
Hewison\Inflection\Verb\Verb::create("go")->toPresentThird(); // Present Third form
Hewison\Inflection\Verb\Verb::create("go")->toPresent(); // Present form

$verb = new Verb("walk");

$verb->toGerund(); // walking

About

A verb conjugation, adjective inflection and noun pluralisation library

Resources

License

Code of conduct

Stars

Watchers

Forks

Packages

No packages published

Languages