sheronov_v2 / php-mystem
A PHP wrapper for Yandex MyStem program
dev-master
2024-04-25 16:45 UTC
Requires
- php: ^7.2|>=8.0
- ext-curl: *
- ext-json: *
- ext-mbstring: *
- ext-zip: *
This package is auto-updated.
Last update: 2025-04-25 19:19:48 UTC
README
A PHP wrapper for Yandex MyStem program https://yandex.ru/dev/mystem/
Installation
- Add the github repo:
composer config repositories.php-mystem vcs https://github.com/sheronov/php-mystem
- Require the package
composer require sheronov/php-mystem
- On first launch, the package will download mystem binaries from yandex, but you can do it manually
./vendor/bin/mystem-downloader.php
By default, it downloads all mystem binaries for Windows, Linux and macOS.
If you want download only for one system, please provide an argument:
- -l - bin for Linux
- -w - exe for Windows
- -m - bin for Macos
Usage
lemmatization (Приведение словоформы к лемме — её нормальной (словарной) форме.)
use Sheronov\PhpMyStem\MyStem; MyStem::lemma('Бегущий'); //бежать MyStem::lemmatization('Бегущий по лезвию'); /* array ( 0 => array ( 'text' => 'Бегущий', 'lemma' => 'бежать', 'weight' => 1, 'gram' => 'V,нп=(непрош,вин,ед,прич,полн,муж,несов,действ,неод|непрош,им,ед,прич,полн,муж,несов,действ)', 'part_letter' => 'V', 'part_more' => 'verb', 'wrong' => false, ), 1 => array ( 'text' => 'по', 'lemma' => 'по', 'weight' => 1, 'gram' => 'PR=', 'part_letter' => 'PR', 'part_more' => 'preposition', 'wrong' => false, ), 2 => array ( 'text' => 'лезвию', 'lemma' => 'лезвие', 'weight' => 1, 'gram' => 'S,сред,неод=дат,ед', 'part_letter' => 'S', 'part_more' => 'noun', 'wrong' => false, ), ) */
Raw binary run with custom arguments from Yandex docs
\Sheronov\PhpMyStem\MyStem::run($someText, ['--weight', '-gi']); // unprepared decoded array from json