diff --git a/WetPancake/DataProcessing.fs b/WetPancake/DataProcessing.fs
index 5d2ec76..12b524b 100644
--- a/WetPancake/DataProcessing.fs
+++ b/WetPancake/DataProcessing.fs
@@ -29,6 +29,13 @@
raise (FileNotFoundException("Unable to find the file at the location specified."))
| _ -> ignore
+ let TextContainsValidEndToken (text: string) =
+ match text with
+ | text when text.Contains "." -> true
+ | text when text.Contains "!" -> true
+ | text when text.Contains "?" -> true
+ | _ -> false
+
let SortIntoGroups groupSize text =
SplitText @"\s+" text // Splits text where there is a space.
|> Seq.windowed groupSize
diff --git a/WetPancake/DataServices.fs b/WetPancake/DataServices.fs
index 73dfb3d..d29eeeb 100644
--- a/WetPancake/DataServices.fs
+++ b/WetPancake/DataServices.fs
@@ -93,17 +93,4 @@
|> Array.take noOfSentences
|> ConcatToString
|> ReplaceArtifact " "
- |> TrimEnd [|' '|]
-
- let TextContainsValidEndToken (text: string) =
- let result = text.Contains "." || text.Contains"!" || text.Contains "?"
- match result with
- | true -> true
- | false -> failwith "The text does not contain a valid end token ('.', '!' and/or '?')."
- (*
- match text with
- | text when (text.Contains".") -> true
- | text.Contains "!" -> true
- | text.Contains "?" -> true
- | _ -> failwith "The text does not contain a valid end token ('.', '!' and/or '?')."
- *)
+ |> TrimEnd [|' '|]
\ No newline at end of file
diff --git a/WetPancake/ProductServices.fs b/WetPancake/ProductServices.fs
index 5bba548..dee5c06 100644
--- a/WetPancake/ProductServices.fs
+++ b/WetPancake/ProductServices.fs
@@ -44,6 +44,11 @@ module Pancake =
| :? InvalidOperationException -> return text
}
+ let TextInFileIsValid filePath =
+ async {
+ return DataAccess.LoadFile filePath |> TextContainsValidEndToken
+ }
+
///
/// An asynchronous function which generates random text.
///
@@ -53,7 +58,7 @@ module Pancake =
///
/// This function will produce a maximum of 10 sentences with each function call.
///
- let RequestRandomTextAsync() =
+ let RequestRandomTextAsync () =
async {
let data =
LoadFile (SelectRandomSampleFile())
@@ -147,7 +152,8 @@ module Pancake =
try
GibberishLevelIsValid gibberishLevel |> ignore
SentencesIsValid sentences |> ignore
- FilePathIsValid |> ignore
+ FilePathIsValid filePath |> ignore
+ // pattern match the TextInFileIsValid function
let data =
LoadFile filePath
|> ApplyStandardSetup
diff --git a/WetPancake/Script.fsx b/WetPancake/Script.fsx
index e874ed0..2a03545 100644
--- a/WetPancake/Script.fsx
+++ b/WetPancake/Script.fsx
@@ -115,6 +115,12 @@ let dp_filePathIsValidException =
| :? ArgumentException as ex -> ex.Message
| :? FileNotFoundException as ex -> ex.Message
+let dp_sentences = "This is a test setence." // Edit this to test (valid end token)
+let dp_validEndToken () =
+ let result = TextContainsValidEndToken dp_sentences
+ result
+printfn "Valid End Token: %b" (dp_validEndToken())
+
// Data Structuring
let ds_map = Map.empty
let ds_text = [|"This"; "is"; "a"; "test"; "string."|]
@@ -160,12 +166,6 @@ let dss_clean =
|> RemoveArtefactSentences 6 // Change the no. of sentences to test.
printfn "CLEANED TEXT: %s" dss_clean
-let dss_sentences3 = "This is a test setence?"
-let dss_validEndToken () =
- let result = TextContainsValidEndToken dss_sentences3
- result
-printfn "Valid End Token: %b" (dss_validEndToken())
-
// Product Services (Pancake)
let ps_files = Pancake.RequestAllTemplateFilesAsync ()