Git Product home page Git Product logo

markov_gen's Introduction

Markov Chain Text Generator

A C++ implementation of a Markov Chain Text Generator that works with both English and German texts.

Features

  • Generates pseudo-random text based on input samples
  • Supports Unicode characters, including German umlauts and รŸ
  • Works with Windows console for proper Unicode display

Key Functions

  • MarkovChain: Main class for the Markov Chain implementation
  • splitIntoWords: Processes input text into individual words
  • generateText: Produces new text based on the built Markov Chain

Core Logic

  1. Text Processing:

    • Split input text into words
    • Convert words to lowercase
    • Handle special characters (e.g., German umlauts)
  2. Building the Markov Chain:

    • Create transitions between consecutive words
    • Store transitions in a map structure
  3. Text Generation:

    • Start with a random or specified word
    • Repeatedly select next words based on transition probabilities
    • Handle dead ends by restarting from a random word
  4. Unicode Handling:

    • Use wide strings (std::wstring) for Unicode support
    • Set Windows console to UTF-16 mode for proper display

How to Compile and Run

Compile (using MinGW-w64 on Windows):

g++ markovChain.cpp -o textgen

Run:

./textgen.exe

Current Limitations

  • First-order Markov Chain (considers only the current word)
  • Input text is currently hardcoded in the program
  • Optimized for Windows console output

Next Steps

  • Implement file I/O for larger input texts
  • Enhance to higher-order Markov Chains for more coherent output
  • Add save/load functionality for Markov Chains
  • Create a user interface for easier interaction

markov_gen's People

Contributors

houmairi avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.