{"id":18952591,"url":"https://github.com/jdan/markov.rb","last_synced_at":"2026-03-29T11:30:18.314Z","repository":{"id":145189748,"uuid":"384734072","full_name":"jdan/markov.rb","owner":"jdan","description":"Simple Markov generator to produce realistic-looking names.","archived":false,"fork":false,"pushed_at":"2021-07-11T01:51:18.000Z","size":72,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-01-01T02:41:34.312Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","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/jdan.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-07-10T15:47:39.000Z","updated_at":"2022-03-08T00:03:09.000Z","dependencies_parsed_at":null,"dependency_job_id":"cf3167e0-cf55-4a94-8197-9e88bafd95d9","html_url":"https://github.com/jdan/markov.rb","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/jdan%2Fmarkov.rb","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jdan%2Fmarkov.rb/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jdan%2Fmarkov.rb/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jdan%2Fmarkov.rb/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jdan","download_url":"https://codeload.github.com/jdan/markov.rb/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239952598,"owners_count":19723922,"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":"2024-11-08T13:34:02.891Z","updated_at":"2026-03-29T11:30:18.280Z","avatar_url":"https://github.com/jdan.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"## markov.rb\n\nSimple [Markov generator](https://en.wikipedia.org/wiki/Markov_chain#Markov_text_generators) to produce\nrealistic-looking names.\n\n### usage\n\n```\n$ ruby main.rb --help\nUsage: main.rb [options]\n    -n, --ngram-length=N             Number of characters to scan when building n-grams\n    -c, --count=COUNT                Number of names to generate\n    -x, --xstate                     Output an X-State machine definition\n    -w, --word                       Separate text into words, rather than characters\n$ ruby main.rb -n 4 -c 10 \u003c names.txt\n[new] Kenne\n[new] Wellina\n[new] Dontavia\n[new] Sachel\n[new] Kayshaunn\n[existing] Melaney\n[new] Lucetta\n[existing] Tonny\n[new] Corenea\n[existing] Quentina\n$ ruby main.rb -n 1 -w -c 1 \u003c decl.txt\nWe, therefore, acquiesce in the same Object evinces a right do.\n```\n\n#### Experimental\n\nOutput to an [X-State](https://xstate.js.org/docs/) state-machine:\n\n```\n$ ruby main.rb -x \u003c names-top10.txt \u003e state.js\n```\n\nhttps://xstate.js.org/viz/?gist=91030bd79939c8bc7192e8f27293861c\n\n### how it works\n\nWe input a list of names ([names.txt](/names.txt)) and for each name, split it into a list [n-grams](https://en.wikipedia.org/wiki/N-gram). For example: (Jordan, 4) =\u003e START -\u003e Jord -\u003e orda -\u003e rdan -\u003e END. We can combine two of these \"chains\" such as START =\u003e [Jord, Jack], Jord =\u003e [orda], Jack =\u003e [acks], ... to build a [state machine](https://en.wikipedia.org/wiki/Finite-state_machine).\n\nOnce the state machine is built, we begin at START and _randomly_ choose a path to take (i.e. START -\u003e \"Jord\" or \"Jack\"). Interesting things happen when our list has _shared n-grams_ (for example: \"Michael\" and \"Richard\" both contain the \"icha\" 4-gram).\n\nWith a sufficiently large input size (\"All first names with frequency at least 5 in the United States in 1984\") and the right n-gram size (2 seems to produce fairly alien names while 4 produces realistic names without too many existing ones), we can generate a list of names that could pass for the real thing.\n\n### credits\n\nJordan Ellenberg's [Shape](https://amzn.to/3yKptm0) has a fantastic section on Markov chains that inspired this.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjdan%2Fmarkov.rb","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjdan%2Fmarkov.rb","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjdan%2Fmarkov.rb/lists"}