sequor 0.7.2 → 0.7.5
raw patch · 8 files changed
+33/−19 lines, 8 filesdep ~text
Dependency ranges changed: text
Files
- Makefile +1/−2
- README.rst +1/−1
- lib/Helper/Text.hs +2/−2
- sequor.cabal +2/−2
- src/NLP/Perceptron/Sequence.hs +12/−6
- src/NLP/Sequor.hs +4/−2
- src/NLP/Sequor/Config.hs +5/−3
- src/sequor.hs +6/−1
Makefile view
@@ -1,8 +1,7 @@ INCLUDES=lib cabal:- runghc Setup.lhs configure --user --prefix=`pwd` --bindir=`pwd`/bin/ &&\- runghc Setup.lhs build && runghc Setup.lhs install + cabal install --user --bindir=`pwd`/bin/ cabal-static: runghc Setup.lhs configure --user --prefix=`pwd` --bindir=`pwd`/bin/ \
README.rst view
@@ -138,7 +138,7 @@ .. [Collins_2002] Collins, Michael. 2002. Discriminative training methods for Hidden Markov Models: Theory and experiments with perceptron- algorithms. EMNLP 2002. http://ir.hit.edu.cn/~car/research/dishmm.pdf+ algorithms. EMNLP 2002. http://www.clic.cs.columbia.edu/~mcollins/papers/tagperc.pdf .. [Chrupala_and_Klakow_2010] Grzegorz Chrupała and Dietrich
lib/Helper/Text.hs view
@@ -53,8 +53,8 @@ type Txt = Text instance Binary Txt where- put = put . encodeUtf8- get = fmap decodeUtf8 get+ put = put . encodeUtf8+ get = fmap decodeUtf8 get splitOn :: Char -> Txt -> [Txt] splitOn c = Prelude.map pack . Utils.splitOn c . unpack
sequor.cabal view
@@ -1,5 +1,5 @@ Name: sequor-Version: 0.7.2+Version: 0.7.5 Description: A sequence labeler based on Collins's sequence perceptron. Synopsis: A sequence labeler based on Collins's sequence perceptron. Homepage: https://bitbucket.org/gchrupala/sequor@@ -34,7 +34,7 @@ vector >= 0.5, array >= 0.2, pretty >= 1.0,- text >= 0.10, + text >= 0.10 && < 1.0, split >= 0.2, nlp-scores >= 0.6.0 Exposed-modules: NLP.Sequor, NLP.Sequor.CoNLL, NLP.Sequor.FeatureTemplate, NLP.Sequor.Config
src/NLP/Perceptron/Sequence.hs view
@@ -54,6 +54,7 @@ , oYs :: [Yi] , oBeam :: !Int , oRate :: !Float+ , oRateDecay :: !Float , oEpochs :: !Int , oFeatBounds :: Maybe (Int,Int) , oStopWinSize :: !Int@@ -87,9 +88,11 @@ return $ Model os ws instance Binary.Binary Options where- put (Options a b c d e f g h i j) = Binary.put a >> Binary.put b >> Binary.put c - >> Binary.put d >> Binary.put e >> Binary.put f- >> Binary.put g >> Binary.put h >> Binary.put i >> Binary.put j+ put (Options a b c d e f g h i j k) = + Binary.put a >> Binary.put b >> Binary.put c + >> Binary.put d >> Binary.put e >> Binary.put f+ >> Binary.put g >> Binary.put h >> Binary.put i + >> Binary.put j >> Binary.put k get = {-# SCC "get2" #-} do a <- Binary.get a == a `seq` return ()@@ -111,7 +114,9 @@ i == i `seq` return () j <- Binary.get j == j `seq` return ()- return $ Options a b c d e f g h i j+ k <- Binary.get+ k == k `seq` return ()+ return $ Options a b c d e f g h i j k yDictFind :: Options -> Xi -> [Yi] yDictFind opts fs = @@ -195,13 +200,14 @@ -> [(X,Y)] -> (STRef s Int, WeightsST s, WeightsST s) -> ST s ()-iter opts _ ss (c,params,params_a) = do+iter opts i ss (c,params,params_a) = do for_ ss $ \ (x,y) -> do params' <- AU.unsafeFreeze params let (y',phi_xy') = decode' opts (params'`dot`) x when (y' /= y) $ do let phi_xy = phi opts x y - update = (phi_xy `minus` phi_xy') `scale` oRate opts+ update = (phi_xy `minus` phi_xy') + `scale` (oRate opts * fromIntegral i ** (- oRateDecay opts)) params `plus_` update c' <- readSTRef c params_a `plus_` (update `scale` fromIntegral c')
src/NLP/Sequor.hs view
@@ -52,8 +52,8 @@ --- | @predict model sentence@ returns the best label sequence for--- sentence. A sentence is a sequence of 'Token's.+-- | @predict model xs@ returns the best label sequence for+-- each sentence in xs. A sentence is a sequence of 'Token's. predict :: ModelData -> [[Token]] -> [[Label]] predict m testdat = let bounds = oFeatBounds . P.options . model $ m@@ -90,6 +90,7 @@ defaultFlags :: Flags defaultFlags = Flags { flagRate = 0.01+ , flagRateDecay = 0.0 , flagBeam = 10 , flagIter = 10 , flagMinFeatCount = 100@@ -172,6 +173,7 @@ , oYs = ys' , oBeam = flagBeam . flags $ conf , oRate = flagRate . flags $ conf+ , oRateDecay = flagRateDecay . flags $ conf , oEpochs = flagIter . flags $ conf , oFeatBounds = bounds , oStopWinSize = flagStopWinSize . flags $ conf
src/NLP/Sequor/Config.hs view
@@ -10,6 +10,7 @@ data Flags = Flags { flagRate :: !Float+ , flagRateDecay :: !Float , flagBeam :: !Int , flagIter :: !Int , flagMinFeatCount :: !Int@@ -28,9 +29,10 @@ } instance B.Binary Flags where- get = do (f1,f2,f3,f4,f5,f6,f7,f8,f9,f10) <- B.get- return $ Flags f1 f2 f3 f4 f5 f6 f7 f8 f9 f10- put (Flags f1 f2 f3 f4 f5 f6 f7 f8 f9 f10) = B.put (f1,f2,f3,f4,f5,f6,f7,f8,f9,f10)+ get = do ((f1,f2,f3,f4,f5,f6,f7,f8,f9,f10),f11) <- B.get+ return $ Flags f1 f2 f3 f4 f5 f6 f7 f8 f9 f10 f11+ put (Flags f1 f2 f3 f4 f5 f6 f7 f8 f9 f10 f11) = + B.put ((f1,f2,f3,f4,f5,f6,f7,f8,f9,f10),f11) instance B.Binary Config where get = let g = B.get
src/sequor.hs view
@@ -13,6 +13,8 @@ , OptDescr(Option), ArgDescr(ReqArg,NoArg)) import NLP.Sequor.Config(Flags(..)) import Text.Printf+import qualified Paths_sequor as Paths +import Data.Version (showVersion) commands :: [(String, CommandSpec Flags)] commands = @@ -20,6 +22,9 @@ [ Option [] ["rate"] (ReqArg (\a o -> o { flagRate = read a }) "NUM (0.01)") "learning rate"+ , Option [] ["rate-decay"]+ (ReqArg (\a o -> o { flagRateDecay = read a }) "NUM (0.0)")+ "learning rate decay" , Option [] ["beam"] (ReqArg (\a o -> o { flagBeam = read a }) "INT (10)") "beam size"@@ -87,7 +92,7 @@ | (i,(err_train, err_dev, ch)) <- zip [(1::Int) ..] scores ] version :: Command Flags -version _ _ = putStrLn "sequor-0.2.2"+version _ _ = putStrLn $ "sequor " ++ showVersion Paths.version help :: Command Flags help _ _ = usage commands msg []