The purpose of this repository is to provide a way for people to generate random "placeholder text" -- with a Markov Chain. https://www.craigoates.net/Software/project/12
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

26 lines
840 B

module internal MapProcessing
open TextProcessing
open System
let SeperateStartWords map =
let startWords =
map
|> Map.partition (fun k _ -> IsStartOfSentence k)
fst startWords
let rec MarkovChain currentWords (map: Map<string, string list>) sentence =
let nextChoice = map.[currentWords] |> GetRandomWord
if IsEndOfSentence nextChoice then nextChoice :: sentence
else
let currentState =
currentWords
|> SplitIntoWords
|> Seq.skip 1
|> JoinWords
MarkovChain (CombineWords currentState nextChoice) map (nextChoice :: sentence)
let GetMarkovSentence startWords map =
MarkovChain startWords map [startWords]
|> List.rev
|> JoinWords