Browse Source

Added the "clean" functions to the script and wrote comments, highlighting the differences.

master
Craig Oates 6 years ago
parent
commit
e36dc5bc8e
  1. 4
      WetPancake/ProductServices.fs
  2. 57
      WetPancake/Script.fsx

4
WetPancake/ProductServices.fs

@ -153,10 +153,6 @@ module Pancake =
return files
}
// ============================================================================================
// DO NOT FORGET TO WRITE TESTS FOR THESE TWO FUNCTIONS -- OR THE CLEANING FUNCTION ABOVE --
// ============================================================================================
// TODO: Add XML comment for RequestCleanTextAsync.
let RequestCleanTextAsync (gibberishLevel: int) (sentences: int) =
async {

57
WetPancake/Script.fsx

@ -162,13 +162,26 @@ printfn "CLEANED TEXT: %s" dss_clean
// Product Services (Pancake)
let ps_files = Pancake.RequestAllTemplateFilesAsync ()
ps_files |> Async.RunSynchronously
(* Basic Text Generation
======================================================================================================================
These functions produce text which does not go through the "cleaning" process.
This means the results here are prone to producing an extra sentence on the (very) odd occassion.
As a general rule, it tends to happen when the gibberish-level is set to one of the higher values.
(High gibberish-level values generates "more" coherent sentences).
It is caused when the start-word is itself a sentence, and the text generation loop has not started.
For more information, see the GenerateMarkovText function in DataServices.fs.
The reason you would use these functions ove the "Clean Text Generation" function below is these are faster to finish.
If you can tolerate the occasional extra bit of text and the functions below are too slow, you use these functions.
*)
let ps_result1 = Pancake.RequestRandomTextAsync()
let ps_result2 = Pancake.RequestTextAsync 5 10
let ps_result3 = Pancake.RequestTextFromFileAsync 3 10 DesktopClock
let ps_result4 = Pancake.RequestTextFromFileAsync 3 10 ConsoleWaterworks
let ps_result3 = Pancake.RequestTextFromFileAsync 3 10 ConsoleWaterworks
let ps_result4 = Pancake.RequestTextFromFileAsync 3 10 DesktopClock
let ps_result5 = Pancake.RequestTextFromFileAsync 3 10 WordGenerator
let ps_result6 = Pancake.RequestTextFromFileAsync 3 10 TestPost
let ps_files = Pancake.RequestAllTemplateFilesAsync ()
ps_result1 |> Async.RunSynchronously
ps_result2 |> Async.RunSynchronously
@ -176,6 +189,40 @@ ps_result3 |> Async.RunSynchronously
ps_result4 |> Async.RunSynchronously
ps_result5 |> Async.RunSynchronously
ps_result6 |> Async.RunSynchronously
ps_files |> Async.RunSynchronously
// TODO: Add code to play/test the "cleaning" functions.
(* This function is made public so users can clean the text manually.
For the most part, this function should not be called.
*)
let ps_cleanText =
ps_result6 // Change this value for one of the above (ps_result1-6)
|> Async.RunSynchronously
|> Pancake.CleanResultAsync 5 // This value must not go above the one declared above (ps_resultX)
|> Async.RunSynchronously
printfn "CLEANED TEXT RESULT: %s" ps_cleanText
(* Clean Text Generation
======================================================================================================================
These functions produce text which have gone through the "clean" process.
This means the results will go through an extra step and remove any erroneous sentences.
This is unlike the "Basic Text Generation" functions above.
The trade-off here is these functions can be slower to finish executing.
If you need your results to match the number of sentences you requested exactly, you should use these functions.
This, also, applies if you can tolerate the extra processing time.
*)
let ps_cleanResult1 = Pancake.RequestCleanTextAsync 5 10
let ps_cleanResult2 = Pancake.RequestCleanTextFromFileAsync 3 10 ConsoleWaterworks
let ps_cleanResult3 = Pancake.RequestCleanTextFromFileAsync 3 10 DesktopClock
let ps_cleanResult4 = Pancake.RequestCleanTextFromFileAsync 3 10 WordGenerator
let ps_cleanResult5 = Pancake.RequestCleanTextFromFileAsync 3 10 TestPost
ps_cleanResult1 |> Async.RunSynchronously
ps_cleanResult2 |> Async.RunSynchronously
ps_cleanResult3 |> Async.RunSynchronously
ps_cleanResult4 |> Async.RunSynchronously
ps_cleanResult5 |> Async.RunSynchronously
let ps_cleanText2 =
ps_cleanResult1 // Change the number for printing result below (E.G. ps_cleanResult1, ps_cleanResult4...)
|> Async.RunSynchronously
printfn "CLEAN TEXT RESULT: %s" ps_cleanText2
Loading…
Cancel
Save