定制 wikimedia/aho-corasick 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

wikimedia/aho-corasick

最新稳定版本:v2.0.0

Composer 安装命令:

composer require wikimedia/aho-corasick

包简介

An implementation of the Aho-Corasick string matching algorithm.

README 文档

README

Packagist.org

AhoCorasick

AhoCorasick is a PHP implementation of the Aho-Corasick string search algorithm, which is an efficient way of searching a body of text for multiple search keywords.

Here is how you use it:

use AhoCorasick\MultiStringMatcher;

$keywords = new MultiStringMatcher( array( 'ore', 'hell' ) );

$keywords->searchIn( 'She sells sea shells by the sea shore.' );
// Result: array( array( 15, 'hell' ), array( 34, 'ore' ) )

$keywords->searchIn( 'Say hello to more text. MultiStringMatcher objects are reusable!' );
// Result: array( array( 4, 'hell' ), array( 14, 'ore' ) )

Features

The algorithm works by constructing a finite-state machine out of the set of search keywords. The time it takes to construct the finite state machine is proportional to the sum of the lengths of the search keywords. Once constructed, the machine can locate all occurences of all search keywords in any body of text in a single pass, making exactly one state transition per input character.

The algorithm originates from "Efficient string matching: an aid to bibliographic search" (CACM, Volume 18, Issue 6, June 1975) by Alfred V. Aho and Margaret J. Corasick.

See also the definition and reference implementation on nist.gov.

Contribute

Support

If you are having issues, please let us know.

License

The project is licensed under the Apache license.

统计信息

  • 总下载量: 3.18M
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 58
  • 点击次数: 1
  • 依赖项目数: 2
  • 推荐数: 0

GitHub 信息

  • Stars: 56
  • Watchers: 16
  • Forks: 10
  • 开发语言: PHP

其他信息

  • 授权协议: Apache-2.0
  • 更新时间: 2015-06-14