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.
23 lines
655 B
23 lines
655 B
module internal DataStructuring |
|
|
|
open DataProcessing |
|
|
|
let UpdateMap (map:Map<_,_>) key value = |
|
if map.ContainsKey key then |
|
let exisitingValue = map.[key] |
|
let map = map |> Map.remove key |
|
map |> Map.add key (value :: exisitingValue) |
|
else |
|
map.Add (key, [value]) |
|
|
|
// Not the best name... |
|
let ConstructMap map text = |
|
BisectWords text ||> UpdateMap map |
|
|
|
let GenerateMap<'a> = Seq.fold ConstructMap Map.empty |
|
|
|
let SeperateStartWords map = |
|
let startWords = |
|
map |
|
|> Map.partition (fun k _ -> MatchText @"^[A-Z]" k) |
|
startWords
|
|
|