{"id":26658266,"url":"https://github.com/ltbringer/exegr","last_synced_at":"2025-04-11T13:07:56.942Z","repository":{"id":99060901,"uuid":"258836321","full_name":"ltbringer/exegr","owner":"ltbringer","description":"Python port for rust's regex","archived":false,"fork":false,"pushed_at":"2020-05-31T08:02:11.000Z","size":18,"stargazers_count":7,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-25T09:19:08.348Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ltbringer.png","metadata":{"files":{"readme":"Readme.md","changelog":null,"contributing":null,"funding":null,"license":null,"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,"zenodo":null}},"created_at":"2020-04-25T17:39:47.000Z","updated_at":"2023-08-24T02:50:17.000Z","dependencies_parsed_at":null,"dependency_job_id":"7df03a3f-3bc6-4915-bfbd-84d2b51f4490","html_url":"https://github.com/ltbringer/exegr","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ltbringer%2Fexegr","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ltbringer%2Fexegr/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ltbringer%2Fexegr/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ltbringer%2Fexegr/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ltbringer","download_url":"https://codeload.github.com/ltbringer/exegr/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248404551,"owners_count":21097771,"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":[],"created_at":"2025-03-25T09:19:10.920Z","updated_at":"2025-04-11T13:07:56.924Z","avatar_url":"https://github.com/ltbringer.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Exegr\n\n\nTrying to optimize code that relied on python's regex brought me to a point\nwhere I was still looking at ~400 (at times unicode rich) patterns and 10 sentences\nto search in. This search cost the algorithm over 100ms. It came to a point where it seemed there\nis no other way than to shed some code which meant a sacrifice of accuracy over speed.\n\nI read about the problems with the [implementation](https://swtch.com/~rsc/regexp/regexp1.html) and better\nalternatives to `regex` libraries. \nI found [re2](https://github.com/google/re2) and its [python wrapper](https://github.com/facebook/pyre2/) the\nlack of features, change in APIs throughout the codebase meant having to keep this as a step\nto try later.\n\nI decided to rewrite the particular function in Rust and port it back to Python\nusing [pyo3](https://github.com/PyO3/pyo3). The results have been dramatically [huge](https://ltbringer.github.io/blog/regular-expressions-and-efficiency#compile-time-speed-boost).\n\nThis might not be helpful for general purpose usage due to poor abstraction for the sake of quick testing.\n\n\n## Installation\nYou can easily add exegr to your python projects like:\n```\npip install exegr\n```\n\nFor testing and development use the following:\n\n```shell\ncargo build --release\ncp target/libexegr.so /path/to/py/project\n```\n\n\u003e On windows and linux, you can build normally with cargo build --release. On Mac Os, you need to set additional linker arguments. The simplest solution is to create a .cargo/config with the following content:\n\n```\n[target.x86_64-apple-darwin]\nrustflags = [\n  \"-C\", \"link-arg=-undefined\",\n  \"-C\", \"link-arg=dynamic_lookup\",\n]\n```\n\n## Usage\n```python\nfrom exegr import GroupRegexMatch\n\npatterns: List[str] = []\nsentences: List[str] = []\n# load patterns\n...\ngroup_regex_match = GroupRegexMatch(patterns)\n\n\"\"\"\nThe sentences passes to this function\nare expected to be ASR output which provide\nmultiple options. If your input is a raw string\nuse sentences = [sentence] instead.\n\"\"\"\ngroup_regex_match(sentences)\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fltbringer%2Fexegr","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fltbringer%2Fexegr","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fltbringer%2Fexegr/lists"}