定制 seoservice2020/laravel-phpmorphy 二次开发

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

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

seoservice2020/laravel-phpmorphy

Composer 安装命令:

composer require seoservice2020/laravel-phpmorphy

包简介

laravel-phpmorphy - Laravel wrapper for phpMorphy.

README 文档

README

Latest Stable Version Total Downloads tests codecov License

laravel-phpmorphy is a Laravel wrapper for phpMorphy library with PHP7 support.

phpMorphy is a morphological analyzer library for Russian, Ukrainian, English and German languages.

Installation

Run the following command from your terminal:

composer require seoservice2020/laravel-phpmorphy

Or add this to require section in your composer.json file:

{
    "require": {
        "seoservice2020/laravel-phpmorphy": "~2.2"
    }
}

then run composer update

Configuration

The defaults are set in config/morphy.php. Copy this file to your own config directory to modify the values. You can publish the config using this command:

php artisan vendor:publish --provider="SEOService2020\Morphy\MorphyServiceProvider"

This is the contents of the published file:

return [
    'common_options' => [
        'storage' => phpMorphy::STORAGE_FILE,
        'predict_by_suffix' => true,
        'predict_by_db' => true,
        'graminfo_as_text' => true,
    ],

    'morphies' => [
        [
            // phpMorphy instance name
            // specific morphy can be accessed through Morphy::morphy($name) method
            'name' => SEOService2020\Morphy\Morphy::russianLang,

            // phpMorphy language
            // see Morphy class for available values
            'language' => SEOService2020\Morphy\Morphy::russianLang,

            // phpMorphy options
            // if not specified or null specified, default options will be used
            // to use common options from this config, specify []
            'options' => [],
            
            // dicts directory path
            // if not specified or null specified, default dicts path will be used
            'dicts_path' => null,

            // values are 'storage', 'filesystem'
            // 'storage': dicts will be taken from laravel storage (storage/app folder)
            // 'filesystem': dicts will be taken by specified path as-is
            // must be specified when dicts_path is not null
            'dicts_storage' => 'storage',
        ],
    ],
];

Usage

Wrapper automatically prepares input word for phpMorphy: it applies trim to word and converts it to uppercase or lowercase, depending on the dictionary options.

Using the wrapper directly:

use SEOService2020\Morphy\Morphy;
$morphy = new Morphy(Morphy::englishLang);
echo $morphy->getPseudoRoot('fighty');

Or via Laravel Facade:

use SEOService2020\Morphy\Facade\Morphy as Morphies;
// first parameter is the name of morphy in config
Morphies::getPseudoRoot('ru', 'Бойцовый');

// get morphy and call methods in regular manner
Morphies::morphy('ru')->lemmatize('   бойцовый');  // word will be trimmed

// get all morphies, returns array like ['name' => Morphy]
Morphies::morphies();

// get all morphies with specific locale, returns array like ['name' => Morphy]
Morphies::morphies(Morphy::russianLang);

// you can call phpMorphy static methods as well
Morphies::getDefaultDictsDir();

Note:

You can access morphy properties only directly from morphy object, not facade.

Add facade support

This package allows Laravel to support facade out of the box, but you may explicitly add facade support to config/app.php:

Section providers

SEOService2020\Morphy\MorphyServiceProvider::class,

Section aliases

'Morphy' => SEOService2020\Morphy\Facade\Morphy::class,

Change log

Please see CHANGELOG for more information what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security

If you discover any security related issues, please email sergotail@mail.ru instead of using the issue tracker.

License

The MIT License (MIT). Please see License File for more information.

seoservice2020/laravel-phpmorphy 适用场景与选型建议

seoservice2020/laravel-phpmorphy 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 176 次下载、GitHub Stars 达 2, 最近一次更新时间为 2020 年 12 月 19 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「laravel」 「nlp」 「phpmorphy」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 seoservice2020/laravel-phpmorphy 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 seoservice2020/laravel-phpmorphy 我们能提供哪些服务?
定制开发 / 二次开发

基于 seoservice2020/laravel-phpmorphy 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 176
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 2
  • 点击次数: 11
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 2
  • Watchers: 2
  • Forks: 2
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2020-12-19