Sha256: 3a45b1dd358e947af08ed977ac9b6b3eb062f01cac4e30fb32f1ab2b84486a36
Contents?: true
Size: 520 Bytes
Versions: 66
Compression:
Stored size: 520 Bytes
Contents
module WordCount exposing (wordCount) import Dict exposing (Dict) import Regex import String wordCount : String -> Dict String Int wordCount sentence = sentence |> String.toLower |> depunctuate |> String.words |> List.foldl (\w d -> Dict.update w incrMaybe d) Dict.empty depunctuate : String -> String depunctuate = Regex.replace Regex.All (Regex.regex "[^a-z0-9 ]") (\_ -> "") incrMaybe : Maybe Int -> Maybe Int incrMaybe maybe = Maybe.withDefault 0 maybe + 1 |> Just
Version data entries
66 entries across 66 versions & 1 rubygems