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 (5 days ago) RSS 2.0 feedStarStarStar 54%Total: 249 This week: 2All time: 7,938 This week: 21Up
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  
Name: Sergey Vanyushin is available for providing paid consulting. Contact Sergey Vanyushin .
Classes: 15 packages by
Country: Russian Federation Russian Federation
Age: 28
All time rank: 57216 in Russian Federation Russian Federation
Week rank: 23 Up4 in Russian Federation Russian Federation Up
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

  Files folder image Files (71)  /  .github  
File Role Description
Files folder imageworkflows (1 file)

  Files folder image Files (71)  /  .github  /  workflows  
File Role Description
  Plain text file tests.yaml Data Auxiliary data

  Files folder image Files (71)  /  bin  
File Role Description
  Plain text file morphos Class Class source

  Files folder image Files (71)  /  src  
File Role Description
Files folder imageEnglish (5 files)
Files folder imageRussian (16 files)
Files folder imageService (2 files)
  Plain text file BaseInflection.php Class Class source
  Plain text file BasePluralization.php Class Class source
  Plain text file Cases.php Class Class source
  Plain text file CasesHelper.php Class Class source
  Plain text file CurrenciesHelper.php Class Class source
  Plain text file Currency.php Class Class source
  Plain text file Gender.php Class Class source
  Plain text file MoneySpeller.php Class Class source
  Plain text file NamesInflection.php Class Class source
  Plain text file NumeralGenerator.php Class Class source
  Plain text file S.php Class Class source
  Plain text file TimeSpeller.php Class Class source

  Files folder image Files (71)  /  src  /  English  
File Role Description
  Plain text file CardinalNumeralGenerator.php Class Class source
  Plain text file functions.php Aux. Auxiliary script
  Plain text file NounPluralization.php Class Class source
  Plain text file OrdinalNumeralGenerator.php Class Class source
  Plain text file TimeSpeller.php Class Class source

  Files folder image Files (71)  /  src  /  Russian  
File Role Description
  Plain text file AdjectiveDeclension.php Class Class source
  Plain text file AdjectivePluralization.php Class Class source
  Plain text file CardinalNumeralGenerator.php Class Class source
  Plain text file Cases.php Class Class source
  Plain text file FirstNamesInflection.php Class Class source
  Plain text file functions.php Example Example script
  Plain text file GeographicalNamesInflection.php Class Class source
  Plain text file LastNamesInflection.php Class Class source
  Plain text file MiddleNamesInflection.php Class Class source
  Plain text file MoneySpeller.php Class Class source
  Plain text file NounDeclension.php Class Class source
  Plain text file NounPluralization.php Class Class source
  Plain text file OrdinalNumeralGenerator.php Class Class source
  Plain text file RussianCasesHelper.php Class Class source
  Plain text file RussianLanguage.php Class Class source
  Plain text file TimeSpeller.php Class Class source

  Files folder image Files (71)  /  src  /  Service  
File Role Description
  Plain text file English.php Class Class source
  Plain text file Russian.php Class Class source

  Files folder image Files (71)  /  tests  
File Role Description
Files folder imageEnglish (5 files)
Files folder imageRussian (12 files)
  Plain text file CasesHelperTest.php Class Class source
  Plain text file CurrenciesHelperTest.php Class Class source
  Plain text file Dockerfile Data Auxiliary data
  Plain text file Makefile Data Auxiliary data

  Files folder image Files (71)  /  tests  /  English  
File Role Description
  Plain text file CardinalNumeralTest.php Class Class source
  Plain text file FunctionsTest.php Class Class source
  Plain text file NounPluralizationTest.php Class Class source
  Plain text file OrdinalNumeralTest.php Class Class source
  Plain text file TimeSpellerTest.php Class Class source

  Files folder image Files (71)  /  tests  /  Russian  
File Role Description
  Plain text file AdjectiveDeclensionTest.php Class Class source
  Plain text file AdjectivePluralizationTest.php Class Class source
  Plain text file CardinalNumeralTest.php Class Class source
  Plain text file FirstNamesInflecionTest.php Class Class source
  Plain text file FunctionsTest.php Class Class source
  Plain text file GeographicalNamesInflectionTest.php Class Class source
  Plain text file LastNamesInflectionTest.php Class Class source
  Plain text file MiddleNamesInflectionTest.php Class Class source
  Plain text file MoneySpellerTest.php Class Class source
  Plain text file NounDeclensionTest.php Class Class source
  Plain text file NounPluralizationTest.php Class Class source
  Plain text file RussianLanguageTest.php Class Class source

  Files folder image Files (71)  /  web  
File Role Description
  Plain text file api.php Class Class source
  Plain text file index.php Example Application script

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:2
All time:7,938
This week:21Up
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