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.
 
 

126 lines
3.7 KiB

// Learn more about F# at http://fsharp.org
// See the 'F# Tutorial' project for more help.
#load "SystemServices.fs"
#load "DataAccess.fs"
#load "DataCleaning.fs"
#load "DataProcessing.fs"
#load "DataStructuring.fs"
#load "DataServices.fs"
#load "ProductServices.fs"
open System
open SystemServices
open DataAccess
open DataCleaning
open DataProcessing
open DataStructuring
open DataServices
open WetPancake
// System Services
let ss_number = PickRandomNumber 10
let ss_item =
let items = seq {1 .. 10}
PickRandomItem items
// Data Access
let da_sampleFilePath = CreateSampleTextFilesPath
let da_sampleTextFiles = FindSampleTextFiles da_sampleFilePath
let da_sampleFiles = ListSampleFiles
let da_randomSampleFile = SelectRandomSampleFile()
let da_file = LoadFile da_randomSampleFile
// Data Cleaning
let dc_replace1 = ReplaceArtifact "\"" "dc_repl1 \" end."
let dc_replace2 = ReplaceArtifact "\n\nIn" "dc_repl2 \n\nIn end."
let dc_replace3 = ReplaceArtifact "\r" "dc_repl3 \r end."
let dc_replace4 = ReplaceArtifact "\n" "dc_repl4 \n end."
let dc_replace5 =
let testPath = "a1 \" a2 \n\nIn a3 \r a4 \n end."
testPath
|> ReplaceArtifact "\""
|> ReplaceArtifact "\n\nIn"
|> ReplaceArtifact "\r"
|> ReplaceArtifact "\n"
let dc_split = SplitText @"\s+" "This is a test string."
// Data Processing
let dp_isStart = MatchText @"^[A-Z]" "This is a test"
let dp_isEnd = MatchText @"\." "and the end is nigh."
let dp_failStart = MatchText @"^[A-Z]" "somewhere in the middle"
let dp_failEnd = MatchText @"\." "this is not the end"
let dp_words =
let words = ["This"; "is"; "a"; "test"; "."]
ConcatToString words
let dp_words2 =
let words = "This is a test. And has serveral words in it."
SortIntoGroups 2 words
|> Seq.toList
let dp_bisect =
let words = [|"This"; "is"; "a"; "test"; "."; "Contains"; "text"; "."|]
BisectWords words
let dp_combine =
let prev = "This is the previous"
let next = "this is the next"
CombineWords prev next
let dp_combine2 =
let prev = " "
let next = "Prev is whitespace"
CombineWords prev next
let dp_combine3 =
let prev = "Next is empty"
let next = ""
CombineWords prev next
let dp_combine4 =
let prev = "Next is null"
let next = null
CombineWords prev next
// Data Structuring
let ds_map = Map.empty
let ds_text = [|"This"; "is"; "a"; "test"; "string."|]
let ds_map2 =
let text = BisectWords ds_text
let result = UpdateMap ds_map (fst(text)) (snd(text))
result
let ds_map3 = ConstructMap ds_map ds_text
let ds_text2 = [
[|"This"; "is"; "the"; "first"; "test"; "string."|]
[|"This"; "is"; "the"; "first"; "test"; "string."|]
[|"this"; "is"; "the"; "second"; "test"; "string"|]
[|"this"; "is"; "the"; "third"; "test"; "string"|]
]
let ds_map4 = ConstructMap ds_map ds_text2.[1]
let ds_map5 = [for i in ds_text2 -> ConstructMap ds_map i]
let ds_map6 =
let result =
[for item in ds_map5 do
for i in item -> i]
result
let ds_map7 =
let result =
[for item in ds_map5 -> SeperateStartWords item]
result
let ds_map7Item = ds_map7.Item(0)
// Data Services
let dss_text =
LoadFile (SelectRandomSampleFile())
|> ReplaceArtifact "\""
|> ReplaceArtifact "\n\nIn"
|> ReplaceArtifact "\r"
|> ReplaceArtifact "\n"
|> SplitText @"\s+"
|> ConcatToString
|> SortIntoGroups 2
|> GenerateMap
let dss_startwords = SeperateStartWords dss_text
let dss_sentences = GenerateMarkovText 2 dss_text
printfn "Text: %A" dss_sentences
// (WetPancake) Pancake
let p_result = Pancake.RequestRandomText()
let p_result2 = Pancake.RequestText 5 10
let p_result3 = Pancake.RequestTextFromFile 3 10 "D:\Developer\Wet-Pancake\WetPancake\TextFiles\desktop-clock-info.txt"