{"id":23168977,"url":"https://github.com/amenezes/pybmoore","last_synced_at":"2025-08-18T06:33:57.338Z","repository":{"id":44403778,"uuid":"411750202","full_name":"amenezes/pybmoore","owner":"amenezes","description":"Python/Cython Boyer-Moore string-search algorithm","archived":false,"fork":false,"pushed_at":"2024-11-27T16:29:56.000Z","size":363,"stargazers_count":5,"open_issues_count":0,"forks_count":1,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-11-27T17:31:46.483Z","etag":null,"topics":["boyer-moore","boyer-moore-algorithm","cython","python"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/amenezes.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-09-29T16:30:26.000Z","updated_at":"2024-11-27T16:30:00.000Z","dependencies_parsed_at":"2024-02-11T23:31:20.784Z","dependency_job_id":"1708fb8c-2a8d-4215-8103-d10495038590","html_url":"https://github.com/amenezes/pybmoore","commit_stats":null,"previous_names":[],"tags_count":12,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/amenezes%2Fpybmoore","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/amenezes%2Fpybmoore/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/amenezes%2Fpybmoore/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/amenezes%2Fpybmoore/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/amenezes","download_url":"https://codeload.github.com/amenezes/pybmoore/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":230210443,"owners_count":18190671,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["boyer-moore","boyer-moore-algorithm","cython","python"],"created_at":"2024-12-18T03:14:36.315Z","updated_at":"2024-12-18T03:15:32.742Z","avatar_url":"https://github.com/amenezes.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"![Build Status](https://github.com/amenezes/pybmoore/actions/workflows/ci.yml/badge.svg?branch=master)\n[![codecov](https://codecov.io/gh/amenezes/pybmoore/branch/master/graph/badge.svg)](https://codecov.io/gh/amenezes/pybmoore)\n[![PyPI version](https://badge.fury.io/py/pybmoore.svg)](https://badge.fury.io/py/pybmoore)\n![PyPI - Python Version](https://img.shields.io/pypi/pyversions/pybmoore)\n[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)\n\n# pybmoore\n\nPython/Cython implementation of [Boyer-Moore string-search algorithm](https://en.wikipedia.org/wiki/Boyer%E2%80%93Moore_string-search_algorithm).\n\n## Installing\n\nInstall and update using uv:\n\n````bash\nuv pip install pybmoore\n````\n\n\u003e notice: `gcc` must be available on the system.\n\n## Usage\n\n### Single term\n\nThe search method in the `pybmoore` module will return a list of tuples with all occurrences, where the tuple have the initial and final position. For example:\n\n```python\nimport pybmoore\n\n\nTEXT = \"\"\"The Boyer–Moore string-search algorithm is \nan efficient string-searching algorithm that is the \nstandard benchmark for practical string-search literature.\n\"\"\"\n\nmatches = pybmoore.search('string', TEXT)\nprint(f\"Occurrences: {len(matches)}\")\n# output: Occurrences: 3\n\nprint(matches)\n# output: [(16, 22), (57, 63), (130, 136)]\n\nfor x, y in matches:\n    print(f\"({x},{y}) - {TEXT[x:y]}\")\n```\n\n\u003e notice: search method it's case sensitive.\n\n\n```python\nimport pybmoore\n\n\nTEXT = \"\"\"The algorithm preprocesses the string being searched for (the pattern), \nbut not the string being searched in (the text). It is thus well-suited for \napplications in which the pattern is much shorter than the text or where it \npersists across multiple searches.\n\"\"\"\n\npybmoore.search('algorithm', TEXT)\n# output: [(4, 13)]\n\npybmoore.search('Algorithm', TEXT)\n# output: []\n```\n\n### Multiple terms\n\n```python\nfrom concurrent.futures import ProcessPoolExecutor, ThreadPoolExecutor\n\nimport pybmoore\n\n\nTEXT = \"\"\"The Boyer-Moore algorithm searches for occurrences of P in T by \nperforming explicit character comparisons at different alignments. Instead of a \nbrute-force search of all alignments (of which there are m − n + 1, Boyer-Moore \nuses information gained by preprocessing P to skip as many alignments as possible.\n\"\"\"\n\n# Using a list of patterns\npybmoore.search_m(['brute-force', 'Boyer-Moore'], TEXT, ProcessPoolExecutor)\n# output: {'brute-force': [(146, 157)], 'Boyer-Moore': [(4, 15), (214, 225)]}\n\n# Using a set of patterns\npybmoore.search_m({'brute-force', 'Boyer-Moore'}, TEXT, ThreadPoolExecutor)\n# output: {'brute-force': [(146, 157)], 'Boyer-Moore': [(4, 15), (214, 225)]}\n\n# Using a tuple of patterns\npybmoore.search_m(('brute-force', 'Boyer-Moore'), TEXT, ThreadPoolExecutor, max_workers=4)\n# output: {'brute-force': [(146, 157)], 'Boyer-Moore': [(4, 15), (214, 225)]}\n```\n\n\u003e Details\n\nFor granular control of the pool, use the parameters listed in the module documentation. For example:\n\n## Development\n\nTo build **pybmoore** locally first install `requirements-dev.txt` dependencies and run:\n\n```bash\nmake build # without Cython\n\nmake build USE_CYTHON=1 # with Cython\n```\n\n\u003e in some cases it's necesary run `make clean` before `make build`.\n\nType `make` in the command line to see all available targets.\n\n## Links\n\n- License: [Apache License](https://choosealicense.com/licenses/apache-2.0/)\n- Code: [https://github.com/amenezes/pybmoore](https://github.com/amenezes/pybmoore)\n- Issue tracker: [https://github.com/amenezes/pybmoore/issues](https://github.com/amenezes/pybmoore/issues)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Famenezes%2Fpybmoore","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Famenezes%2Fpybmoore","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Famenezes%2Fpybmoore/lists"}