diff options
author | Akshay <[email protected]> | 2020-11-22 16:37:48 +0000 |
---|---|---|
committer | Akshay <[email protected]> | 2020-11-22 16:37:48 +0000 |
commit | 589a9c03eeee61b6e1bc9b6ac145c177a59258be (patch) | |
tree | 022b87b2a254423fb0f39ebc108207078e92d1c4 /src/Data.elm | |
parent | 19a06028be67598e718ea13daa65dd82576ee8f4 (diff) |
add app config, word generation
Diffstat (limited to 'src/Data.elm')
-rw-r--r-- | src/Data.elm | 21 |
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 @@ | |||
1 | module Data exposing (punctuations, randomWord, textData) | 1 | module Data exposing (defaultConfig, randomParagraph) |
2 | 2 | ||
3 | import Base exposing (Config) | ||
3 | import Random | 4 | import Random |
4 | import Utils exposing (listIdx, triple) | 5 | import Utils exposing (listIdx, triple) |
5 | 6 | ||
6 | 7 | ||
7 | type alias Config = | 8 | defaultConfig : Config |
8 | { punctuation : Bool | 9 | defaultConfig = |
9 | , capitals : Bool | 10 | Config True True 50 |
10 | , length : Int | ||
11 | } | ||
12 | 11 | ||
13 | 12 | ||
14 | textData : List String | 13 | textData : List String |
@@ -22,9 +21,9 @@ punctuations = | |||
22 | ", ! . ? ... ; :" |> String.split " " | 21 | ", ! . ? ... ; :" |> String.split " " |
23 | 22 | ||
24 | 23 | ||
25 | randomBool : Random.Generator Bool | 24 | falseWeightedBool : Random.Generator Bool |
26 | randomBool = | 25 | falseWeightedBool = |
27 | Random.uniform True [ False ] | 26 | Random.weighted ( 20, True ) [ ( 80, False ) ] |
28 | 27 | ||
29 | 28 | ||
30 | randomWord : Config -> Random.Generator ( Int, Bool, Bool ) | 29 | randomWord : 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 |