init() public static method

Static method init
public static init ( array $options = [] ) : void
$options array # other options
return void
示例#1
0
 public function extractKeywords($content, $top_k = 5)
 {
     Jieba::init(array('mode' => 'test', 'dict' => 'samll'));
     Finalseg::init();
     JiebaAnalyse::init();
     $tags = JiebaAnalyse::extractTags($content, $top_k);
     $this->quanzhong = $tags;
     return $tags;
 }
示例#2
0
 public function testJiebaAnalyseInit()
 {
     Jieba::init();
     JiebaAnalyse::init();
     $this->assertGreaterThan(0, JiebaAnalyse::$max_idf);
 }
示例#3
0
#!/usr/bin/php
<?php 
/**
 * demo_extract_tags.php
 *
 * PHP version 5
 *
 * @category PHP
 * @package  /src/cmd/
 * @author   Fukuball Lin <*****@*****.**>
 * @license  MIT Licence
 * @version  GIT: <fukuball/jieba-php>
 * @link     https://github.com/fukuball/jieba-php
 */
ini_set('memory_limit', '600M');
require_once dirname(dirname(__FILE__)) . "/vendor/multi-array/MultiArray.php";
require_once dirname(dirname(__FILE__)) . "/vendor/multi-array/Factory/MultiArrayFactory.php";
require_once dirname(dirname(__FILE__)) . "/class/Jieba.php";
require_once dirname(dirname(__FILE__)) . "/class/Finalseg.php";
require_once dirname(dirname(__FILE__)) . "/class/JiebaAnalyse.php";
use Fukuball\Jieba\Jieba;
use Fukuball\Jieba\Finalseg;
use Fukuball\Jieba\JiebaAnalyse;
Jieba::init(array('mode' => 'test', 'dict' => 'samll'));
Finalseg::init();
JiebaAnalyse::init();
$top_k = 10;
$content = file_get_contents(dirname(dirname(__FILE__)) . "/dict/lyric.txt", "r");
$tags = JiebaAnalyse::extractTags($content, $top_k);
var_dump($tags);