저자: Fukuball Lin (fukuball@gmail.com)
예제 #1
0
 public function getPartofspeech($string)
 {
     Jieba::init();
     Finalseg::init();
     Posseg::init();
     $seg_list = Posseg::cut($string);
     $this->cixing = $seg_list;
     return $seg_list;
 }
예제 #2
0
 public function testPossegCut()
 {
     $case_array = array(array("word" => "这", "tag" => "r"), array("word" => "是", "tag" => "v"), array("word" => "一个", "tag" => "m"), array("word" => "伸手不见五指", "tag" => "i"), array("word" => "的", "tag" => "uj"), array("word" => "黑夜", "tag" => "n"), array("word" => "。", "tag" => "w"), array("word" => "我", "tag" => "r"), array("word" => "叫", "tag" => "v"), array("word" => "孙悟空", "tag" => "nr"), array("word" => ",", "tag" => "w"), array("word" => "我", "tag" => "r"), array("word" => "爱", "tag" => "v"), array("word" => "北京", "tag" => "ns"), array("word" => ",", "tag" => "w"), array("word" => "我", "tag" => "r"), array("word" => "爱", "tag" => "v"), array("word" => "Python", "tag" => "eng"), array("word" => "和", "tag" => "c"), array("word" => "C++", "tag" => "eng"), array("word" => "。", "tag" => "w"));
     $seg_list = Posseg::cut("这是一个伸手不见五指的黑夜。我叫孙悟空,我爱北京,我爱Python和C++。");
     $this->assertEquals($case_array, $seg_list);
 }
예제 #3
0
#!/usr/bin/php
<?php 
/**
 * demo_posseg.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/Posseg.php";
use Fukuball\Jieba\Jieba;
use Fukuball\Jieba\Finalseg;
use Fukuball\Jieba\Posseg;
Jieba::init();
Finalseg::init();
Posseg::init();
$seg_list = Posseg::cut("这是一个伸手不见五指的黑夜。我叫孙悟空,我爱北京,我爱Python和C++。");
var_dump($seg_list);
$seg_list = Posseg::posTagReadable($seg_list);
var_dump($seg_list);
예제 #4
0
<?php

ini_set('memory_limit', '1024M');
require_once dirname(dirname(__FILE__)) . "/src/vendor/multi-array/MultiArray.php";
require_once dirname(dirname(__FILE__)) . "/src/vendor/multi-array/Factory/MultiArrayFactory.php";
require_once dirname(dirname(__FILE__)) . "/src/class/Jieba.php";
require_once dirname(dirname(__FILE__)) . "/src/class/Finalseg.php";
require_once dirname(dirname(__FILE__)) . "/src/class/JiebaAnalyse.php";
require_once dirname(dirname(__FILE__)) . "/src/class/Posseg.php";
use Fukuball\Jieba\Jieba;
use Fukuball\Jieba\Finalseg;
use Fukuball\Jieba\JiebaAnalyse;
use Fukuball\Jieba\Posseg;
Jieba::init();
Finalseg::init();
JiebaAnalyse::init();
Posseg::init();
function loader($class)
{
    $file = $class . '.php';
    if (file_exists($file)) {
        require_once $file;
    }
}
spl_autoload_register('loader');