The purpose of this repository is to provide a way for people to generate random "placeholder text" -- with a Markov Chain.
https://www.craigoates.net/Software/project/12
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
28 lines
792 B
28 lines
792 B
module Helpers |
|
|
|
open System.Text.RegularExpressions |
|
open System |
|
|
|
// The main aim of these functions is to reduce code in the unit and property tests. |
|
// You will most-likely find them in the "contents" tests (for unit and property). |
|
|
|
let CountSentences text = |
|
let count = |
|
Regex.Split(text, @"(?<=[\.\!\?]\s)") |
|
|> Array.length |
|
count |
|
|
|
let EndsAsIntended (text: string) = |
|
match text.Chars (text.Length - 1) with |
|
| '.' -> true |
|
| '!' -> true |
|
| '?' -> true |
|
| _ -> false |
|
|
|
|
|
let RandomBool () = |
|
let x = Random().Next(100) |
|
match x with |
|
| x when x % 2 <> 0 -> false |
|
| x when x % 2 = 0 -> true |
|
| _ -> failwith "Unable to generate a random bool." |