Browse Source

Refactored DataServices file.

Began adding the public function for RemoveArtifactSentences.
master
Craig Oates 6 years ago
parent
commit
b11a29729e
  1. 20
      WetPancake/DataServices.fs
  2. 9
      WetPancake/ProductServices.fs

20
WetPancake/DataServices.fs

@ -12,14 +12,6 @@
ListSampleFiles
|> Array.contains filePath
let RemoveArtifactSentences noOfSentences text =
text
|> SplitText @"(?<=[\.\!\?]\s)"
|> Array.take noOfSentences
|> ConcatToString
|> ReplaceArtifact " "
let rec GenerateMarkovChain (map: Map<string, string List>) (state:string) chain =
if map.ContainsKey state then
let nextChoice = map.[state] |> PickRandomItem
@ -69,8 +61,7 @@
As this NuGet package is about generating random text, this should not be a problem for the most part.
With that said, when this happens, it is an incorrect result -- from the end-users point-of-view.
So, to get a more accurate result, pass the result of this function through the data-cleaner function.
(THE DATA-CLEANER FUNCTION HAS NOT BEEN MADE YET.)
So, to get a more accurate result, pass the result of this function through to the RemoveArtifactSentences function.
*)
let GenerateMarkovText noOfSentences map =
let startWords = fst(SeperateStartWords map)
@ -80,4 +71,11 @@
Thread.Sleep(100)
yield GenerateMarkovSentence map (PickRandomItem startWords).Key
}
result |> ConcatToString
result |> ConcatToString
let RemoveArtifactSentences noOfSentences text =
text
|> SplitText @"(?<=[\.\!\?]\s)"
|> Array.take noOfSentences
|> ConcatToString
|> ReplaceArtifact " "

9
WetPancake/ProductServices.fs

@ -141,4 +141,13 @@ module Pancake =
ListSampleFiles
|> Array.toList
return files
}
// Finish annotating this function when this branch (0.7-p2) is merged back into 0.7-p1.
let CleanResult noOfSentences text =
async {
let cleanText =
text
|> RemoveArtifactSentences noOfSentences
return cleanText
}
Loading…
Cancel
Save