1 Star 0 Fork 0

等风来,随风去 / think-pullword

加入 Gitee
与超过 800 万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README.md

think-pullword

ThinkPHP 分词/抽词 扩展包 5.1 6.0

使用梁厂的产品 http://www.pullword.com/

Latest Stable Version Latest Unstable Version License Total Downloads

安装

composer require xiaodi/think-pullword

使用

常规实例化

use PullWord\PullWord;
class Index
{
    public function index()
    {
        $source = '352净水器K10家用直饮大通量1000G 厨下RO反渗透纯水机';
        $pullWord = new PullWord($source);
        $result = $pullWord->pull()->toJson()->get();
        // $result = $pullWord->service('pull', $source)->get();
        // 结果 => string(169) "[{"t":"352净水器"},{"t":"净水器"},{"t":"家用"},{"t":"大通量"},{"t":"1000g"},{"t":"反渗透"},{"t":"反渗透纯水机"},{"t":"渗透"},{"t":"纯水机"}]


        // 商品分类
        // $source = '352净水器K10家用直饮大通量1000G 厨下RO反渗透纯水机';
        // $pullWord = new PullWord($source);
        // $result = $pullWord->classify()->get();
        // // $result = $pullWord->service('classify', $source)->get();
        // 结果 => string(27) "{"class":"电器","idx":11}"
    }
}

依赖注入

use PullWord\PullWord;
class Index
{
    public function index(PullWord $pullWord)
    {
        $source = '352净水器K10家用直饮大通量1000G 厨下RO反渗透纯水机';
        $result = $pullWord->pull($source)->get();
        var_dump($result);

        // $source = '352净水器K10家用直饮大通量1000G 厨下RO反渗透纯水机';
        // $result = $pullWord->classify($source)->get();
        // var_dump($result);
    }
}

门面

use PullWord\Facade\PullWord;

class Index
{
    public function index()
    {
        $source = '352净水器K10家用直饮大通量1000G 厨下RO反渗透纯水机';
        $result = PullWord::pull($source')->get();
        var_dump($result);
    }
}

助手函数

class Index
{
    public function index()
    {
        $source = '352净水器K10家用直饮大通量1000G 厨下RO反渗透纯水机';
        $result = app('pullword')->pull($source)->get();
        var_dump($result);
    }
}

其它链式方法

json返回

$source = '352净水器K10家用直饮大通量1000G 厨下RO反渗透纯水机';
PullWord::pull($source)->toJson()->get();
// 结果 [{"t":"352净水器","p":"1"},{"t":"净水器","p":"1"},{"t":"家用","p":"1"},{"t":"大通量","p":"0.923331"},{"t":"1000g","p":"0.959741"},{"t":"反渗透","p":"0.944082"},{"t":"反渗透纯水机","p":"0.964588"},{"t":"渗透","p":"0.838643"},{"t":"纯水机","p":"0.928798"}]

调试模式

结果含有出词概率

$source = '352净水器K10家用直饮大通量1000G 厨下RO反渗透纯水机';
PullWord::pull($source)->debug()->get();
// 结果 [{"t":"352净水器","p":"1"},{"t":"净水器","p":"1"},{"t":"家用","p":"1"},{"t":"大通量","p":"0.923331"},{"t":"1000g","p":"0.959741"},{"t":"反渗透","p":"0.944082"},{"t":"反渗透纯水机","p":"0.964588"},{"t":"渗透","p":"0.838643"},{"t":"纯水机","p":"0.928798"}]

设置阈值

出词概率阈值(0-1之间的小数),1表示只有100%有把握的词才出

$source = '352净水器K10家用直饮大通量1000G 厨下RO反渗透纯水机';
PullWord::pull($source)->threshold(0.4)->toJson()->get();
// 结果 [{"t":"352"},{"t":"352净水器"},{"t":"净水"},{"t":"净水器"},{"t":"家用"},{"t":"大通量"},{"t":"通量"},{"t":"1000g"},{"t":"反渗透"},{"t":"反渗透纯水机"},{"t":"渗透"},{"t":"纯水"},{"t":"纯水机"},{"t":"水机"}]

仓库评论 ( 0 )

你可以在登录后,发表评论

简介

暂无描述 展开 收起
PHP
MIT
取消

发行版

暂无发行版

贡献者

全部

近期动态

加载更多
不能加载更多了
1
https://gitee.com/BieAi_admin/think-pullword.git
git@gitee.com:BieAi_admin/think-pullword.git
BieAi_admin
think-pullword
think-pullword
master

搜索帮助