Last active
December 21, 2015 00:24
-
-
Save cpdean/fbee06b6a7a2d90a28fc to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type DocumentBody = Raw String | Words List String | |
tokenize: DocumentBody -> List String | |
tokenize s = | |
case s of | |
Raw str_body -> String.split " " str_body |> (List.map String.toLower) | |
Words list_body -> List.map String.toLower list_body | |
-- Tests | |
tests = | |
suite "Tokenizer" | |
[ test "simple" <| assertEqual ["this", "is", "a", "simple", "string"] | |
<| tokenize (Raw "this is a simple string") | |
, test "downcasing tokens: string" <| assertEqual ["foo", "bar"] | |
<| tokenize (Raw "FOO BAR") | |
, test "downcasing tokens: list of str" <| assertEqual ["foo", "bar"] | |
<| tokenize (Words ["Foo", "BAR"]) | |
] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment