| International Journal of Computer Applications |
| Foundation of Computer Science (FCS), NY, USA |
| Volume 187 - Number 66 |
| Year of Publication: 2025 |
| Authors: Ahmad Farhan AlShammari |
10.5120/ijca2025926115
|
Ahmad Farhan AlShammari . Implementation of Text Generation using Markov Chains in Python. International Journal of Computer Applications. 187, 66 ( Dec 2025), 35-40. DOI=10.5120/ijca2025926115
The goal of this research is to implement text generation using Markov chains in Python. Text generation is the process of creating a new text by analyzing the input text and then predicting the new words. It is used to make posts, reviews, reports, stories, poems, summaries, etc. Markov chains is a mathematical method used to predict the next state based on the current state. The text is generated by randomly selecting the new words based on their probabilities (or weights). The basic steps of text generation using Markov chains are explained: reading file, cleaning text, creating words, creating chains, computing frequency, computing transition probability, generating text, and printing generated text. The developed program was tested on an experimental text. The program has successfully performed the basic steps of text generation using Markov chains and provided the required results.