tinigin/morphos
Composer 安装命令:
composer require tinigin/morphos
包简介
A morphological solution for Russian and English language written completely in PHP. Provides classes to inflect personal names, geographical names, decline and pluralize nouns, generate cardinal and ordinal numerals, spell out money amounts and time.
关键字:
README 文档
README
A morphological solution for Russian and English language written completely in PHP and delivered as a PHP library or docker image to integrate in non-PHP stack.
Features
- [✓] Inflection of Personal names (Фамилия, Имя, Отчество) (Russian)
- [✓] Inflection of Geographical names (Страны/Города) (Russian)
- [✓] Declension/Pluralization of nouns and adjectives (Russian, English)
- [✓] Generation numerals of numbers (количественные и порядковые) (Russian, English)
- [✓] Spelling out amounts of money (Russian)
- [✓] Spelling out time units and intervals (Russian, English)
Table of contents
- Installation
- Quick start
- Documentation
- Contributing
Installation
As PHP library
- Download library through composer:
composer require wapmorgan/morphos
or install via adapter:
- Adapter for Blade: wapmorgan/morphos-blade
- Adapter for Twig: wapmorgan/morphos-twig
- Adapter for Yii2: wapmorgan/yii2-inflection
As a separate service
The server starts in a container from docker image and listens 8080 port for GET-requests.
Integrate service into your stack (for example, docker compose)
services: morphos: image: wapmorgan/morphos:3.2.29 ports: - 8093:8080
or standalone container:
docker run --env NUM_WORKERS=4 --rm --publish 8093:8080 -v wapmorgan/morphos:3.2.29
Tip: adjust NUM_WORKERS env variable if you will send a lot of load to service. By default, it's 4.
There are API: marks in documentation for functions, that exposed as service endpoints. Just pass them the same arguments as to PHP-functions/methods.
Quick Start
Russian
// Inflect russian names: morphos\Russian\inflectName('Иванов Петр', 'родительный') => 'Иванова Петра' // Inflect geographical names: morphos\Russian\GeographicalNamesInflection::getCase('Москва', 'родительный') => 'Москвы' // Pluralize russian nouns and adjectives: morphos\Russian\pluralize(10, 'новый дом') => '10 новых домов' // Generate russian cardinal numerals: morphos\Russian\CardinalNumeralGenerator::getCase(567, 'именительный') => 'пятьсот шестьдесят семь' // Generate russian ordinal numerals: morphos\Russian\OrdinalNumeralGenerator::getCase(961, 'именительный') => 'девятьсот шестьдесят первый' // Generate russian time difference morphos\Russian\TimeSpeller::spellDifference(time() + 3600, morphos\TimeSpeller::DIRECTION) => 'через 1 час' // other functions described in README-ru.md
English
// Pluralize english nouns: morphos\English\pluralize(10, 'house') => '10 houses' // Generate english cardinal numerals: morphos\English\CardinalNumeralGenerator::generate(567) => 'five hundred sixty-seven' // Generate english ordinal numerals: morphos\English\OrdinalNumeralGenerator::generate(961) => 'nine hundred sixty-first' // Generate english time difference morphos\English\TimeSpeller::spellDifference(time() + 3600, morphos\TimeSpeller::DIRECTION) => 'in 1 hour'
Documentation
- Русская морфология в файле README-ru.md
- English morphology in file README-en.md
Contributing
See CONTRIBUTING.md for this.
tinigin/morphos 适用场景与选型建议
tinigin/morphos 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 2.95k 次下载、GitHub Stars 达 0, 最近一次更新时间为 2024 年 07 月 16 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「time」 「money」 「language」 「russian」 「inflection」 「english」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 tinigin/morphos 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 tinigin/morphos 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 tinigin/morphos 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Texy converts plain text in easy to read Texy syntax into structurally valid (X)HTML. It supports adding of images, links, nested lists, tables and has full support for CSS. Texy supports hyphenation of long words (which reflects language rules), clickable emails and URL (emails are obfuscated again
Easy to use i18n translation PHP class for multi-language websites
Beyonic PHP Library
Tools to convert between .NET and PHP date formats
Package for convenient work with Laravel's localization features
Store your language lines in the database, yaml or other sources
统计信息
- 总下载量: 2.95k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 29
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2024-07-16