Browse Source

Added a fold function to the map generation process.

This reduces the nested maps, lists and whetever else I was working with up to this point.
master
Craig Oates 6 years ago
parent
commit
1b82abd5fc
  1. 19
      WetPancake/DataServices.fs
  2. 3
      WetPancake/DataStructuring.fs
  3. 15
      WetPancake/Script.fsx

19
WetPancake/DataServices.fs

@ -3,13 +3,20 @@
open SystemServices
open System
let PickStartWord words =
let word = PickRandomItem (Random().Next) words
word
let PickStartWord words = PickRandomItem (Random().Next) words
let PutMarkovTogether map words =
let rec GenerateMarkovChain (map: Map<string, string List> List) state chain =
let nextChoice = map.[state]
nextChoice
//"Not done yet"
let GenerateSentence map start =
let test = GenerateMarkovChain map start [start]
let result = "Not done yet"
result
let GenerateMarkovSentence map startWord =
PutMarkovTogether map [startWord]
let GenerateMarkovSentences sentences map startWords =
seq {
for i in 1 .. sentences do
yield GenerateSentence map (PickStartWord startWords)
}

3
WetPancake/DataStructuring.fs

@ -10,9 +10,12 @@
else
map.Add (key, [value])
// Not the bast name...
let ConstructMap map text =
BisectWords text ||> UpdateMap map
let GenerateMap<'a> = Seq.fold ConstructMap Map.empty
let SeperateStartWords map =
let startWords =
map

15
WetPancake/Script.fsx

@ -114,12 +114,9 @@ let dss_text =
|> SplitText @"\s+"
|> ConcatToString
|> SortIntoPairs 6
|> Seq.toList
let dss_map = [for item in dss_text -> ConstructMap Map.empty item]
let dss_startwords = [for item in dss_map -> SeperateStartWords item]
let dss_sentence =
seq {
for i in 1 .. 4 do
yield GenerateMarkovSentence dss_map (PickStartWord dss_startwords)
}
|> Seq.toList
|> GenerateMap
let dss_startword = PickStartWord dss_startwords
let dss_startword2 = snd(dss_startword)
dss_startword2.["see"]
let dds_startword3 = dss_map.[0]
//let dss_sentences = GenerateMarkovSentences 4 dss_map dss_startwords
Loading…
Cancel
Save