Browse Source

Merge pull request #12 from CraigOates/0.7-p2

0.7 p2
master
Craig Oates 6 years ago committed by GitHub
parent
commit
040428eb14
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 15
      WetPancake/DataServices.fs
  2. 9
      WetPancake/ProductServices.fs
  3. 5
      WetPancake/Script.fsx

15
WetPancake/DataServices.fs

@ -12,7 +12,6 @@
ListSampleFiles
|> Array.contains filePath
let rec GenerateMarkovChain (map: Map<string, string List>) (state:string) chain =
if map.ContainsKey state then
let nextChoice = map.[state] |> PickRandomItem
@ -20,7 +19,7 @@
else
let currentWords =
state
|> SplitText @"\s+"
|> SplitText "\s+"
|> Seq.skip 1
|> ConcatToString
GenerateMarkovChain map (CombineWords currentWords nextChoice) (nextChoice :: chain)
@ -62,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)
@ -73,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
}

5
WetPancake/Script.fsx

@ -154,6 +154,11 @@ let dss_text =
let dss_startwords = SeperateStartWords dss_text
let dss_sentences = GenerateMarkovText 2 dss_text
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.
printfn "CLEANED TEXT: %s" dss_clean
// Product Services (Pancake)

Loading…
Cancel
Save