PHP Classes

Morphos: Get the different forms of language words

Recommend this page to a friend!
  Info   Documentation   View files Files   Install with Composer Install with Composer   Download Download   Reputation   Support forum   Blog    
Last Updated Ratings Unique User Downloads Download Rankings
2024-09-28 (2 days ago) RSS 2.0 feedStarStarStar 54%Total: 249 This week: 1All time: 7,938 This week: 37Up
Version License PHP version Categories
morphos 1.114Free for non-comm...5.4Algorithms, PHP 5, Text processing
Description 

Author

This class can get the different forms of language words.

It provides several classes that can take words in a given language and determine declension of the word, i.e. the inflection of the word to indicate plurality (singular and plural), gender (male or female), and case (nominative, genitive, dative, accusative, ablative, and prepositional).

Currently it provides specialized classes for Russian declension and English plurality.

Innovation Award
PHP Programming Innovation award nominee
December 2014
Number 2


Prize: One downloadable copy of Komodo IDE
Many words can have multiple forms by changing inflection aspects like the gender, number or the case of those words.

This class implements a solution that can obtain variations of words changing its inflection aspects. It can also detect if a word is a variation of another word.

These capabilities are implemented in a way that can support multiple languages by providing specialization classes for each language.

Manuel Lemos
Picture of Sergey Vanyushin
  Performance   Level  
Innovation award
Innovation award
Nominee: 15x

Winner: 2x

 

Documentation

Morphos

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.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

Contributing

See CONTRIBUTING.md for this.


  Files folder image Files (71)  
File Role Description
Files folder image.github (1 directory)
Files folder imagebin (1 file)
Files folder imagesrc (12 files, 3 directories)
Files folder imagetests (4 files, 2 directories)
Files folder imageweb (2 files)
Plain text file .rr.yaml Data Auxiliary data
Plain text file composer.json Data Auxiliary data
Plain text file CONTRIBUTING.md Data Auxiliary data
Plain text file Dockerfile Data Auxiliary data
Plain text file LICENSE.md Lic. License text
Plain text file phpstan.neon Data Auxiliary data
Plain text file phpunit.xml.dist Data Auxiliary data
Plain text file README-en.md Doc. Documentation
Plain text file README-ru.md Doc. Documentation
Plain text file README.md Doc. Documentation
Plain text file _config.yml Data Auxiliary data

The PHP Classes site has supported package installation using the Composer tool since 2013, as you may verify by reading this instructions page.
Install with Composer Install with Composer
 Version Control Unique User Downloads Download Rankings  
 100%
Total:249
This week:1
All time:7,938
This week:37Up
User Ratings User Comments (12)
 All time
Utility:75%StarStarStarStar
Consistency:50%StarStarStar
Documentation:58%StarStarStar
Examples:66%StarStarStarStar
Tests:-
Videos:-
Overall:54%StarStarStar
Rank:2001
 
Поддержим своих!)
2 years ago (pataskun)
80%StarStarStarStarStar
Поддержим своих!)
2 years ago (pataskun)
80%StarStarStarStarStar
Поддержим своих!)
2 years ago (pataskun)
80%StarStarStarStarStar
Поддержим своих!)
2 years ago (pataskun)
80%StarStarStarStarStar
Поддержим своих!)
2 years ago (pataskun)
80%StarStarStarStarStar
Поддержим своих!)
2 years ago (pataskun)
80%StarStarStarStarStar
Поддержим своих!)
2 years ago (pataskun)
80%StarStarStarStarStar
Поддержим своих!)
2 years ago (pataskun)
80%StarStarStarStarStar
Поддержим своих!)
2 years ago (pataskun)
80%StarStarStarStarStar
Поддержим своих!)
2 years ago (pataskun)
80%StarStarStarStarStar
Поддержим своих!)
2 years ago (pataskun)
80%StarStarStarStarStar
Поддержим своих!)
2 years ago (pataskun)
80%StarStarStarStarStar