aboutsummaryrefslogtreecommitdiff
path: root/src/Data.elm
diff options
context:
space:
mode:
Diffstat (limited to 'src/Data.elm')
-rw-r--r--src/Data.elm21
1 files changed, 10 insertions, 11 deletions
diff --git a/src/Data.elm b/src/Data.elm
index c3e71ae..95c92c1 100644
--- a/src/Data.elm
+++ b/src/Data.elm
@@ -1,14 +1,13 @@
1module Data exposing (punctuations, randomWord, textData) 1module Data exposing (defaultConfig, randomParagraph)
2 2
3import Base exposing (Config)
3import Random 4import Random
4import Utils exposing (listIdx, triple) 5import Utils exposing (listIdx, triple)
5 6
6 7
7type alias Config = 8defaultConfig : Config
8 { punctuation : Bool 9defaultConfig =
9 , capitals : Bool 10 Config True True 50
10 , length : Int
11 }
12 11
13 12
14textData : List String 13textData : List String
@@ -22,9 +21,9 @@ punctuations =
22 ", ! . ? ... ; :" |> String.split " " 21 ", ! . ? ... ; :" |> String.split " "
23 22
24 23
25randomBool : Random.Generator Bool 24falseWeightedBool : Random.Generator Bool
26randomBool = 25falseWeightedBool =
27 Random.uniform True [ False ] 26 Random.weighted ( 20, True ) [ ( 80, False ) ]
28 27
29 28
30randomWord : Config -> Random.Generator ( Int, Bool, Bool ) 29randomWord : Config -> Random.Generator ( Int, Bool, Bool )
@@ -35,14 +34,14 @@ randomWord config =
35 34
36 punct = 35 punct =
37 if config.punctuation then 36 if config.punctuation then
38 randomBool 37 falseWeightedBool
39 38
40 else 39 else
41 Random.constant False 40 Random.constant False
42 41
43 caps = 42 caps =
44 if config.capitals then 43 if config.capitals then
45 randomBool 44 falseWeightedBool
46 45
47 else 46 else
48 Random.constant False 47 Random.constant False