crf-chain1 0.2.1 → 0.2.2
raw patch · 4 files changed
+32/−19 lines, 4 filesdep +vector-th-unboxdep ~basedep ~vector-binaryPVP ok
version bump matches the API change (PVP)
Dependencies added: vector-th-unbox
Dependency ranges changed: base, vector-binary
API changes (from Hackage documentation)
Files
- Data/CRF/Chain1/Dataset/Internal.hs +18/−7
- Data/CRF/Chain1/Model.hs +7/−6
- Data/CRF/Chain1/Train.hs +2/−2
- crf-chain1.cabal +5/−4
Data/CRF/Chain1/Dataset/Internal.hs view
@@ -1,5 +1,9 @@ {-# LANGUAGE GeneralizedNewtypeDeriving #-}+{-# LANGUAGE TemplateHaskell #-}+{-# LANGUAGE MultiParamTypeClasses #-}+{-# LANGUAGE TypeFamilies #-} + module Data.CRF.Chain1.Dataset.Internal ( Ob (..) , Lb (..)@@ -15,23 +19,30 @@ , Ys ) where -import Data.Vector.Generic.Base-import Data.Vector.Generic.Mutable++-- import Data.Vector.Generic.Base+-- import Data.Vector.Generic.Mutable import Data.Binary (Binary) import Data.Ix (Ix) import qualified Data.Vector as V import qualified Data.Vector.Unboxed as U+import Data.Vector.Unboxed.Deriving ++ -- | An observation. newtype Ob = Ob { unOb :: Int }- deriving ( Show, Read, Eq, Ord, Binary- , Vector U.Vector, MVector U.MVector, U.Unbox )+ deriving ( Show, Read, Eq, Ord, Binary )+-- GeneralizedNewtypeDeriving doesn't work for this in 7.8.2:+-- , Vector U.Vector, MVector U.MVector, U.Unbox )+derivingUnbox "Ob" [t| Ob -> Int |] [| unOb |] [| Ob |] + -- | A label. newtype Lb = Lb { unLb :: Int }- deriving ( Show, Read, Eq, Ord, Binary- , Vector U.Vector, MVector U.MVector, U.Unbox- , Num, Ix )+ deriving ( Show, Read, Eq, Ord, Binary, Num, Ix )+derivingUnbox "Lb" [t| Lb -> Int |] [| unLb |] [| Lb |]+ -- | Simple word represented by a list of its observations. newtype X = X { _unX :: U.Vector Ob }
Data/CRF/Chain1/Model.hs view
@@ -1,4 +1,7 @@ {-# LANGUAGE GeneralizedNewtypeDeriving #-}+{-# LANGUAGE TemplateHaskell #-}+{-# LANGUAGE MultiParamTypeClasses #-}+{-# LANGUAGE TypeFamilies #-} -- | Internal implementation of the CRF model. @@ -29,14 +32,16 @@ import qualified Data.Vector.Unboxed as U import qualified Data.Vector as V import qualified Data.Number.LogFloat as L+import Data.Vector.Unboxed.Deriving import Data.CRF.Chain1.Dataset.Internal import Data.CRF.Chain1.Feature -- | A feature index. To every model feature a unique index is assigned. newtype FeatIx = FeatIx { unFeatIx :: Int }- deriving ( Show, Eq, Ord, Binary- , G.Vector U.Vector, G.MVector U.MVector, U.Unbox )+ deriving ( Show, Eq, Ord, Binary) + -- , G.Vector U.Vector, G.MVector U.MVector, U.Unbox )+derivingUnbox "FeatIx" [t| FeatIx -> Int |] [| unFeatIx |] [| FeatIx |] -- | A label and a feature index determined by that label. type LbIx = (Lb, FeatIx)@@ -182,10 +187,6 @@ sgValue :: Model -> Lb -> L.LogFloat sgValue crf (Lb x) = case unFeatIx (sgIxsV crf U.! x) of- -- FIXME: shoule not be -Infinity? It looks like it doesn't- -- matter much for know, because that value is ignored anyway,- -- but the SFeature which is not a member of the model- -- should have probability of 0. -1 -> 0 ix -> L.logToLogFloat (values crf U.! ix)
Data/CRF/Chain1/Train.hs view
@@ -77,9 +77,9 @@ | doneTotal k == doneTotal (k - 1) = putStr "." | Just dataSet <- evalDataM = do let x = accuracy (crf { values = para }) dataSet- putStrLn ("\n" ++ "[" ++ show (doneTotal k) ++ "] f = " ++ show x)+ putStrLn ("\n" ++ "[" ++ show (doneTotal k) ++ "] acc = " ++ show x) | otherwise =- putStrLn ("\n" ++ "[" ++ show (doneTotal k) ++ "] f = #")+ putStrLn ("\n" ++ "[" ++ show (doneTotal k) ++ "] acc = #") where doneTotal :: Int -> Int doneTotal = floor . done
crf-chain1.cabal view
@@ -1,5 +1,5 @@ name: crf-chain1-version: 0.2.1+version: 0.2.2 synopsis: First-order, linear-chain conditional random fields description: The library provides efficient implementation of the first-order,@@ -32,11 +32,12 @@ , random , parallel , logfloat- , monad-codec >= 0.2 && < 0.3+ , monad-codec >= 0.2 && < 0.3 , binary- , vector-binary+ , vector-binary >= 0.1 && < 0.2 , data-lens- , sgd >= 0.2.1 && < 0.3+ , sgd >= 0.2.1 && < 0.3+ , vector-th-unbox >= 0.2.1 && < 0.3 exposed-modules: Data.CRF.Chain1