Registry / ai-ml / rjieba

rjieba

JSON →
library0.2.1pypypi✓ verified 87d ago

rjieba is a high-performance Python binding for the `jieba-rs` Rust library, offering efficient Chinese word segmentation. It aims to provide faster processing speeds compared to pure Python implementations by leveraging Rust's performance. The current version is 0.2.0. Releases are infrequent and typically driven by significant updates to the underlying `jieba-rs` library or `pyo3` binding infrastructure.

pip install rjieba
INSTALL
IMPORT
SIG · RJIEBA
R
rjieba
ai-mlpythonv0.2.1
Install
1.6s avg
Import
150ms
Disk
23MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v0.2.1 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.920 runs
installs and imports cleanly · install 0.0s · import 0.158s · 25.3MB
glibc
py 3.103.920 runs
installs and imports cleanly · install 1.6s · import 0.141s · 25MB
23MB installed
● package 23MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

rjieba
import rjieba

This quickstart demonstrates basic Chinese word segmentation and part-of-speech tagging using `rjieba.cut` and `rjieba.tag` functions. No explicit dictionary initialization is required as dictionaries are embedded by default.

import rjieba text = '我们中出了一个叛徒' segmented_text = rjieba.cut(text) print(f"Segmented (cut): {list(segmented_text)}") tagged_text = rjieba.tag(text) print(f"Tagged: {list(tagged_text)}")
Debug
Known issues
gotchaUnlike the original `jieba` Python library, `rjieba` does not typically require an explicit `initialize()` call. Dictionaries are embedded and loaded automatically upon first use, which simplifies setup but might be unexpected for users familiar with `jieba`'s initialization patterns.
fix
Simply import `rjieba` and use its functions directly. Do not look for an `initialize` method.
affects: All versions
gotchaAs a Rust binding, `rjieba` relies on pre-compiled wheels for easy installation across different Python versions, operating systems, and architectures. If a pre-built wheel is not available for your specific environment, `pip install rjieba` might fail, requiring a Rust toolchain to compile from source.
fix
Ensure your environment is supported by available wheels. If not, install Rust (via `rustup`) and related build tools before attempting `pip install rjieba`.
affects: All versions
breakingWhile no explicit breaking changes are documented for `rjieba` itself, significant updates to the underlying `jieba-rs` Rust library (e.g., from `0.7.x` to `0.8.x`) could introduce subtle behavioral changes or new features that might affect `rjieba`'s output or API in future versions.
fix
Refer to the `jieba-rs` GitHub repository (https://github.com/messense/jieba-rs) for changes in the core Rust library when updating `rjieba`.
affects: Potentially future major versions (e.g., 0.3.0+)
Errors
Common errors & fixes
ModuleNotFoundError: No module named 'rjieba'
The `rjieba` package was not successfully installed or is not accessible in the current Python environment. This can happen if the installation failed, especially on platforms without pre-built wheels requiring compilation.
fix
Run `pip install rjieba` again. If it fails with compilation errors, ensure you have Rust and a C compiler installed, or check if your platform is supported by pre-built wheels.
UnicodeEncodeError: 'gbk' codec can't encode character '\u201c' in position X: illegal multibyte sequence
This error, though often associated with `jieba`, can occur with any text processing library if the input text or file encoding is misidentified, particularly when dealing with Chinese characters on systems where the default encoding is not UTF-8 (e.g., some Windows environments).
fix
Explicitly ensure all input text is handled as UTF-8. When reading files, specify `encoding='utf-8'` (e.g., `open('file.txt', 'r', encoding='utf-8')`). If dealing with external data, convert it to UTF-8 before passing to `rjieba`.
Upgrade
Version history
0.2.1latest on PyPI · released Apr 25, 2026
Audit
Dependencies
jieba-rsrequiredrjieba is a Python binding to the Rust `jieba-rs` library, which provides the core segmentation logic.
Agent activity
12 hits · last 30 days
node
10
OpenAI (training)
1
Resources
rjieba — pip install rjieba · libregistry