|
|
|
@ -1,7 +1,5 @@
|
|
|
|
|
namespace WetPancake |
|
|
|
|
|
|
|
|
|
open System.Linq.Expressions |
|
|
|
|
|
|
|
|
|
module Pancake = |
|
|
|
|
|
|
|
|
|
open SystemServices |
|
|
|
@ -11,6 +9,15 @@ module Pancake =
|
|
|
|
|
open DataServices |
|
|
|
|
open System |
|
|
|
|
|
|
|
|
|
/// <summary> |
|
|
|
|
/// An asynchronous function which generates random text. |
|
|
|
|
/// </summary> |
|
|
|
|
/// <returns> |
|
|
|
|
/// A string of randomly generated text. |
|
|
|
|
/// </returns> |
|
|
|
|
/// <remarks> |
|
|
|
|
/// This function will produce a maximum of 10 sentences with each function call. |
|
|
|
|
/// </remarks> |
|
|
|
|
let RequestRandomTextAsync() = |
|
|
|
|
async { |
|
|
|
|
let data = |
|
|
|
@ -21,6 +28,31 @@ module Pancake =
|
|
|
|
|
return GenerateMarkovText (PickRandomNumber 2 10) data |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/// <summary> |
|
|
|
|
/// An asynchronous function which generates random text. |
|
|
|
|
/// It uses the built-in template (.txt) files as a reference and the parameters specified by the caller. |
|
|
|
|
/// </summary> |
|
|
|
|
/// <param name="gibberishLevel"> |
|
|
|
|
/// Specifies how coherent the generated text is. |
|
|
|
|
/// Min. value = 2. Max. value = 20. |
|
|
|
|
/// The lower the value the more gibberish it will produce. |
|
|
|
|
/// </param> |
|
|
|
|
/// <param name="sentences"> |
|
|
|
|
/// Specifies the number of sentences to generate. |
|
|
|
|
/// </param> |
|
|
|
|
/// <returns> |
|
|
|
|
/// A string of randomly generated text. |
|
|
|
|
/// </returns> |
|
|
|
|
/// <exception cref="System.ArgumentNullException"> |
|
|
|
|
/// Thrown when the "gibberishLevel" is not between 2 and 20. |
|
|
|
|
/// </exception> |
|
|
|
|
/// <exception cref="System.ArgumentNullException"> |
|
|
|
|
/// Thrown when the "sentences" count is less than 1. |
|
|
|
|
/// </exception> |
|
|
|
|
/// <remarks> |
|
|
|
|
/// The higher the “gibberishLevel” and the “sentences” count is the longer it will take to complete the task. |
|
|
|
|
/// Try to make the most of the asynchronous nature of the function as possible. |
|
|
|
|
///</remarks> |
|
|
|
|
let RequestTextAsync (gibberishLevel: int) (sentences: int) = |
|
|
|
|
async { |
|
|
|
|
try |
|
|
|
@ -37,6 +69,44 @@ module Pancake =
|
|
|
|
|
return ex.Message |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/// <summary> |
|
|
|
|
/// An asynchronous function which generates text. |
|
|
|
|
/// It generates the text by using the (.txt) file passed in by the caller (as the reference) and the parameters specified by the caller. |
|
|
|
|
/// </summary> |
|
|
|
|
/// <param name="gibberishLevel"> |
|
|
|
|
/// Specifies how coherent the generated text is. |
|
|
|
|
/// Min. value = 2. Max. value = 20. |
|
|
|
|
/// The lower the value the more gibberish it will produce. |
|
|
|
|
/// </param> |
|
|
|
|
/// <param name="sentences"> |
|
|
|
|
/// Specifies the number of sentences to generate. |
|
|
|
|
/// </param> |
|
|
|
|
/// <param name="filePath"> |
|
|
|
|
/// The path of the (.txt) file the function will use as the reference text. |
|
|
|
|
/// </param> |
|
|
|
|
/// <returns> |
|
|
|
|
/// A string of randomly generated text. |
|
|
|
|
/// </returns> |
|
|
|
|
/// <exception cref="System.ArgumentNullException"> |
|
|
|
|
/// Thrown when the "gibberishLevel" is not between 2 and 20. |
|
|
|
|
/// </exception> |
|
|
|
|
/// <exception cref="System.ArgumentNullException"> |
|
|
|
|
/// Thrown when the "sentences" count is less than 1. |
|
|
|
|
/// </exception> |
|
|
|
|
/// <exception cref="System.FileNotFoundException"> |
|
|
|
|
/// Thrown when the (.txt) file cannot be found. |
|
|
|
|
/// </exception> |
|
|
|
|
/// <exception cref="System.ArgumentNullException"> |
|
|
|
|
/// Thrown when the specified file is not a plain-text (.txt) file. |
|
|
|
|
/// </exception> |
|
|
|
|
/// <remarks> |
|
|
|
|
/// The higher the “gibberishLevel” and the “sentences” count is the longer it will take to complete the task. |
|
|
|
|
/// This, also, applies to the (.txt) file passed into the function. |
|
|
|
|
/// The bigger it is, the longer it will take to read. |
|
|
|
|
/// Try to make the most of the asynchronous nature of the function as possible. |
|
|
|
|
/// Also, the function does not know what is in the (.txt) file until it reads it. |
|
|
|
|
/// Defensive coding should be applied here. |
|
|
|
|
/// </remarks> |
|
|
|
|
let RequestTextFromFileAsync (gibberishLevel: int) (sentences: int) (filePath: string) = |
|
|
|
|
async { |
|
|
|
|
try |
|
|
|
@ -54,6 +124,16 @@ module Pancake =
|
|
|
|
|
return ex.Message |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/// <summary> |
|
|
|
|
/// Finds every available template (.txt) file in Wet Pancake and forms a list of their file paths. |
|
|
|
|
/// </summary> |
|
|
|
|
/// <returns> |
|
|
|
|
/// A list of every template (.txt) file path. |
|
|
|
|
/// </returns> |
|
|
|
|
/// <remarks> |
|
|
|
|
/// You can use the information provided by this function alongside the <see cref=”RequestTextFromFileAsync”>RequestTextFromFileAsync</see> function. |
|
|
|
|
/// This allows you to generate text using a specific template (.txt) file. |
|
|
|
|
/// </remarks > |
|
|
|
|
let RequestAllTemplateFilesAsync () = |
|
|
|
|
async { |
|
|
|
|
let files = |
|
|
|
|