PHP code example of karma617 / phpanalysis

1. Go to this page and download the library: Download karma617/phpanalysis 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/ */

    

karma617 / phpanalysis example snippets


    \Phpanalysis\PhpAnalysis::$loadInit = false;
    $pa = new \Phpanalysis\PhpAnalysis('utf-8', 'utf-8', true);
    //载入词典
    $pa->LoadDict();
    //执行分词
    $pa->SetSource('今天不要忘记给智聪带面膜
    昨天喝了咖啡,晚上失眠,现在蓝瘦香菇
    北京天气变得好冷了,秋风萧瑟');
    $pa->differMax = true;
    $pa->unitWord = true;
    $pa->StartAnalysis( true );
    $okresult = $pa->GetFinallyResult('###', false);

    print_r($okresult);