Browse Source

Added abilty to generate text by specifying a particular template file.

Script file udated to test out by hand.
master
Craig Oates 6 years ago
parent
commit
9f82b6c6f6
  1. 5
      WetPancake/DataServices.fs
  2. 10
      WetPancake/ProductServices.fs
  3. 31
      WetPancake/Script.fsx

5
WetPancake/DataServices.fs

@ -6,6 +6,11 @@
open DataCleaning
open System.Threading
open System
open DataAccess
let CheckFileExists filePath =
ListSampleFiles
|> Array.contains filePath
let rec GenerateMarkovChain (map: Map<string, string List>) (state:string) chain =
if map.ContainsKey state then

10
WetPancake/ProductServices.fs

@ -1,5 +1,7 @@
namespace WetPancake
open System.Linq.Expressions
module Pancake =
open SystemServices
@ -38,7 +40,7 @@ module Pancake =
return GenerateMarkovText sentences data
}
let RequestAllTextFiles () =
let RequestAllTextFilesAsync () =
async {
let files =
ListSampleFiles
@ -46,6 +48,12 @@ module Pancake =
return files
}
let RequestTextFromTemplateAsync (gibberishLevel: int) (sentences: int) (templateFilePath: string) =
match CheckFileExists templateFilePath with
| true -> RequestTextFromFileAsync gibberishLevel sentences templateFilePath
| false -> failwith "The template file can not be found."
// Add Checks to make sure the client is passing in a .txt file?
// Leave for the client to check?
// Give the client a function to check (and throw) if not handed a .txt file?

31
WetPancake/Script.fsx

@ -131,18 +131,23 @@ let WordGenerator = __SOURCE_DIRECTORY__ + @"\TextFiles\word-generator.txt"
[<Literal>]
let TestPost = __SOURCE_DIRECTORY__ + @"\TextFiles\test-post.txt"
let p_result = Pancake.RequestRandomTextAsync()
let p_result2 = Pancake.RequestTextAsync 5 10
let p_result3 = Pancake.RequestTextFromFileAsync 3 10 DesktopClock
let p_result4 = Pancake.RequestTextFromFileAsync 3 10 ConsoleWaterworks
let p_result5 = Pancake.RequestTextFromFileAsync 3 10 WordGenerator
let p_result6 = Pancake.RequestTextFromFileAsync 3 10 TestPost
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_result5 = Pancake.RequestTextFromFileAsync 3 10 WordGenerator
let ps_result6 = Pancake.RequestTextFromFileAsync 3 10 TestPost
p_result |> Async.RunSynchronously
p_result2 |> Async.RunSynchronously
p_result3 |> Async.RunSynchronously
p_result4 |> Async.RunSynchronously
p_result5 |> Async.RunSynchronously
p_result6 |> Async.RunSynchronously
let ps_files = Pancake.RequestAllTextFilesAsync ()
let p_files = Pancake.RequestAllTextFiles () |> Async.RunSynchronously
ps_result1 |> Async.RunSynchronously
ps_result2 |> Async.RunSynchronously
ps_result3 |> Async.RunSynchronously
ps_result4 |> Async.RunSynchronously
ps_result5 |> Async.RunSynchronously
ps_result6 |> Async.RunSynchronously
let ps_templateFiles = ps_files |> Async.RunSynchronously
let ps_templateResult7 =
Pancake.RequestTextFromTemplateAsync 3 10 ps_templateFiles.[2]
|> Async.RunSynchronously
Loading…
Cancel
Save