Browse Source

Added try-with block to CleanResult in ProducServices.

Updated the script files for live testing the new code.
Minor editing in comments.
master
Craig Oates 6 years ago
parent
commit
c9327cbef0
  1. 4
      WetPancake/DataServices.fs
  2. 11
      WetPancake/ProductServices.fs
  3. 9
      WetPancake/Script.fsx

4
WetPancake/DataServices.fs

@ -34,7 +34,7 @@
(* Note: Thread.Sleep (Random Number Generation)
==================================================================================================================
Thread.Sleep is needed yield better random numbers. Without it, the same random number tends to be used.
Thread.Sleep is needed to yield better random numbers. Without it, the same random number tends to be used.
When debugging (I.E. the observer effect?), enough time passes for a new random number to generate --
meaning a new seed or "start word" for each sentence.
This isn't ideal but be careful when attempting to remove this line.
@ -83,7 +83,7 @@
With that said, run the generated text through this function if you want "clean" results.
It will mean it will take longer to process the results but it does reduce the chance of incorrect output.
("Incorrect" from the end-users point-of-view.)
The ReplaceArtifact function at the end counteracts the effects of the text splitting.
The ReplaceArtifact function counteracts the effects of the text splitting.
SplitText splits the text and adds a space at the split.
This leads to the text having double-spaces when concatenated back together.
*)

11
WetPancake/ProductServices.fs

@ -33,10 +33,13 @@ module Pancake =
/// </remarks>
let CleanResultAsync noOfSentences text =
async {
let cleanText =
text
|> RemoveArtefactSentences noOfSentences
return cleanText
try
let cleanText =
text
|> RemoveArtefactSentences noOfSentences
return cleanText
with
| :? InvalidOperationException -> return text
}
/// <summary>

9
WetPancake/Script.fsx

@ -157,7 +157,7 @@ printfn "Text: %A" dss_sentences
let dss_sentences2 = "This is a sentence. And, so is this. This shouldn't be here! How about this? No!"
let dss_clean =
dss_sentences2
|> RemoveArtifactSentences 2 // Change the no. of sentences to test.
|> RemoveArtefactSentences 6 // Change the no. of sentences to test.
printfn "CLEANED TEXT: %s" dss_clean
@ -193,9 +193,10 @@ ps_result6 |> Async.RunSynchronously
(* 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)
// ps_result6 // Change this value for one of the above (ps_result1-6)
//|> Async.RunSynchronously
"This is a sentence. And, so is this. This shouldn't be here! How about this? No!"
|> Pancake.CleanResultAsync 6 // This value must not go above the one declared above (ps_resultX)
|> Async.RunSynchronously
printfn "CLEANED TEXT RESULT: %s" ps_cleanText

Loading…
Cancel
Save