Browse Source

Updated README with basic running information

master
Denis Thiessen 1 year ago
parent
commit
909400957c
  1. 8
      README.md
  2. 2
      sentence_generator.hs

8
README.md

@ -1,3 +1,9 @@
# RandomSentenceGenerator
A basic random sentence generator using Markov Chains.
A basic random sentence generator using Markov Chains.
## How to run
First you need to supply a file called *text.txt* in the same directory as the final compiled program.
Compile the program with a compiler like *ghc*. ("stack ghc sentence_generator.hs")
Last, run this program with the length of the randomly generated sentence as a command line argument.

2
sentence_generator.hs

@ -59,7 +59,7 @@ main = do
-- We first retrieve the sentence length
sentenceLength <- getIntArg
-- Then the words from the given text, which serve as a basis for the Markov Chain
contents <- readFile "test.txt"
contents <- readFile "text.txt"
-- To generate our sentence we use our text content, build a Markov Chain, and then use it to generate our random sentence by using the chain to repeatedly add random words from our Markov Chain.
let text = words contents
chain = buildChain text

Loading…
Cancel
Save