Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up

A PHP implementation of the Aho-Corasick string search algorithm. Mirror fromhttps://gerrit.wikimedia.org/g/AhoCorasick - our actual code is hosted with Gerrit (please seehttps://www.mediawiki.org/wiki/Developer_access for contributing)

License

NotificationsYou must be signed in to change notification settings

wikimedia/AhoCorasick

Repository files navigation

Packagist.org

AhoCorasick

AhoCorasick is a PHP implementation of theAho-Corasick string searchalgorithm, which is an efficient way of searching a body of text for multiplesearch keywords.

Here is how you use it:

useAhoCorasick\MultiStringMatcher;$keywords =newMultiStringMatcher(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 ofsearch keywords. The time it takes to construct the finite state machine isproportional to the sum of the lengths of the search keywords. Onceconstructed, the machine can locate all occurences of all search keywords inany body of text in a single pass, making exactly one state transition perinput 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 onnist.gov.

Contribute

Support

If you are having issues,please let us know.

License

The project is licensed under the Apache license.

About

A PHP implementation of the Aho-Corasick string search algorithm. Mirror fromhttps://gerrit.wikimedia.org/g/AhoCorasick - our actual code is hosted with Gerrit (please seehttps://www.mediawiki.org/wiki/Developer_access for contributing)

Topics

Resources

License

Code of conduct

Stars

Watchers

Forks

Languages


[8]ページ先頭

©2009-2025 Movatter.jp