Git Product home page Git Product logo

markov_text_gen's Introduction

Markov text generator

A Markov chain-based text randomizer written in Haskell

How do I get this to run?

Compile with ghc randomizer.hs and run with ./randomizer <input file> <sentence count>. If you're on Windows, converting these commands to Windows command prompt commands shouldn't be too hard.

What does it do?

The program reads the text file you give as its argument and compiles a statistic of how often words follow after other words (aka counts word pairs). It then builds sentences not unlike a Markov chain, using a weighted choice algorithm to choose the following words in the sentence. The first word of every sentence is the only word that is chosen without considering weight. A sentence ends when the generator picks a word that ends with a '.', '!' or a '?'. You control how many sentences it generates with the sentence count parameter.

That's cool and all, but what does it actually do?

In this repository, you'll find a couple of test files you can run the program with to see what it does. The following files are present:

  • hgttg.txt - a chapter from the Hitchhiker's Guide to the Galaxy
  • trump.txt - a speech Donald Trump made in September 2017 during his first United Nations address
  • cuni.txt - a brief excerpt from the history of the Charles University
  • simple.txt - two simple sentences, there are only a couple of sentences that can actually be generated
  • empty.txt - in case you want to try to break my program and/or don't know how to make an empty file

made as part of my non-procedural programming lab at MFF CUNI

markov_text_gen's People

Contributors

yawnston avatar

Watchers

 avatar  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.