From 589a9c03eeee61b6e1bc9b6ac145c177a59258be Mon Sep 17 00:00:00 2001 From: Akshay Date: Sun, 22 Nov 2020 22:07:48 +0530 Subject: add app config, word generation --- src/Data.elm | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) (limited to 'src/Data.elm') 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 @@ -module Data exposing (punctuations, randomWord, textData) +module Data exposing (defaultConfig, randomParagraph) +import Base exposing (Config) import Random import Utils exposing (listIdx, triple) -type alias Config = - { punctuation : Bool - , capitals : Bool - , length : Int - } +defaultConfig : Config +defaultConfig = + Config True True 50 textData : List String @@ -22,9 +21,9 @@ punctuations = ", ! . ? ... ; :" |> String.split " " -randomBool : Random.Generator Bool -randomBool = - Random.uniform True [ False ] +falseWeightedBool : Random.Generator Bool +falseWeightedBool = + Random.weighted ( 20, True ) [ ( 80, False ) ] randomWord : Config -> Random.Generator ( Int, Bool, Bool ) @@ -35,14 +34,14 @@ randomWord config = punct = if config.punctuation then - randomBool + falseWeightedBool else Random.constant False caps = if config.capitals then - randomBool + falseWeightedBool else Random.constant False -- cgit v1.2.3