-
Notifications
You must be signed in to change notification settings - Fork 0
/
Tests.hs
36 lines (29 loc) · 1.03 KB
/
Tests.hs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
{-# LANGUAGE TemplateHaskell #-}
import NLP.Tokenizer
import Test.QuickCheck
import Test.QuickCheck.All
import qualified Data.Text as T
import Data.Text (Text)
import Control.Applicative
prop_placeholder () = True
main = $quickCheckAll
newtype Word = Word { unWord :: Text }
deriving (Show)
newtype Sentence = Sentence { unSentence :: Text }
deriving (Show)
newtype Document = Document { unDocument :: Text }
deriving (Show)
instance Arbitrary Word where
-- TODO: use a bigger dictionary
arbitrary = Word <$> do
elements $ map T.pack $ ["foo", "bar", "baz"]
instance Arbitrary Sentence where
arbitrary = Sentence <$> do
words <- map unWord <$> arbitrary :: Gen [Text]
-- TODO: capitalize the first one, sprinkle in some punctuation.
return $ T.intercalate (T.pack " ") words
instance Arbitrary Document where
arbitrary = Document <$> do
sentences <- map unSentence <$> arbitrary
-- TODO: make paragraphs
return $ T.intercalate (T.pack " ") sentences