2017 © Pedro Peláez
 

library jieba-php

结巴中文分词PHP版本

image

deminy/jieba-php

结巴中文分词PHP版本

  • Tuesday, July 4, 2017
  • by deminy
  • Repository
  • 1 Watchers
  • 2 Stars
  • 259 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 143 Forks
  • 0 Open issues
  • 13 Versions
  • 37 % Grown

The README.md

deminy/jieba-php

Build Status Latest Stable Version Codacy Badge Coding Standards PSR-4 License, (*1)

"结巴中文分词"PHP版本:"结巴中文分词"是Sun Junyi开发的Python版的中文分词组件,后来衍生了多种语言实现,包括C++、Java、.NET、Go等等。这份PHP版本起始于fukuball之前做的PHP实现(v0.25),随后对其整体重写并作了各种更新和改进,包括代码升级、使用PHP 7的新功能重构代码、使用PSR-4管理autoloading、使用依赖注射等设计模式、更新单元测试的实现、以及更多的性能优化和代码更新等等。如果你需要相应的PHP扩展的版本,可考虑jonnywang写的结巴中文分词之PHP扩展。, (*2)

有关算法、词典生成等方面的问题,请参考结巴中文分词相关文档。, (*3)

特点

  • 支持三种分词模式:
    • 精确模式,试图将句子最精确地切开,适合文本分析。
    • 全模式,把句子中所有的可以成词的词语都扫描出来, 速度非常快,但是不能解决歧义。
    • 搜索引擎模式,在精确模式的基础上,对长词再次切分,提高召回率,适合用于搜索引擎分词。
  • 支持繁体分词。
  • 支持自定义词典。

安装使用

使用本库你需要至少给PHP分配1G内存限制或更多,主要是用来存储词典信息。随着进一步的优化(包括缓存方面的优化),内存消耗将会降低。, (*4)

composer require deminy/jieba-php:dev-master
<?php

require_once dirname(__DIR__) . '/vendor/autoload.php';

use Jieba\Jieba;

var_dump((new Jieba())->cut("怜香惜玉也得要看对象啊!"));

字符编码处理

本库默认假设用户使用的字符编码为UTF-8。如果运行环境非UTF-8,你可以参考下面的代码文件解决相关编码问题:, (*5)

./examples/encoding.php, (*6)

用法介绍

分词

请参考下面的代码文件:, (*7)

./examples/default.php, (*8)

添加自定义词典

开发者可以指定自己自定义的词典,以便包含jieba词库裡没有的词。虽然jieba有新词识别能力,但是自行添加新词可以保证更高的正确率。请参考下面的代码文件:, (*9)

./examples/useUserDict.php, (*10)

关键词提取

请参考下面的代码文件:, (*11)

./examples/extractTags.php, (*12)

词性分词

有关词性说明,请参考《词性标记》这篇文档。下面的代码文件可以提供更多的理解:, (*13)

./examples/posseg.php, (*14)

切换成繁体字典

请参考下面的代码文件:, (*15)

./examples/big5.php, (*16)

使用不同的序列化格式(BSON, JSON, MessagePack等)

请参考下面的代码文件:, (*17)

./examples/useDifferentSerializers.php, (*18)

常见问题

  1. 模型的数据是如何生成的?, (*19)

  2. 术语说明, (*20)

The Versions

04/07 2017

dev-master

9999999-dev

结巴中文分词PHP版本

  Sources   Download

MIT

The Requires

 

The Development Requires

by Avatar fukuball

php nlp natural language processing chinese jieba

01/07 2017

0.25.3

0.25.3.0

结巴中文分词PHP版本

  Sources   Download

MIT

The Requires

 

The Development Requires

php nlp natural language processing chinese jieba

23/06 2017

0.25.2

0.25.2.0

结巴中文分词PHP版本

  Sources   Download

MIT

The Requires

 

The Development Requires

php nlp natural language processing chinese jieba

19/06 2017

0.25.1

0.25.1.0

结巴中文分词PHP版本

  Sources   Download

MIT

The Requires

 

The Development Requires

php jieba

16/02 2016

0.25

0.25.0.0

結巴中文分詞(PHP 版本):做最好的 PHP 中文分詞、中文斷詞組件

  Sources   Download

MIT

The Requires

  • php >= 5.3

 

The Development Requires

by Avatar fukuball

php jieba

06/02 2016

0.24

0.24.0.0

結巴中文分詞(PHP 版本):做最好的 PHP 中文分詞、中文斷詞組件

  Sources   Download

MIT

The Requires

  • php >= 5.3

 

The Development Requires

by Avatar fukuball

php jieba

28/01 2016

0.22

0.22.0.0

結巴中文分詞(PHP 版本):做最好的 PHP 中文分詞、中文斷詞組件

  Sources   Download

MIT

The Requires

  • php >= 5.3

 

The Development Requires

by Avatar fukuball

php jieba

27/01 2016

0.21

0.21.0.0

結巴中文分詞(PHP 版本):做最好的 PHP 中文分詞、中文斷詞組件

  Sources   Download

MIT

The Requires

  • php >= 5.3

 

The Development Requires

by Avatar fukuball

php jieba

26/11 2015

0.20

0.20.0.0

結巴中文分詞(PHP 版本):做最好的 PHP 中文分詞、中文斷詞組件

  Sources   Download

MIT

The Requires

  • php >= 5.3

 

The Development Requires

by Avatar fukuball

php jieba

27/07 2015

0.19

0.19.0.0

結巴中文分詞(PHP 版本):做最好的 PHP 中文分詞、中文斷詞組件

  Sources   Download

MIT

The Requires

  • php >= 5.4

 

The Development Requires

by Avatar fukuball

php jieba

27/05 2015

0.18

0.18.0.0

結巴中文分詞(PHP 版本):做最好的 PHP 中文分詞、中文斷詞組件

  Sources   Download

MIT

The Requires

  • php >= 5.4

 

The Development Requires

by Avatar fukuball

php jieba

02/05 2015

0.17

0.17.0.0

結巴中文分詞(PHP 版本):做最好的 PHP 中文分詞、中文斷詞組件

  Sources   Download

MIT

The Requires

  • php >= 5.4

 

The Development Requires

by Avatar fukuball

php jieba

30/04 2015

0.16

0.16.0.0

結巴中文分詞(PHP 版本):做最好的 PHP 中文分詞、中文斷詞組件

  Sources   Download

MIT

The Requires

  • php >= 5.4

 

The Development Requires

by Avatar fukuball