{"id":19682221,"url":"https://github.com/nchinling/markov_sentence_constructor","last_synced_at":"2026-01-30T20:31:59.980Z","repository":{"id":221863022,"uuid":"755546150","full_name":"nchinling/markov_sentence_constructor","owner":"nchinling","description":"Sentence generator app using Markov chain","archived":false,"fork":false,"pushed_at":"2024-02-16T09:49:30.000Z","size":141,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-06-16T04:23:09.491Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"HTML","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/nchinling.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":"2024-02-10T14:45:34.000Z","updated_at":"2024-02-14T13:55:33.000Z","dependencies_parsed_at":"2025-02-27T06:43:16.078Z","dependency_job_id":"3b7026f2-2581-47ff-9c0a-c550147386ef","html_url":"https://github.com/nchinling/markov_sentence_constructor","commit_stats":null,"previous_names":["nchinling/markov_sentence_constructor"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/nchinling/markov_sentence_constructor","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nchinling%2Fmarkov_sentence_constructor","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nchinling%2Fmarkov_sentence_constructor/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nchinling%2Fmarkov_sentence_constructor/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nchinling%2Fmarkov_sentence_constructor/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nchinling","download_url":"https://codeload.github.com/nchinling/markov_sentence_constructor/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nchinling%2Fmarkov_sentence_constructor/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28918451,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-30T20:25:28.696Z","status":"ssl_error","status_checked_at":"2026-01-30T20:25:13.426Z","response_time":66,"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":"2024-11-11T18:09:58.032Z","updated_at":"2026-01-30T20:31:59.964Z","avatar_url":"https://github.com/nchinling.png","language":"HTML","funding_links":[],"categories":[],"sub_categories":[],"readme":"#  Markov Sentence Generator app\n\n## About the app\nA Markov sentence generator is a type of algorithm used to generate sentences based on statistical patterns observed in a given corpus of text. The algorithm relies on Markov chains, which are mathematical models that describe a sequence of possible events in which the probability of each event depends on the state attained in the preceding event. A Markov chain can be used to model the likelihood of transitioning from one word to another based on the words that precede it in a given text.\n\nThe generator constructs a Markov chain by recording the frequency of word transitions. For example, if the word \"cat\" frequently follows the word \"the\" in the input text, the generator assigns a higher probability to that transition in the Markov chain.\n\nTo generate a sentence, the generator starts with a randomly selected word and uses the Markov chain to probabilistically select the next word based on the preceding word. This process continues until a predetermined stopping condition is met, such as reaching a provided sentence length. \n\n## Features\n\n### 1. Train Model\n- Users can provide paragraphs of text to train the text generation model.\n- The paragraphs are preprocessed to remove unwanted characters, leading/trailing whitespace, and are converted to lowercase.\n- The trained data is stored in a SQLite database.\n\n### 2. Generate Text\n- Users can generate text based on the trained model.\n- The text generation process starts with a random word from the trained data and iteratively predicts the next word using a Markov Chain model until the desired length of the text is achieved.\n- The generated text is capitalised and ends with a full-stop.\n\n\n## Components\n\n### 1. Flask Application\n- The core of the application built using Flask, a Python web framework.\n- Consists of routes for training the model, generating text, and serving HTML templates.\n\n### 2. SQLite Database\n- Stores the trained data in a relational database.\n- The database schema includes tables for storing word frequencies.\n\n### 3. Text Generation Logic\n- Implemented using Markov Chain modeling.\n- Chooses the next word based on the frequency of occurrence in the trained data.\n\n## Usage\n\n1. **Training the Model**\n   - Navigate to the '/train' route.\n   - Provide a paragraph of text in the input field and submit.\n   - Trained data will be stored in the database.\n\n2. **Generating Text**\n   - Visit the '/generate' route.\n   - Optionally specify the desired length of the generated text.\n   - Click on the \"Generate\" button.\n   - The app will generate text based on the trained model and display it on the page.\n\n## Dependencies\n\n- Flask: Web framework for building the application.\n- SQLite3: Database management system for storing trained data.\n- Random: Python module for selecting random words.\n- Collections: Provides specialised datatypes.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnchinling%2Fmarkov_sentence_constructor","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnchinling%2Fmarkov_sentence_constructor","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnchinling%2Fmarkov_sentence_constructor/lists"}