{"id":23709454,"url":"https://github.com/one19/markov-json","last_synced_at":"2025-09-03T15:31:21.303Z","repository":{"id":57291388,"uuid":"127135558","full_name":"one19/markov-json","owner":"one19","description":"Depth 2, variable complexity Markov chain lib done in js with zero deps.","archived":false,"fork":false,"pushed_at":"2024-08-23T01:33:44.000Z","size":451,"stargazers_count":17,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2024-12-23T02:43:18.664Z","etag":null,"topics":["javascript","json","markov-chain","no-dependencies","nodejs","npm-package","typescript"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","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/one19.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}},"created_at":"2018-03-28T12:17:42.000Z","updated_at":"2024-08-23T01:33:47.000Z","dependencies_parsed_at":"2024-08-23T02:41:58.367Z","dependency_job_id":"ad2411f9-6021-4925-8ae6-635e3c80b60a","html_url":"https://github.com/one19/markov-json","commit_stats":{"total_commits":81,"total_committers":1,"mean_commits":81.0,"dds":0.0,"last_synced_commit":"74ba3dd7533563f68f337862b155cda1b080df06"},"previous_names":[],"tags_count":27,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/one19%2Fmarkov-json","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/one19%2Fmarkov-json/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/one19%2Fmarkov-json/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/one19%2Fmarkov-json/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/one19","download_url":"https://codeload.github.com/one19/markov-json/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":231898204,"owners_count":18442790,"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":["javascript","json","markov-chain","no-dependencies","nodejs","npm-package","typescript"],"created_at":"2024-12-30T18:29:57.470Z","updated_at":"2025-09-03T15:31:21.292Z","avatar_url":"https://github.com/one19.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# MARKOV-JSON\n\n[![published on npm!](https://raw.githubusercontent.com/one19/project-status/master/cache/markov-json/npm.svg?sanitize=true)](https://www.npmjs.com/package/markov-json)\n---\n\nA markov generator of 2 depth and variable complexity, made for most human languages. It's made to be really really simple to use!\n\n`npm i markov-json`\n\n```js\n  import fs from 'fs';\n  import Markov from 'markov-json';\n\n  const bookText = fs.readFileSync('./a_big_book.txt');\n\n  const chain1 = new Markov();\n  chain1.train(bookText);\n\n  console.log(chain1.sentence(5));\n  // Outputs words that conform statistically well to book text.\n```\n\n## API:\n| Method | Arguments | Response |\n| --- | --- | --- |\n| `new Markov()` | [?`State`, ?`Options`] | markov object ready to train |\n| `.train` | `string` | void |\n| `.setComplexity` | `number` \u003e= 0 | void |\n| `.sentence` / `.sentences` | `number` | A number of sentences equal to the number asked for. |\n| `.blob` / `.words` | `number` | A number of words equal to the number asked for. |\n| `.output` | ?file_pathname | The internal `State` of the markov chain in JSON format... or a file of JSON at the file name location. |\n\n`State` is the internal state in json format. You can import and export at any time. `Options` are just a bag for `complexity`, which sets the outcome deviation of the model.\n\n\nExamples from [shakespeare](https://shakespeare.mit.edu/hamlet/full.html)\n```js\nma.sentence();\n// `'What, a dew!'`\nma.sentence();\n// `'A king claudius we doubt it was sick almost to see you.'`\nma.sentence(5);\n// `'So hallow\\'d and i pray thee do mine ear that lives must hold my tongue. Hamlet not for thy asking?\n// Marcellus. Horatio a man might be and the extravagant and bed-rid, for so.\n// This portentous figure like a guilty thing to france and thy nighted colour off, colleagued with remembrance of our duty.'`\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fone19%2Fmarkov-json","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fone19%2Fmarkov-json","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fone19%2Fmarkov-json/lists"}