Giter Site home page Giter Site logo

jieba-php's Introduction

Jieba PHP

Latest Version on Packagist GitHub Tests Action Status Total Downloads

结巴分词 PHP 实现 - The Jieba Chinese Word Segmentation Implemented in PHP
使用 PHP 7.4 中新增的 FFIjieba-rs 进行了包装。

Requirement

PHP >= 7.4,并开启 FFI 扩展

Installation

You can install the package via composer:

composer require binaryoung/jieba-php

Usage

use Binaryoung\Jieba\Jieba;

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

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

see examples/example.php

composer example

Testing

composer test

Benchmark

composer bench

对比 jukuball/jieba-php,循环 50 次对围城每行文字作为一个句子进行分词,分词算法都采用 HMM 模式。

名称 耗时 单次耗时 内存占用 内存峰值
jukuball/jieba-php 51.593 1.032 493.00MB 515.03MB
binaryoung/jieba-php 8.408 0.16816 10.00MB 22.01MB
差值 ↓513.59% ↓513.59% ↓4830.00% ↓2240.20%

Changelog

Please see CHANGELOG for more information on what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security

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

Credits

License

The MIT License (MIT). Please see License File for more information.

jieba-php's People

Contributors

binaryoung avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.