py-aho-corasick
===============================
.. image:: https://img.shields.io/pypi/v/py_aho_corasick.svg
:target: https://pypi.python.org/pypi/py_aho_corasick
.. image:: https://img.shields.io/travis/JanFan/py_aho_corasick.svg
:target: https://travis-ci.org/JanFan/py_aho_corasick
.. image:: https://readthedocs.org/projects/py-aho-corasick/badge/?version=latest
:target: https://py-aho-corasick.readthedocs.io/en/latest/?badge=latest
:alt: Documentation Status
.. image:: https://pyup.io/repos/github/JanFan/py_aho_corasick/shield.svg
:target: https://pyup.io/repos/github/JanFan/py_aho_corasick/
:alt: Updates
py-aho-corasick
* Free software: MIT license
* The prototype is inspired by and borrowed from `Carolyn Shen <http://carshen.github.io/data-structures/algorithms/2014/04/07/aho-corasick-implementation-in-python.html>`_
Features
--------
* Pure Python implementation
* Python2 && Python3 support
* Unicode && UTF-8 encoding support
* Pickle-able serialization
Usage
--------
Install::
pip install py_aho_corasick
Usage::
from py_aho_corasick import py_aho_corasick
# keywords only
A = py_aho_corasick.Automaton(['cash', 'shew', 'ew'])
text = "cashew"
for idx,k,v in A.get_keywords_found(text):
assert text[idx:idx+len(k)] == k
# keywords and values
kv = [('cash',1), ('shew',2), ('ew',3)]
A = py_aho_corasick.Automaton(kv)
text = "cashew"
for idx,k,v in A.get_keywords_found(text):
assert text[idx:idx+len(k)] == k
assert v == dict(kv)[k]
Performance
--------
Compared with `pyahocorasick (C extention) <https://github.com/WojciechMula/pyahocorasick>`_
You can run the testing script to get this::
# Requirements:
# pip install pyahocorasick
python cmp.py
* pyahocorasick: text of 1000000 length, 1000 keywords, building time 0.026426076889038086 and searching time cost 0.047805070877075195
* py_aho_corasick: text of 1000000 length, 1000 keywords, building time 0.47435593605041504 and searching time cost 4.24287486076355
Sorry about the poor performance :-(
Development
--------
Run tests::
# testing against py2 and py3
tox
TODO
--------
* Performance optimization
=======
History
=======
0.1.0 (2017-04-17)
------------------
* First release on PyPI.
Metadata
Release files for py_aho_corasick 1.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| py_aho_corasick-1.1.0.tar.gz | 15.8 kB | Without provenance | Details for py_aho_corasick-1.1.0.tar.gz |
Release files / py_aho_corasick-1.1.0.tar.gz
| Download URL | py_aho_corasick-1.1.0.tar.gz |
|---|---|
| Size | 15.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
8ab37ad323fa42982012a98a529ee2465ea2e4b382508c0aff86b2aaa5c45ca6
|
|
BLAKE2b-256 checksum How to use checksums |
44b05c78df4c57dd87e0a96ef363eacd6bf6dba60457e5c51b4b54176a89ca20
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Security for py_aho_corasick 1.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.