mirror of
https://github.com/BinRoot/Haskell-Data-Analysis-Cookbook.git
synced 2024-08-15 17:30:29 +03:00
12 lines
344 B
Haskell
12 lines
344 B
Haskell
import Data.MarkovChain
|
|
import System.Random (mkStdGen)
|
|
|
|
-- Using a Markov chain
|
|
main = do
|
|
rawText <- readFile "big.txt"
|
|
let g = mkStdGen 100
|
|
putStrLn $ "Generated character by character: \n"
|
|
putStrLn $ take 100 $ run 3 rawText 0 g
|
|
putStrLn $ "\nGenerated word by word: \n"
|
|
putStrLn $ unwords $ take 100 $ run 2 (words rawText) 0 g
|