sheronov_v2/php-mystem

A PHP wrapper for Yandex MyStem program

Installs: 0

Dependents: 0

Suggesters: 0

Security: 0

Stars: 0

Watchers: 0

Forks: 2

Type:project

dev-master 2024-04-25 16:45 UTC

This package is auto-updated.

Last update: 2024-04-25 16:49:37 UTC


README

A PHP wrapper for Yandex MyStem program https://yandex.ru/dev/mystem/

Installation

  1. Add the github repo:
composer config repositories.php-mystem vcs https://github.com/sheronov/php-mystem
  1. Require the package
composer require sheronov/php-mystem
  1. 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