PHP code example of xiaodi / think-pullword

1. Go to this page and download the library: Download xiaodi/think-pullword library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

xiaodi / think-pullword example snippets


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);
    }
}


$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"}]

$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":"水机"}]