hewison/inflection
Composer 安装命令:
composer require hewison/inflection
包简介
README 文档
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
hewison/inflection 适用场景与选型建议
hewison/inflection 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 3.05k 次下载、GitHub Stars 达 1, 最近一次更新时间为 2019 年 11 月 08 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 hewison/inflection 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 hewison/inflection 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 3.05k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 4
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2019-11-08