PHPackages                             forever2077/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. [Parsing &amp; Serialization](/categories/parsing)
4. /
5. forever2077/jieba-php

ActiveLibrary[Parsing &amp; Serialization](/categories/parsing)

forever2077/jieba-php
=====================

The Jieba Chinese Word Segmentation Implemented in PHP

0.1.1(2y ago)071MITPHPPHP &gt;=7.4

Since Sep 12Pushed 2y agoCompare

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

READMEChangelog (1)Dependencies (4)Versions (2)Used By (1)

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 forever2077/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

18

—

LowBetter than 8% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity4

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity33

Early-stage or recently created project

 Bus Factor1

Top contributor holds 60% 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

974d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/758b0f41ec6fd34df3b483dd78ceb1f30b4248bfbc1a3733f88ff0669aaddc8e?d=identicon)[forever2077](/maintainers/forever2077)

---

Top Contributors

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

---

Tags

ChineseffisegmentationJiebajieba-php

###  Code Quality

TestsPHPUnit

Code StylePHP CS Fixer

### Embed Badge

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

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

###  Alternatives

[mtdowling/jmespath.php

Declaratively specify how to extract elements from a JSON document

2.0k472.8M135](/packages/mtdowling-jmespathphp)[opis/closure

A library that can be used to serialize closures (anonymous functions) and arbitrary data.

2.6k230.0M284](/packages/opis-closure)[masterminds/html5

An HTML5 parser and serializer.

1.8k242.8M229](/packages/masterminds-html5)[sabberworm/php-css-parser

Parser for CSS Files written in PHP

1.8k191.2M65](/packages/sabberworm-php-css-parser)[jms/metadata

Class/method/property metadata management in PHP

1.8k152.8M88](/packages/jms-metadata)[jms/serializer-bundle

Allows you to easily serialize, and deserialize data of any complexity

1.8k89.3M627](/packages/jms-serializer-bundle)

PHPackages © 2026

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