定制 wapmorgan/morphos 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

wapmorgan/morphos

最新稳定版本:3.2.30

Composer 安装命令:

composer require wapmorgan/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.

Latest Stable Version License Total Downloads Daily Downloads Latest Unstable Version

Tests & Quality: Build Status Scrutinizer Code Quality Code Coverage

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

  1. Installation
  2. Quick start
  3. Documentation
  4. Contributing

Installation

As PHP library

  • Download library through composer:
composer require wapmorgan/morphos

or install via adapter:

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.30
    ports:
      - 8093:8080

or standalone container:

docker run --env NUM_WORKERS=4 --rm --publish 8093:8080 -v wapmorgan/morphos:3.2.30

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

Contributing

See CONTRIBUTING.md for this.

统计信息

  • 总下载量: 1.19M
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 835
  • 点击次数: 1
  • 依赖项目数: 11
  • 推荐数: 0

GitHub 信息

  • Stars: 826
  • Watchers: 36
  • Forks: 114
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2014-11-12