{"id":47143162,"url":"https://github.com/pboyd/markov","last_synced_at":"2026-03-12T22:33:30.297Z","repository":{"id":57498187,"uuid":"141653015","full_name":"pboyd/markov","owner":"pboyd","description":"Markov chain implementation for Go","archived":false,"fork":false,"pushed_at":"2018-09-22T13:54:36.000Z","size":78,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-08-14T05:03:56.418Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Go","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/pboyd.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-07-20T02:23:38.000Z","updated_at":"2023-06-24T10:41:50.000Z","dependencies_parsed_at":"2022-08-28T17:12:16.390Z","dependency_job_id":null,"html_url":"https://github.com/pboyd/markov","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/pboyd/markov","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pboyd%2Fmarkov","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pboyd%2Fmarkov/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pboyd%2Fmarkov/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pboyd%2Fmarkov/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pboyd","download_url":"https://codeload.github.com/pboyd/markov/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pboyd%2Fmarkov/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30446448,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-12T21:31:01.033Z","status":"ssl_error","status_checked_at":"2026-03-12T21:30:43.161Z","response_time":114,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":"2026-03-12T22:33:29.824Z","updated_at":"2026-03-12T22:33:30.288Z","avatar_url":"https://github.com/pboyd.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Markov [![GoDoc](https://godoc.org/github.com/golang/gddo?status.svg)](https://godoc.org/github.com/pboyd/markov)\n\n`markov` is a Markov chain for Go. The package contains a in-memory chain and a\nslower disk-based version, and functions to move between the memory and disk\nversions.\n\n## Example\n\nThis example generates a nonsense sentence from sample text.\n\n```go\npackage main\n\nimport (\n\t\"fmt\"\n\n\t\"github.com/pboyd/markov\"\n)\n\nconst text = `Listen, strange women lying in ponds distributing swords is no basis for a system of government. Supreme executive power derives from a mandate from the masses, not from some farcical aquatic ceremony.`\n\nfunc main() {\n\tchain := markov.NewMemoryChain(0)\n\n\t// Feed each rune into the chain\n\tmarkov.Feed(chain, split(text))\n\n\t// Walk the chain with randomly but with weighted probabilities.\n\twalker := markov.RandomWalker(chain, 0)\n\tfor {\n\t\tr, _ := walker.Next()\n\t\tfmt.Printf(string(r.(rune)))\n\n\t\t// Stop after the first period.\n\t\tif r == '.' {\n\t\t\tbreak\n\t\t}\n\t}\n\n        fmt.Print(\"\\n\")\n}\n\nfunc split(text string) chan interface{} {\n\trunes := make(chan interface{})\n\tgo func() {\n\t\tdefer close(runes)\n\n\t\t// Start at the beginning of a word\n\t\trunes \u003c- ' '\n\n\t\tfor _, r := range text {\n\t\t\trunes \u003c- r\n\t\t}\n\t}()\n\treturn runes\n}\n```\n\nFor more in-depth examples see the `cmd/markov-ngram` and `cmd/markov-walk` programs.\n\n# License\n\nThis package is released under the terms of the Apache 2.0 license. See LICENSE.TXT.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpboyd%2Fmarkov","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpboyd%2Fmarkov","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpboyd%2Fmarkov/lists"}