hewison / inflection
Installs: 3 044
Dependents: 0
Suggesters: 0
Security: 0
Stars: 1
Watchers: 1
Forks: 0
Open Issues: 0
Requires
- php: >=7.2
Requires (Dev)
- phpunit/phpunit: ~8.0
README
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