@ -21,6 +21,7 @@ module Pancake =
return GenerateMarkovText (PickRandomNumber 2 10 ) d a t a
}
// TODO: Write tests for the validation checks (throws e x c e p t i o n s )
let RequestTextAsync (gibberishLevel: int) (sentences: int) =
async {
t r y
@ -32,22 +33,37 @@ module Pancake =
|> SortIntoGroups g i b b e r i s h L e v e l
|> G e n e r a t e M a p
return GenerateMarkovText sentences d a t a
else return raise (ArgumentException("Invalid argument. Must be greater than 0 . ", " s e n t e n c e s " ) )
e l s e
return raise (ArgumentException("Invalid argument. Must be greater than 0 . ", " s e n t e n c e s " ) )
e l s e
return raise (ArgumentException("Invalid argument. Must be between 2 and 20 (inclusive).", " g i b b e r i s h L e v e l " ) )
w i t h
| :? ArgumentException as e x - >
| :? ArgumentException as ex - >
return e x . M e s s a g e
}
// TODO: Write tests for the validation checks (throws e x c e p t i o n s )
let RequestTextFromFileAsync (gibberishLevel: int) (sentences: int) (filePath: string) =
async {
let data =
LoadFile f i l e P a t h
|> A p p l y S t a n d a r d S e t u p
|> SortIntoGroups g i b b e r i s h L e v e l
|> G e n e r a t e M a p
return GenerateMarkovText sentences d a t a
t r y
if GibberishLevelIsValid gibberishLevel t h e n
if SentencesIsValid sentences t h e n
if FilePathIsValid filePath t h e n
let data =
LoadFile f i l e P a t h
|> A p p l y S t a n d a r d S e t u p
|> SortIntoGroups g i b b e r i s h L e v e l
|> G e n e r a t e M a p
return GenerateMarkovText sentences d a t a
e l s e
return raise (ArgumentException("Invalid argument. File must be a . txt file and include a valid file path.", " f i l e P a t h " ) )
e l s e
return raise (ArgumentException("Invalid argument. Must be greater than 0 . ", " s e n t e n c e s " ) )
e l s e
return raise (ArgumentException("Invalid argument. Must be between 2 and 20 (inclusive).", " g i b b e r i s h L e v e l " ) )
w i t h
| :? ArgumentException as ex - >
return e x . M e s s a g e
}
let RequestAllTemplateFilesAsync () =