|
|
|
@ -8,7 +8,7 @@
|
|
|
|
|
|
|
|
|
|
let rec GenerateMarkovChain (map: Map<string, string List>) (state:string) chain = |
|
|
|
|
if map.ContainsKey state then |
|
|
|
|
let nextChoice = map.[state] |> PickNextWord |
|
|
|
|
let nextChoice = map.[state] |> PickRandomItem |
|
|
|
|
if MatchText @"\." nextChoice then nextChoice :: chain |
|
|
|
|
else |
|
|
|
|
let currentWords = |
|
|
|
@ -26,34 +26,18 @@
|
|
|
|
|
|> List.rev |
|
|
|
|
|> ConcatToString |
|
|
|
|
|
|
|
|
|
(* Thread.Sleep is needed for a new random number to generate. |
|
|
|
|
Without it, the same sentence tends to repeat itself. |
|
|
|
|
When debugging (I.E. the observer effect), |
|
|
|
|
enough time passes for a new random number to generate -- |
|
|
|
|
meaning a new seed or "start word" for each sentence. |
|
|
|
|
This isn't ideal but needed so please be careful when attempting to remove this line. *) |
|
|
|
|
let GenerateMarkovText noOfSentences map = |
|
|
|
|
let startWords = fst(SeperateStartWords map) |
|
|
|
|
let result = |
|
|
|
|
seq { |
|
|
|
|
for i in 1 .. noOfSentences do |
|
|
|
|
(*Thread.Sleep is needed for a new random number to generate. |
|
|
|
|
Without it, the same sentence tends to repeat itself. |
|
|
|
|
When debugging (I.E. the observer effect), |
|
|
|
|
enough time passes for a new random number to generate -- |
|
|
|
|
meaning a new seed or "start word" for each sentence. |
|
|
|
|
This isn't ideal but needed so please be careful when attempting to |
|
|
|
|
remove this line.*) |
|
|
|
|
Thread.Sleep(100) |
|
|
|
|
yield GenerateMarkovSentence map (PickRandomItem startWords).Key |
|
|
|
|
} |
|
|
|
|
result |> ConcatToString |
|
|
|
|
|
|
|
|
|
(* |
|
|
|
|
YOU ARE UP TO HERE! |
|
|
|
|
My hunch is I need to validate the startwords collection. |
|
|
|
|
If the startwords is empty, the key generated from it will not be found in the map of possible results to append on to the initial word in startwords. |
|
|
|
|
*) |
|
|
|
|
let GenerateMarkovTextTesting noOfSentences map = |
|
|
|
|
let startWords = fst(SeperateStartWords map) |
|
|
|
|
let result = |
|
|
|
|
seq { |
|
|
|
|
for i in 1 .. noOfSentences do |
|
|
|
|
Thread.Sleep(100) |
|
|
|
|
yield GenerateMarkovSentence map (PickRandomItem startWords).Key |
|
|
|
|
} |
|
|
|
|
result |> ConcatToString |