Giter Club home page Giter Club logo

phpjieba's Introduction

version 0.0.6

functions

array jieba(string $text, int $action = 0, int $limit = 50)
  • action
    • 0 Extract
    • 1 CutForSearch
    • 2 Tag
    • 3 TagAll 解决 Tag 对于相同 key 的问题

install

git clone https://github.com/jonnywang/phpjieba.git
cd phpjieba/cjieba
make

cd ..
phpize
./configure
make
make install

php.ini

extension=jieba.so
jieba.enable=1
jieba.dict_path=/data/softs/phpjieba/cjieba/dict

*jieba.dict_path指向字典所在对应目录,请根据自己编译目录替换更改

example

$result = jieba('小明硕士毕业于**科学院计算所,后在日本京都大学深造');
echo implode('/', $result) . PHP_EOL;
//计算所/小明/京都大学/深造/硕士/**科学院/毕业/日本

$result = jieba('小明硕士毕业于**科学院计算所,后在日本京都大学深造', 1, 50);
echo implode('/', $result) . PHP_EOL;
//小明/硕士/毕业/于/**/科学/学院/科学院/**科学院/计算/计算所/,/后/在/日本/京都/大学/京都大学/深造

$result = jieba('他心理健康', 1);
echo implode('/', $result) . PHP_EOL;
//他/心理/健康/心理健康

$result = jieba('this is a demo, my name is jony', 1, 10);
echo implode('/', $result) . PHP_EOL;
//demo/jony

$result = jieba('this is a demo, my name is jony');
echo implode('/', $result) . PHP_EOL;
//this/ /is/ /a/ /demo/,/ /my/ /name/ /is/ /jony

$result = jieba('小明硕士毕业于**科学院计算所,后在日本京都大学深造', 2);
print_r($result);

Array
(
    [小明] => x
    [硕士] => n
    [毕业] => n
    [于] => p
    [**科学院] => nt
    [计算所] => n
    [,] => x
    [后] => f
    [在] => p
    [日本] => ns
    [京都大学] => nz
    [深造] => v
)
  • 更新请参考example目录
  • 词性可参考HanLP词性标注集解释

contact

更多疑问请+qq群 233415606

plus

https://github.com/jonnywang/goredisjieba

贡献者

phpjieba's People

Contributors

breakliu avatar ixqbar avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.