chatter 0.5.0.2 → 0.5.1.0
raw patch · 13 files changed
+100/−88 lines, 13 filesdep +tastydep +tasty-ant-xmldep +tasty-hunitdep −test-frameworkdep −test-framework-hunitdep −test-framework-quickcheck2PVP ok
version bump matches the API change (PVP)
Dependencies added: tasty, tasty-ant-xml, tasty-hunit, tasty-quickcheck
Dependencies removed: test-framework, test-framework-hunit, test-framework-quickcheck2, test-framework-skip
API changes (from Hackage documentation)
Files
- changelog.md +6/−0
- chatter.cabal +6/−6
- tests/src/AvgPerceptronTests.hs +3/−3
- tests/src/BackoffTaggerTests.hs +3/−3
- tests/src/Data/DefaultMapTests.hs +3/−3
- tests/src/IntegrationTests.hs +36/−28
- tests/src/Main.hs +18/−19
- tests/src/NLP/Extraction/ParsecTests.hs +3/−3
- tests/src/NLP/POS/UnambiguousTaggerTests.hs +5/−5
- tests/src/NLP/POSTests.hs +3/−3
- tests/src/NLP/Similarity/VectorSimTests.hs +3/−4
- tests/src/NLP/TypesTests.hs +3/−3
- tests/src/TestUtils.hs +8/−8
changelog.md view
@@ -1,3 +1,9 @@+= 0.5.1.0 =++ - Moved to Tasty from test-framework. I'm treating this as a+ c-level patch because it may have siginficant impact on the+ transitive dependencies.+ = 0.5.0.2 = - removed upper vesion bounds on many dependencies.
chatter.cabal view
@@ -1,5 +1,5 @@ name: chatter-version: 0.5.0.2+version: 0.5.1.0 synopsis: A library of simple NLP algorithms. description: chatter is a collection of simple Natural Language Processing algorithms.@@ -201,15 +201,15 @@ text, HUnit, parsec >= 3.1.5,- test-framework,- test-framework-skip,- test-framework-quickcheck2,- test-framework-hunit, tokenize, QuickCheck, filepath, cereal, quickcheck-instances,- containers+ containers,+ tasty,+ tasty-quickcheck,+ tasty-hunit,+ tasty-ant-xml ghc-options: -Wall -auto-all -caf-all
tests/src/AvgPerceptronTests.hs view
@@ -4,8 +4,8 @@ import Control.Applicative ((<$>)) import Test.QuickCheck ( Arbitrary(..), (==>), Property ) import Test.QuickCheck.Instances ()-import Test.Framework.Providers.QuickCheck2 (testProperty)-import Test.Framework ( testGroup, Test )+import Test.Tasty (TestTree, testGroup)+import Test.Tasty.QuickCheck (testProperty) import Data.Serialize (encode, decode) import Data.Map (Map)@@ -13,7 +13,7 @@ import NLP.ML.AvgPerceptron -tests :: Test+tests :: TestTree tests = testGroup "AvgPerceptron" [ testGroup "Encoding tests" [ testProperty "Features round-trip" prop_featureRoundtrips
tests/src/BackoffTaggerTests.hs view
@@ -2,8 +2,8 @@ module BackoffTaggerTests where import Test.HUnit ( (@=?), Assertion )-import Test.Framework ( testGroup, Test )-import Test.Framework.Providers.HUnit (testCase)+import Test.Tasty (TestTree, testGroup)+import Test.Tasty.HUnit (testCase) import Data.Map (Map) import qualified Data.Map as Map@@ -14,7 +14,7 @@ import qualified NLP.POS.LiteralTagger as LT -tests :: Test+tests :: TestTree tests = testGroup "Backoff Tagging" [ testCase "Simple back-off tagging" testLiteralBackoff ]
tests/src/Data/DefaultMapTests.hs view
@@ -1,14 +1,14 @@ module Data.DefaultMapTests where import Test.QuickCheck.Instances ()-import Test.Framework.Providers.QuickCheck2 (testProperty)-import Test.Framework ( testGroup, Test )+import Test.Tasty (TestTree, testGroup)+import Test.Tasty.QuickCheck (testProperty) import Data.Serialize (decode, encode) import Data.DefaultMap (DefaultMap(..)) -tests :: Test+tests :: TestTree tests = testGroup "NLP.Data.DefaultMapTests" [ testGroup "Serialize / Deserialize Tests" [ testProperty "DefaultMap round-trips" prop_defMapSerialize
tests/src/IntegrationTests.hs view
@@ -5,9 +5,10 @@ ---------------------------------------------------------------------- import Test.QuickCheck.Instances ()-import Test.Framework.Providers.HUnit (testCase)-import Test.Framework ( testGroup, Test, buildTest ) import Test.HUnit (Assertion, assertFailure, assertEqual )+import Test.Tasty (TestTree, testGroup, withResource)+import Test.Tasty.HUnit (testCase)+import Test.HUnit ( (@=?) ) ---------------------------------------------------------------------- import Data.Text (Text) import qualified Data.Map as Map@@ -23,32 +24,39 @@ import qualified NLP.Corpora.Brown as B import qualified NLP.Corpora.Conll as C -import TestUtils--tests :: Test-tests = buildTest $ do- brown <- brownTagger :: IO (POSTagger B.Tag)- def <- defaultTagger :: IO (POSTagger C.Tag)- return $ testGroup "Integration Tests"- [ testGroup "Default Tagger" $- map (genTest $ tagText def)- [ ("Simple 1", "The dog jumped.", "The/DT dog/NN jumped/VBD ./.")- ]- , testGroup "Brown Tagger" $- map (genTest $ tagText brown)- [ ("Simple 1", "The dog jumped.", "The/AT dog/NN jumped/VBD ./.")- ]- , testGroup "POS Serialization" $- map (testSerialization examples)- [ ("Average Perceptron", Avg.mkTagger Avg.emptyPerceptron Nothing)- , ("Unambiguous", UT.mkTagger Map.empty Nothing)- , ("Literal", LT.mkTagger Map.empty Sensitive Nothing)- , ("Unambiguous -> Avg"- , UT.mkTagger Map.empty- (Just $ Avg.mkTagger Avg.emptyPerceptron Nothing))- ]- ]+genTestM :: (Show b, Show c, Eq c) => IO tgr -> (tgr -> b -> c) -> (String, b, c) -> TestTree+genTestM genTgr fn (descr, input, oracle) =+ testCase (descr++" [input: "++show input++"]") $ do+ tgr <- genTgr+ assert tgr+ where assert tgr = oracle @=? fn tgr input +tests :: TestTree+tests = withResource loadTaggers (\_ -> return ()) $ \getTaggers ->+ testGroup "Integration Tests"+ [ testGroup "Default Tagger" $+ map (genTestM (snd `fmap` getTaggers) tagText)+ [ ("Simple 1", "The dog jumped.", "The/DT dog/NN jumped/VBD ./.")+ ]+ , testGroup "Brown Tagger" $+ map (genTestM (fst `fmap` getTaggers) tagText)+ [ ("Simple 1", "The dog jumped.", "The/AT dog/NN jumped/VBD ./.")+ ]+ , testGroup "POS Serialization" $+ map (testSerialization examples)+ [ ("Average Perceptron", Avg.mkTagger Avg.emptyPerceptron Nothing)+ , ("Unambiguous", UT.mkTagger Map.empty Nothing)+ , ("Literal", LT.mkTagger Map.empty Sensitive Nothing)+ , ("Unambiguous -> Avg"+ , UT.mkTagger Map.empty+ (Just $ Avg.mkTagger Avg.emptyPerceptron Nothing))+ ]+ ]+ where+ loadTaggers = do+ brown <- brownTagger :: IO (POSTagger B.Tag)+ def <- defaultTagger :: IO (POSTagger C.Tag)+ return (brown, def) examples :: [Text] examples = [ "This/dt is/bez a/at test/nn ./."@@ -59,7 +67,7 @@ testSerialization :: [Text] -- ^ A training corpus. One sentence per entry. -> ( String -- ^ The name of the POS tagger. , POSTagger B.Tag) -- ^ An empty (untrained) POS tagger.- -> Test+ -> TestTree testSerialization training (name, newTagger) = testCase name doTest where doTest :: Assertion
tests/src/Main.hs view
@@ -4,14 +4,14 @@ import Data.Text (Text) import qualified Data.Text as T-import qualified Data.Text.IO as T import Test.HUnit ( (@=?) )-import Test.QuickCheck ()-import Test.Framework.Providers.QuickCheck2 (testProperty)-import Test.Framework.Providers.HUnit (testCase)-import Test.Framework ( buildTest, testGroup, Test, defaultMain )--- import Test.Framework.Skip (skip)+import Test.Tasty.QuickCheck (testProperty)+import Test.Tasty.HUnit (testCase)+import Test.Tasty ( TestTree, defaultIngredients, defaultMainWithIngredients+ , testGroup )+import Test.Tasty.Ingredients (Ingredient )+import Test.Tasty.Runners.AntXML ( antXMLRunner ) import NLP.Types (Tag(..), parseTag, RawTag(..), POSTagger(..)) import NLP.POS (tagText, train)@@ -37,10 +37,15 @@ import Corpora main :: IO ()-main = defaultMain tests+main = defaultMainWithIngredients ingredients tests -tests :: [Test]-tests = [ testGroup "parseTag" $+ingredients :: [Ingredient]+ingredients = antXMLRunner : defaultIngredients+++tests :: TestTree+tests = testGroup "Tests"+ [ testGroup "parseTag" $ [ testProperty "basic tag parsing" prop_parseTag] , testGroup "Train and tag" [ testGroup "miniCorpora1" $@@ -73,13 +78,7 @@ , Tree.tests ] --trainAndTagTestFileCorpus :: FilePath -> (Text, Text) -> Test-trainAndTagTestFileCorpus file args = buildTest $ do- corpus <- T.readFile file- return $ trainAndTagTest corpus args--trainAndTagTestIO :: IO Text -> (Text, Text) -> Test+trainAndTagTestIO :: IO Text -> (Text, Text) -> TestTree trainAndTagTestIO corpora (input, oracle) = testCase (T.unpack input) $ do let parser :: Text -> RawTag parser = parseTag@@ -88,7 +87,7 @@ tagger = (APT.mkTagger perceptron Nothing) oracle @=? tagText tagger input -trainAndTagTest :: Text -> (Text, Text) -> Test+trainAndTagTest :: Text -> (Text, Text) -> TestTree trainAndTagTest corpora (input, oracle) = testCase (T.unpack input) $ do let parser :: Text -> RawTag parser = parseTag@@ -97,7 +96,7 @@ tagger = (APT.mkTagger perceptron Nothing) oracle @=? tagText tagger input -trainAndTagTestVTrainer :: Text -> (Text, Text) -> Test+trainAndTagTestVTrainer :: Text -> (Text, Text) -> TestTree trainAndTagTestVTrainer corpora (input, oracle) = testCase (T.unpack input) $ do let newTagger :: POSTagger RawTag newTagger = APT.mkTagger APT.emptyPerceptron Nothing@@ -109,7 +108,7 @@ prop_parseTag :: Text -> Bool prop_parseTag txt = parseTag txt == RawTag txt -genTest :: (Show a, Show b, Eq b) => (a -> b) -> (String, a, b) -> Test+genTest :: (Show a, Show b, Eq b) => (a -> b) -> (String, a, b) -> TestTree genTest fn (descr, input, oracle) = testCase (descr++" input: "++show input) assert where assert = oracle @=? fn input
tests/src/NLP/Extraction/ParsecTests.hs view
@@ -7,8 +7,8 @@ ---------------------------------------------------------------------- import Test.QuickCheck ((==>), Property) import Test.QuickCheck.Instances ()-import Test.Framework.Providers.QuickCheck2 (testProperty)-import Test.Framework ( testGroup, Test )+import Test.Tasty (TestTree, testGroup)+import Test.Tasty.QuickCheck (testProperty) ---------------------------------------------------------------------- import Text.Parsec.Prim (parse) ----------------------------------------------------------------------@@ -19,7 +19,7 @@ import TestUtils -tests :: Test+tests :: TestTree tests = testGroup "NLP.Extraction.Parsec" [ testProperty "posTok extraction" prop_posTok , testProperty "anyToken" prop_anyToken
tests/src/NLP/POS/UnambiguousTaggerTests.hs view
@@ -2,10 +2,10 @@ module NLP.POS.UnambiguousTaggerTests where import Test.HUnit ( (@=?) )-import Test.Framework ( testGroup, Test )-import Test.Framework.Providers.HUnit (testCase) import Test.QuickCheck ()-import Test.Framework.Providers.QuickCheck2 (testProperty)+import Test.Tasty (TestTree, testGroup)+import Test.Tasty.HUnit (testCase)+import Test.Tasty.QuickCheck (testProperty) import qualified Data.Map as Map import Data.Text (Text)@@ -15,7 +15,7 @@ import NLP.POS import qualified NLP.POS.UnambiguousTagger as UT -tests :: Test+tests :: TestTree tests = testGroup "NLP.POS.UnambiguousTagger" [ testProperty "basic tag parsing" prop_emptyAlwaysUnk , testGroup "Initial training" $ map (trainAndTagTest emptyTagger)@@ -42,7 +42,7 @@ prop_emptyAlwaysUnk input = all (\(POS y _) -> y == tagUNK) (concatMap unTS $ tag emptyTagger inputTxt) where inputTxt = T.pack input -trainAndTagTest :: Tag t => POSTagger t -> (Text, Text, Text) -> Test+trainAndTagTest :: Tag t => POSTagger t -> (Text, Text, Text) -> TestTree trainAndTagTest tgr (exs, input, oracle) = testCase (T.unpack (T.intercalate ": " [exs, input])) $ do trained <- trainText tgr exs oracle @=? tagText trained input
tests/src/NLP/POSTests.hs view
@@ -1,9 +1,9 @@ {-# LANGUAGE OverloadedStrings #-} module NLP.POSTests where -import Test.Framework ( testGroup, Test ) import Test.QuickCheck.Instances ()-import Test.Framework.Providers.QuickCheck2 (testProperty)+import Test.Tasty (TestTree, testGroup)+import Test.Tasty.QuickCheck (testProperty) import qualified Data.Map as Map @@ -13,7 +13,7 @@ import TestUtils -tests :: Test+tests :: TestTree tests = testGroup "NLP.POS" [ testGroup "Evaluation" $ map (genTestF $ eval mamalTagger) [ ("Half", [ TaggedSent [ (POS (RawTag "DT") "the"), (POS (RawTag "NN") "cat")]
tests/src/NLP/Similarity/VectorSimTests.hs view
@@ -3,9 +3,8 @@ import Test.QuickCheck ( Property, (==>) ) import Test.QuickCheck.Property ()-import Test.Framework.Providers.QuickCheck2 (testProperty)-import Test.Framework ( testGroup, Test)--- import Test.Framework.Skip (skip)+import Test.Tasty (TestTree, testGroup)+import Test.Tasty.QuickCheck (testProperty) import qualified Data.Text as T @@ -14,7 +13,7 @@ import TestUtils -tests :: Test+tests :: TestTree tests = testGroup "Vector Sim" [ -- testGroup "Dot Products" $ map (genTestF2 dotProd) -- [ ("3-4-5", [1,3,-5], [4, -2, -1], 3)
tests/src/NLP/TypesTests.hs view
@@ -1,14 +1,14 @@ module NLP.TypesTests where import Test.QuickCheck.Instances ()-import Test.Framework.Providers.QuickCheck2 (testProperty)-import Test.Framework ( testGroup, Test )+import Test.Tasty (TestTree, testGroup)+import Test.Tasty.QuickCheck (testProperty) import Data.Serialize (decode, encode) import NLP.Types (Corpus(..)) -tests :: Test+tests :: TestTree tests = testGroup "NLP.Types" [ testGroup "Serialize / Deserialize Tests" [ testProperty "Corpus round-trips" prop_corpusSerialize
tests/src/TestUtils.hs view
@@ -3,15 +3,15 @@ import Control.Monad (unless) import Test.HUnit ( (@=?), Assertion, assertFailure )-import Test.Framework.Providers.HUnit (testCase)-import Test.Framework (Test)+import Test.Tasty.HUnit (testCase)+import Test.Tasty (TestTree) -- | Not available until Base 4.7 or greater: isRight :: Either a b -> Bool isRight (Left _) = False isRight (Right _) = True -genTestF2 :: (Show a, Show b) => (a -> b -> Double) -> (String, a, b, Double) -> Test+genTestF2 :: (Show a, Show b) => (a -> b -> Double) -> (String, a, b, Double) -> TestTree genTestF2 fn (descr, in1, in2, oracle) = testCase (descr++" [input: "++show in1++"," ++show in2++"]") assert where assert = assertApproxEquals "" 0.001 oracle $ fn in1 in2@@ -19,7 +19,7 @@ genTest3 :: (Show a, Show b, Show c, Show d, Eq d) => (a -> b -> c -> d) -> (String, a, b, c, d)- -> Test+ -> TestTree genTest3 fn (descr, in1, in2, in3, oracle) = testCase (descr++" [input: "++show in1++"," ++show in2++"," ++show in3++"]") assert where assert = oracle @=? fn in1 in2 in3@@ -27,22 +27,22 @@ genTestF3 :: (Show a, Show b, Show c) => (a -> b -> c -> Double) -> (String, a, b, c, Double)- -> Test+ -> TestTree genTestF3 fn (descr, in1, in2, in3, oracle) = testCase (descr++" [input: "++show in1++"," ++show in2++"," ++show in3++"]") assert where assert = assertApproxEquals "" 0.001 oracle $ fn in1 in2 in3 -genTest2 :: (Show a, Show b, Show c, Eq c) => (a -> b -> c) -> (String, a, b, c) -> Test+genTest2 :: (Show a, Show b, Show c, Eq c) => (a -> b -> c) -> (String, a, b, c) -> TestTree genTest2 fn (descr, in1, in2, oracle) = testCase (descr++" [input: "++show in1++"," ++show in2++"]") assert where assert = oracle @=? fn in1 in2 -genTest :: (Show a, Show b, Eq b) => (a -> b) -> (String, a, b) -> Test+genTest :: (Show a, Show b, Eq b) => (a -> b) -> (String, a, b) -> TestTree genTest fn (descr, input, oracle) = testCase (descr++" [input: "++show input++"]") assert where assert = oracle @=? fn input -genTestF :: Show a => (a -> Double) -> (String, a, Double) -> Test+genTestF :: Show a => (a -> Double) -> (String, a, Double) -> TestTree genTestF fn (descr, input, oracle) = testCase (descr++" [input: "++show input++"]") assert where assert = assertApproxEquals "" 0.001 oracle $ fn input