{"id":16602931,"url":"https://github.com/leonardpepa/string-matching-go","last_synced_at":"2025-03-09T12:56:13.502Z","repository":{"id":215999555,"uuid":"738358253","full_name":"Leonardpepa/string-matching-go","owner":"Leonardpepa","description":"String matching algorithms written in go","archived":false,"fork":false,"pushed_at":"2024-01-07T21:32:11.000Z","size":1760,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-01-17T08:45:44.138Z","etag":null,"topics":["algorithms","brute-force","dfa","go","golang","introduction-to-algorithms","knuth-morris-pratt","rabin-karp-algorithm","string-matching"],"latest_commit_sha":null,"homepage":"https://github.com/Leonardpepa/string-matching-go?tab=readme-ov-file","language":"Go","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/Leonardpepa.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}},"created_at":"2024-01-03T03:32:17.000Z","updated_at":"2024-01-07T21:17:39.000Z","dependencies_parsed_at":"2024-01-24T12:04:43.657Z","dependency_job_id":"baa672cf-3cb3-402a-b8a6-126cc103c7db","html_url":"https://github.com/Leonardpepa/string-matching-go","commit_stats":{"total_commits":35,"total_committers":2,"mean_commits":17.5,"dds":0.02857142857142858,"last_synced_commit":"275a5e5dcf46528600cc6d7dba34d71059cc9c11"},"previous_names":["leonardpepa/string-matching-go"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Leonardpepa%2Fstring-matching-go","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Leonardpepa%2Fstring-matching-go/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Leonardpepa%2Fstring-matching-go/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Leonardpepa%2Fstring-matching-go/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Leonardpepa","download_url":"https://codeload.github.com/Leonardpepa/string-matching-go/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":242692349,"owners_count":20170228,"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":["algorithms","brute-force","dfa","go","golang","introduction-to-algorithms","knuth-morris-pratt","rabin-karp-algorithm","string-matching"],"created_at":"2024-10-12T00:45:51.856Z","updated_at":"2025-03-09T12:56:13.473Z","avatar_url":"https://github.com/Leonardpepa.png","language":"Go","readme":"# String matching algorithms written in go\n\n## Purpose\n\n* Educational\n\n## Description\n\nThis project is an implementation of various string matching algorithms described\nin [Introduction to algorithms](https://dl.ebooksworld.ir/books/Introduction.to.Algorithms.4th.Leiserson.Stein.Rivest.Cormen.MIT.Press.9780262046305.EBooksWorld.ir.pdf)\u003cbr\u003e\n\n## Algorithms Implemented\n\n* Brute force\n* Rabin Karp\n* DFA (Deterministic finite automaton)\n* Knuth Morris Pratt\n\n## Time Complexity\n * n = length of the input text\n * m = length of the pattern\n * This table shows the worst case time\n\u003ctable\u003e\n  \u003ctr\u003e\n    \u003cth\u003eAlgorithms\u003c/th\u003e\n    \u003cth\u003ePreprocessing time\u003c/th\u003e\n    \u003cth\u003eMatching time\u003c/th\u003e\n  \u003c/tr\u003e\n  \u003ctr\u003e\n    \u003ctd\u003eBrute Force\u003c/td\u003e\n    \u003ctd\u003e0\u003c/td\u003e\n    \u003ctd\u003eΟ((n - m + 1)m)\u003c/td\u003e\n  \u003c/tr\u003e\n\u003ctr\u003e\n    \u003ctd\u003eRabin Karp\u003c/td\u003e\n    \u003ctd\u003eΘ(m)\u003c/td\u003e\n    \u003ctd\u003eΟ((n - m + 1)m)\u003c/td\u003e\n  \u003c/tr\u003e\n\u003ctr\u003e\n    \u003ctd\u003eDFA\u003c/td\u003e\n    \u003ctd\u003eΟ(m |Σ|)\u003c/td\u003e\n    \u003ctd\u003eΘ(n)\u003c/td\u003e\n  \u003c/tr\u003e\n\u003ctr\u003e\n    \u003ctd\u003eKnuth Morris Pratt\u003c/td\u003e\n    \u003ctd\u003eΘ(m)\u003c/td\u003e\n    \u003ctd\u003eΘ(n)\u003c/td\u003e\n  \u003c/tr\u003e\n\u003c/table\u003e\n\n### String Matching Definition\nThe problem of finding occurrence(s) of a pattern string within another string or body of text.\nThe algorithm returns an array of the first index for every occurrence in the text\n\n## Example\n\n```go\npackage main\n\nimport (\n\t\"fmt\"\n\t\"log\"\n\t\"string-matching/internal/KMP\"\n)\n\nfunc main() {\n\tinput := `Project Gutenberg's International Short Stories: French, by Various\n\nThis eBook is for the use of anyone anywhere at no cost and with\nalmost no restrictions whatsoever.  You may copy it, give it away or\nre-use it under the terms of the Project Gutenberg License included\nwith this eBook or online at www.gutenberg.net\n`\n\n\tpattern := \"Gutenberg\"\n\n\tindexes, err := KMP.MatchString(input, pattern)\n\n\tif err != nil {\n\t\tlog.Fatal(err)\n\t}\n\n\tprintMatches(indexes, input, len(pattern))\n}\n\nfunc printMatches(indexes []int, input string, patternLen int) {\n\tfor _, index := range indexes {\n\t\tfmt.Printf(\"found at %d, %s\\n\", index, input[index:index+patternLen])\n\t}\n}\n```\n\n### output\n\n```terminal\nfound at 8, Gutenberg\nfound at 244, Gutenberg\n```\n\n# How to run\n1. Clone the repo ```git clone https://github.com/Leonardpepa/string-matching-go.git```\n2. Build ```go build```\n3. run on windows```string-matching.exe```\n4. run on linux ```./string-matching```\n5. run tests ```go test```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fleonardpepa%2Fstring-matching-go","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fleonardpepa%2Fstring-matching-go","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fleonardpepa%2Fstring-matching-go/lists"}