PHPackages                             binaryoung/jieba-php - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. binaryoung/jieba-php

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

binaryoung/jieba-php
====================

The Jieba Chinese Word Segmentation Implemented in PHP

v0.1.0(5y ago)203649[2 PRs](https://github.com/binaryoung/jieba-php/pulls)MITPHPPHP ^7.4

Since Jun 16Pushed 1y ago1 watchersCompare

[ Source](https://github.com/binaryoung/jieba-php)[ Packagist](https://packagist.org/packages/binaryoung/jieba-php)[ Docs](https://github.com/binaryoung/jieba-php)[ RSS](/packages/binaryoung-jieba-php/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (4)Versions (3)Used By (0)

Jieba PHP
=========

[](#jieba-php)

[![Latest Version on Packagist](https://camo.githubusercontent.com/a38d25c1291e1fd359cf5f0f35c7e0175099906088a25940794a7113cdd63149/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f62696e6172796f756e672f6a696562612d7068702e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/binaryoung/jieba-php)[![GitHub Tests Action Status](https://camo.githubusercontent.com/cd1caf0ba3948e29bf0cd45340f495cee5e3c433262af69ac6e09b536283e2ec/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f776f726b666c6f772f7374617475732f62696e6172796f756e672f6a696562612d7068702f72756e25323074657374733f6c6162656c3d7465737473)](https://github.com/binaryoung/jieba-php/actions?query=workflow%3A%22run+tests%22+branch%3Amaster)[![Total Downloads](https://camo.githubusercontent.com/5da2ce19cf7f7083969d0f931b7162c7006a4676bf5cea5723691238ec8ad059/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f62696e6172796f756e672f6a696562612d7068702e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/binaryoung/jieba-php)

[结巴分词](https://github.com/fxsjy/jieba) PHP 实现 - The Jieba Chinese Word Segmentation Implemented in PHP
使用 PHP 7.4 中新增的 [FFI](https://www.php.net/manual/en/class.ffi.php) 对 [jieba-rs](https://github.com/messense/jieba-rs) 进行了包装。

Requirement
-----------

[](#requirement)

PHP &gt;= 7.4，并开启 FFI 扩展

Installation
------------

[](#installation)

You can install the package via composer:

```
composer require binaryoung/jieba-php
```

Usage
-----

[](#usage)

```
use Binaryoung\Jieba\Jieba;

var_dump(Jieba::cut('PHP是世界上最好的语言！'));
```

API
---

[](#api)

```
array cut(string $sentence, bool $hmm = true)
array cutAll(string $sentence)
array cutForSearch(string $sentence, bool $hmm = true)
array TFIDFExtract(string $sentence, int $topK = 20, array $allowedPOS = [])
array textRankExtract(string $sentence, int $topK = 20, array $allowedPOS = [])
array tokenize(string $sentence, string $mode = 'default', bool $hmm = true)
array tag(string $sentence, bool $hmm = true)
int   suggestFrequency(string $segment)
self  addWord(string $word, ?int $frequency = null, ?string $tag = null)
self  useDictionary(string $path)
```

Examples
--------

[](#examples)

see examples/example.php

```
composer example
```

Testing
-------

[](#testing)

```
composer test
```

Benchmark
---------

[](#benchmark)

```
composer bench
```

对比 [jukuball/jieba-php](https://github.com/fukuball/jieba-php)，循环 50 次对围城每行文字作为一个句子进行分词，分词算法都采用 HMM 模式。

名称耗时单次耗时内存占用内存峰值jukuball/jieba-php51.5931.032493.00MB515.03MBbinaryoung/jieba-php8.4080.1681610.00MB22.01MB差值↓513.59%↓513.59%↓4830.00%↓2240.20%Changelog
---------

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING](CONTRIBUTING.md) for details.

Security
--------

[](#security)

If you discover any security related issues, please email me instead of using the issue tracker.

Credits
-------

[](#credits)

- [young](https://github.com/binaryoung)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

30

—

LowBetter than 64% of packages

Maintenance28

Infrequent updates — may be unmaintained

Popularity24

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity46

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

2163d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/984983?v=4)[Jem Young](/maintainers/young)[@young](https://github.com/young)

---

Top Contributors

[![binaryoung](https://avatars.githubusercontent.com/u/5364548?v=4)](https://github.com/binaryoung "binaryoung (2 commits)")

---

Tags

chinese-word-segmentationffijiebaChineseffisegmentationJiebajieba-php

###  Code Quality

TestsPHPUnit

Code StylePHP CS Fixer

### Embed Badge

![Health badge](/badges/binaryoung-jieba-php/health.svg)

```
[![Health](https://phpackages.com/badges/binaryoung-jieba-php/health.svg)](https://phpackages.com/packages/binaryoung-jieba-php)
```

###  Alternatives

[overtrue/pinyin

Chinese to pinyin translator.

4.5k6.5M72](/packages/overtrue-pinyin)[zhuzhichao/ip-location-zh

get the ip's location info with Chinese

617212.5k11](/packages/zhuzhichao-ip-location-zh)[overtrue/chinese-calendar

中国农历转换与查询工具

557103.7k4](/packages/overtrue-chinese-calendar)[zhuzhichao/bank-card-info

Get the bank card info

45464.8k](/packages/zhuzhichao-bank-card-info)[vanderlee/php-sentence

Simple text sentence splitting and counting. Supports at least english, german and dutch, possibly more.

84555.7k6](/packages/vanderlee-php-sentence)[douyasi/identity-card

Chinese Identity Card package

17851.4k3](/packages/douyasi-identity-card)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
