{"id":21409889,"url":"https://github.com/stackbuilders/corasick-park","last_synced_at":"2025-08-29T06:05:13.933Z","repository":{"id":20756646,"uuid":"24041218","full_name":"stackbuilders/corasick-park","owner":"stackbuilders","description":"Server for velociraptor-speed substitutions using the Aho-Corasick algorithm.","archived":false,"fork":false,"pushed_at":"2014-09-29T23:01:24.000Z","size":392,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":60,"default_branch":"master","last_synced_at":"2025-03-16T17:46:25.949Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Haskell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/stackbuilders.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}},"created_at":"2014-09-15T03:20:47.000Z","updated_at":"2019-12-05T06:33:35.000Z","dependencies_parsed_at":"2022-08-26T01:33:12.080Z","dependency_job_id":null,"html_url":"https://github.com/stackbuilders/corasick-park","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/stackbuilders/corasick-park","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stackbuilders%2Fcorasick-park","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stackbuilders%2Fcorasick-park/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stackbuilders%2Fcorasick-park/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stackbuilders%2Fcorasick-park/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/stackbuilders","download_url":"https://codeload.github.com/stackbuilders/corasick-park/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stackbuilders%2Fcorasick-park/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":272639873,"owners_count":24968517,"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","status":"online","status_checked_at":"2025-08-29T02:00:10.610Z","response_time":87,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":"2024-11-22T17:34:56.397Z","updated_at":"2025-08-29T06:05:13.894Z","avatar_url":"https://github.com/stackbuilders.png","language":"Haskell","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Corasick Park\n\nCorasick Park is a server for quickly applying lots of transformations\nto strings. By using a simple JSON interface, you can specify the\nstring replacements that should be made. After you describe the\ntransformations that should be made, you can hit another JSON endpoint\nto quickly apply the transformations that you described.\n\nCorasick Park is able to apply hundreds of thousands of transactions\nin less than a second by using\n[the Aho-Corasick algorithm](http://en.wikipedia.org/wiki/Aho%E2%80%93Corasick_string_matching_algorithm)\nfor finding out which transformations apply to the string you\nprovide. Currently the server uses the\n[Aho-Corasick implementation in Haskell](http://hackage.haskell.org/package/AhoCorasick)\nfor the heavy lifting of finding the correct patterns to apply.\n\nSince it is very quick even to precompile hundreds of thousands of\npatterns, the server doesn't persist anything to disk, and uses\nHaskell's MVars for safe concurrency.\n\nCorasick Park allows you to precompile patterns in groups by a\n'bucket' name so that you can easily choose which set of\ntransformations to apply for each string.\n\n## Downloading and Running\n\nIn order to install this project, you should first install GHC\n(Haskell compiler) and cabal (Haskell dependency management). Once you\nhave these dependencies installed, clone this project using git, `cd`\nto the folder where this project lives, and execute the following:\n\n```bash\ncabal install --only-dependencies --enable-tests\ncabal test\n```\n\nIf the test command runs without error, you have correctly installed\nthe application.\n\nIn order to start the server, execute `cabal run`. The server will\nstart on port 8000, and you can test it by sending JSON requests\nsimilar to the following.\n\n## Interface\n\n`POST` the transformations that you wish to apply to `/operations`:\n\n```json\n\n{\"name\": \"downcasefoos\", \"operations\":\n    [{\"target\":\n        { \"text\": \"foo\",\n          \"isCaseSensitive\": false,\n          \"leftBoundaryType\": \"none\",\n          \"rightBoundaryType\": \"none\",\n          \"isGlobal\": true\n        },\n      \"transform\":{\"type\": \"replace\", \"replacement\": \"bar\"}\n      }]\n}\n```\n\nThen, apply the transformations you specified by submitting a `POST`\nrequest to the `/transform` endpoint:\n\n```json\n{ \"name\": \"testbucket\", \"input\": \"foo bar baz\" }\n```\n\nResult:\n\n```json\n{\n  \"result\" : \"bar bar baz\"\n}\n```\n\nSince Corasick Park doesn't store anything to disk, clients could\nfirst try posting to a particular bucket to apply a transformation,\nand if the server returns a 404 (bucket not found) the client should\npost all of the transformations again, and then re-try the\ntransformation endpoint.\n\n## Supported Target Patterns\n\nCorasick Park doesn't have full support for regular\nexpressions. However you can customize the patterns that are matched\nfor replacements by specifying case sensitivity (`isCaseSensitive`\noption), global or single replacement (`isGlobal` option), and the\ntypes of boundaries on each side of the pattern you specified. The\ncurrently supported boundaries, which can be supplied to the\n`leftBoundaryType` and `rightBoundaryType` option are:\n\n* `none` - there is no requirement for the type of boundary around the\n  string\n* `word` - the match must be surrounded by word boundaries (similar to\n  `\\b` in a Ruby regular expression\n* `line` - there must be a newline at the specified side of the match\n* `input` - the input boundary must be on the specified side of the\n    match. To specify that the match needs to be exact, just put an\n    input boundary on both sides.\n\n## Supported String Transformations\n\nCorasick Park can apply a variety of transformations to input strings\nafter efficiently finding the applicable transformations using the\nAho-Corasick state machine. The following transformations are\ncurrently supported:\n\n* `replace` - Replaces the target with another target\n* `upcase` - Upper-cases matches of the target in input text\n* `downcase` - Lower-cases matches of the target in input text\n* `titleize` - Captalizes the first letter in each word of the input\n  string\n* `truncate trailing` - Removes the text following each match of the string\n\n## Configuring the maximum number of buckets\n\nSince all of the state machines compiled by Corasick Park are held in memory,\nit uses an LRU algorithm to evict older values from the cache. By default,\n1,000 'buckets' are kept in memory before evicting the one that has not had an\naccess in the greatest amount of time. You can configure the number of buckets\nto be held in memory with the MAX_BUCKETS environment variable, which accepts\nan integer, or the string \"unlimited\" if you do not wish to automatically evict\nbuckets from memory.\n\n## Author\n\nJustin Leitgeb, Stack Builders Inc.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstackbuilders%2Fcorasick-park","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fstackbuilders%2Fcorasick-park","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstackbuilders%2Fcorasick-park/lists"}