Jieba 中文分词在 Rust 中实现,并为 PHP 提供绑定。
The Jieba Chinese Word Segmentation Implemented in Rust Bound for PHP.
# Optional, specify if php isn't installed globally,
# this environment is used by `phper-sys`.
#
# export PHP_CONFIG=<Your path of php-config>
# Build libjieba.so.
cargo build --release
php -d "extension=target/debug/libjieba.so" -r "print_r((new Jieba())->cut('我们中出了一个叛徒'));"
<?php
$jieba = new Jieba();
$words = $jieba->cut("我们中出了一个叛徒", true);
print_r($words);
$words = $jieba->cutAll("我们中出了一个叛徒");
print_r($words);
$words = $jieba->cutForSearch("我们中出了一个叛徒");
print_r($words);
MulanPSL-2.0