sequor 0.2.2 → 0.2.3
raw patch · 20 files changed
+420/−407 lines, 20 files
Files
- README +1/−0
- lib/Aux/Atom.hs +0/−88
- lib/Aux/Commands.hs +0/−62
- lib/Aux/ListZipper.hs +0/−76
- lib/Aux/Text.hs +0/−111
- lib/Aux/Utils.hs +0/−44
- lib/Helper/Atom.hs +88/−0
- lib/Helper/Commands.hs +62/−0
- lib/Helper/ListZipper.hs +76/−0
- lib/Helper/Text.hs +123/−0
- lib/Helper/Utils.hs +44/−0
- sequor.cabal +3/−3
- src/Config.hs +1/−1
- src/CorpusReader.hs +4/−4
- src/FeatureTemplate.hs +2/−2
- src/Features.hs +5/−5
- src/Hashable.hs +1/−1
- src/Labeler.hs +5/−5
- src/Main.hs +3/−3
- src/Perceptron/Sequence.hs +2/−2
README view
@@ -111,3 +111,4 @@ For more examples see files all.features and example.features in the directory data.+
− lib/Aux/Atom.hs
@@ -1,88 +0,0 @@-{-# LANGUAGE GeneralizedNewtypeDeriving - , NoMonomorphismRestriction - , BangPatterns #-}-module Aux.Atom - ( MonadAtoms (..)- , AtomTable (..)- , Atoms- , AtomsT- , empty- , evalAtoms- , evalAtomsT- , runAtoms- , runAtomsT- )-where-import Control.Monad.State-import Control.Monad.Identity-import qualified Data.Map as Map-import qualified Data.IntMap as IntMap-import qualified Data.Binary as B-import qualified Aux.Text as Text-type Txt = Text.Txt---data AtomTable = T { lastID :: !Int - , to :: Map.Map Txt Int - , from :: IntMap.IntMap Txt } - deriving (Eq,Show)---instance B.Binary AtomTable where- put t = do B.put (lastID t) - B.put (to t)- B.put (from t)- get = do liftM3 T B.get B.get B.get---class Monad m => MonadAtoms m where- toAtom :: Txt -> m Int- maybeToAtom :: Txt -> m (Maybe Int)- fromAtom :: Int -> m Txt- table :: m AtomTable--instance Monad m => MonadAtoms (AtomsT m) where- toAtom x = AtomsT $ do- t <- get- case Map.lookup x (to t) of- Just j -> return $! j- Nothing -> do - let i = lastID t- i' = i + 1 - !t' = t { lastID = i'- , to = Map.insert x i (to t) - , from = IntMap.insert i x (from t) }- put t'- return $! lastID t-- maybeToAtom x = - AtomsT $ do- t <- get- return . Map.lookup x . to $ t- - fromAtom i = AtomsT $ do- t <- get- return $ (from t) IntMap.! i- table = AtomsT get--empty :: AtomTable-empty = T 0 Map.empty IntMap.empty--runAtomsT :: AtomsT t t1 -> AtomTable -> t (t1, AtomTable)-runAtomsT (AtomsT x) s = runStateT x s--runAtoms :: Atoms t -> AtomTable -> (t, AtomTable)-runAtoms (Atoms x) s = runIdentity (runAtomsT x s)---evalAtoms :: Atoms t -> t-evalAtoms = fst . flip runAtoms empty--evalAtomsT :: (Monad m) => AtomsT m a -> m a-evalAtomsT = liftM fst . flip runAtomsT empty--newtype AtomsT m r = AtomsT (StateT AtomTable m r)- deriving (Functor,Monad,MonadTrans,MonadIO)--newtype Atoms r = Atoms (AtomsT Identity r)- deriving (Functor,Monad,MonadAtoms)
− lib/Aux/Commands.hs
@@ -1,62 +0,0 @@-module Aux.Commands - ( Command- , CommandName- , Help- , CommandSpec (..)- , module System.Console.GetOpt- , defaultMain- , usage- )-where-import Text.PrettyPrint(renderStyle,render,nest,vcat,hsep,style- ,Mode(..),mode,text,(<>),($$),($+$),(<+>))-import System.Console.GetOpt-import System.Environment (getArgs)-import System.IO (stderr,hPutStr)-import qualified Data.List as List---type Command opts = (opts -> [String] -> IO ())-type CommandName = String-type Help = String-data CommandSpec opts = CommandSpec (Command opts)- Help - [OptDescr (opts -> opts)]- [String]--defaultMain :: opts -> [(String, CommandSpec opts)] -> String -> IO ()-defaultMain def commands header = do- args <- getArgs- let theUsage = usage commands header- case args of- [] -> theUsage []- command:opts -> case List.lookup command commands of- Nothing -> theUsage ["Invalid command: " ++ command]- Just spec -> runCommand theUsage def spec opts--runCommand :: ([String] -> IO ()) - -> opts - -> CommandSpec opts - -> [String] - -> IO ()-runCommand theUsage def (CommandSpec command help optDesc argnames) args = - case getOpt Permute optDesc args of- (o,n,[] ) -> command (foldr ($) def o) n- (_,_,errs) -> theUsage errs--usage :: [(String, CommandSpec t)] -> String -> [String] -> IO ()-usage commands header errs = hPutStr stderr . render - $ vcat (List.map text errs)- $$ usageMsg commands header--usageMsg commands header = - text header- $+$ (vcat (List.map commandUsage commands))--commandUsage (name , CommandSpec command help optionDesc args) = - text name <> text ":"- $$ (nest 10 (text help))- $$ (text name <+> text (if null optionDesc then "" else "[OPTION...]")- <+> hsep (map text args))- <+> (nest 10 (text $ usageInfo "" optionDesc))-
− lib/Aux/ListZipper.hs
@@ -1,76 +0,0 @@-module Aux.ListZipper - ( - ListZipper(..)- , focus- , left- , right- , reset- , fromList- , toZippers- , toList- , next- , atEnd - , at- )-where-import Data.Maybe-import Data.Monoid-import Data.Foldable (Foldable,foldMap)---data ListZipper a = LZ [a] (Maybe a) [a] deriving (Show,Eq,Ord)--left :: ListZipper a -> [a]-left (LZ xs _ _) = xs--focus :: ListZipper a -> Maybe a-focus (LZ _ x _) = x--right :: ListZipper a -> [a]-right (LZ _ _ ys) = ys--fromList [] = LZ [] Nothing [] -fromList (x:xs) = LZ [] (Just x) xs--toZippers xs = let zs = iterate next . fromList $ xs- in map snd . zip xs $ zs--toList (LZ xs (Just x) ys) = reverse xs ++ [x] ++ ys-toList (LZ xs Nothing []) = reverse xs--next :: ListZipper a -> ListZipper a-next = nextWith id id-nextWith f g (LZ lxs (Just x) rxs) =- case rxs of- y:ys -> LZ (f x:lxs) (Just (g y)) ys- [] -> LZ (f x:lxs) Nothing []--atEnd :: ListZipper a -> Bool-atEnd = isNothing . focus--reset (LZ [] (Just y) ys) = LZ [] (Just y) ys-reset (LZ [] Nothing []) = LZ [] Nothing []-reset (LZ xs (Just y) ys) = LZ [] (Just z) (zs++[y]++ys)- where z:zs = reverse xs -reset (LZ xs Nothing []) = LZ [] (Just z) zs- where z:zs = reverse xs--from :: (Monoid m) => Maybe m -> m-from Nothing = mempty-from (Just x) = x--index 1 (x:xs) = Just x-index i [] = Nothing-index i (x:xs) = index (i-1) xs--at :: (Monoid m) => ListZipper m -> Int -> m-at z 0 = from . focus $ z-at z i | i < 0 = from . index (negate i) . left $ z-at z i = from . index i . right $ z--instance Functor ListZipper where- fmap f (LZ ls x rs) = LZ (fmap f ls) (fmap f x) (fmap f rs) -instance Foldable ListZipper where- foldMap f (LZ ls x rs) = mconcat $ fmap f (reverse ls) - ++ [from $ fmap f x] ++ fmap f rs-
− lib/Aux/Text.hs
@@ -1,111 +0,0 @@-{-# LANGUAGE OverloadedStrings - , TypeSynonymInstances - #-}-module Aux.Text - ( Txt- , module Data.Text.Lazy- , module Data.Text.Lazy.Encoding- , splitOn- , show- , read- , reads- , readDouble- , readInt- , normalize- , fromString- , toString- , getContents- , readFile - , writeFile - , putStr - , putStrLn - , interact - , hPutStr - , hPutStrLn- )- where-import Data.Text.Lazy hiding (splitOn)-import Data.Text.Lazy.Encoding-import Data.Text.Lazy.Read-import System.IO (Handle)-import qualified Data.Text.Lazy.IO as IO-import qualified Data.ByteString.Lazy.Char8 as ByteString-import qualified Data.Text as Strict-import Data.Binary-import qualified Aux.Utils as Utils-import Prelude hiding ( show- , reverse- , map- , read- , reads- , getContents- , readFile - , writeFile - , putStr - , putStrLn - , interact - )-import qualified Prelude--type Txt = Text--instance Binary Txt where- put = put . encodeUtf8- get = fmap decodeUtf8 get--splitOn :: Char -> Txt -> [Txt]-splitOn c = Prelude.map pack . Utils.splitOn c . unpack--show :: (Show a) => a -> Txt-show = pack . Prelude.show--read :: (Read a) => Txt -> a-read = Prelude.read . unpack--reads :: (Read a) => Txt -> [(a,Txt)]-reads = Prelude.map (\ (r,s) -> (r,pack s)) . Prelude.reads . unpack--readDouble :: Txt -> Double -readDouble t = case double t of- Right (d,"") -> d- Left err -> error err--readInt :: Txt -> Int-readInt t = case decimal t of- Right (d,"") -> d- Left err -> error err--fromString :: String -> Txt-fromString = pack--toString :: Txt -> String-toString = unpack--normalize :: Txt -> Txt-normalize = fromChunks . return . Strict.concat . toChunks--getContents :: IO Txt-getContents = decodeUtf8 `fmap` ByteString.getContents--readFile :: FilePath -> IO Txt-readFile f = decodeUtf8 `fmap` ByteString.readFile f--writeFile :: FilePath -> Txt -> IO ()-writeFile f = ByteString.writeFile f . encodeUtf8--putStr :: Txt -> IO ()-putStr = ByteString.putStr . encodeUtf8--putStrLn :: Txt -> IO ()-putStrLn = ByteString.putStrLn . encodeUtf8--interact :: (Txt -> Txt) -> IO ()-interact f = ByteString.interact (encodeUtf8 . f . decodeUtf8)--hPutStr :: Handle -> Txt -> IO ()-hPutStr h = ByteString.hPutStr h . encodeUtf8--hPutStrLn :: Handle -> Txt -> IO ()-hPutStrLn h s = do ByteString.hPutStr h . encodeUtf8 $ s- ByteString.hPutStr h . encodeUtf8 $ "\n"-
− lib/Aux/Utils.hs
@@ -1,44 +0,0 @@-{-# LANGUAGE BangPatterns #-}--module Aux.Utils - ( splitOn- , splitWith- , padRight- , uniq- , accuracy- , mean- , (#)- )-where-import Data.List (foldl')-import qualified Data.Set as Set-import qualified Data.Map as Map--splitOn :: (Eq a) => a -> [a] -> [[a]]-splitOn = splitWith . (==)--splitWith :: (a -> Bool) -> [a] -> [[a]]-splitWith f s = case dropWhile f s of- [] -> []- s' -> w : splitWith f s''- where (w, s'') = break f s'--padRight :: a -> Int -> [a] -> [a]-padRight x i xs = take i (xs ++ repeat x)--uniq :: (Ord a) => [a] -> [a]-uniq = Set.toList . Set.fromList--accuracy predicted testset = - fromIntegral (foldl' (+) 0 (zipWith ((fromEnum .) . (==)) predicted - testset))- / - fromIntegral (length testset)--{-# SPECIALIZE mean :: [Double] -> Double #-}-mean :: (Fractional a) => [a] -> a-mean = uncurry (/) - . foldl' (\ (!s,!n) x -> (s+x,n+1)) (0,0)--(#) :: (Show k,Ord k) => Map.Map k a -> k -> a-m # i = Map.findWithDefault (error $ "#: not found: " ++ show i) i m
+ lib/Helper/Atom.hs view
@@ -0,0 +1,88 @@+{-# LANGUAGE GeneralizedNewtypeDeriving + , NoMonomorphismRestriction + , BangPatterns #-}+module Helper.Atom + ( MonadAtoms (..)+ , AtomTable (..)+ , Atoms+ , AtomsT+ , empty+ , evalAtoms+ , evalAtomsT+ , runAtoms+ , runAtomsT+ )+where+import Control.Monad.State+import Control.Monad.Identity+import qualified Data.Map as Map+import qualified Data.IntMap as IntMap+import qualified Data.Binary as B+import qualified Helper.Text as Text+type Txt = Text.Txt+++data AtomTable = T { lastID :: !Int + , to :: Map.Map Txt Int + , from :: IntMap.IntMap Txt } + deriving (Eq,Show)+++instance B.Binary AtomTable where+ put t = do B.put (lastID t) + B.put (to t)+ B.put (from t)+ get = do liftM3 T B.get B.get B.get+++class Monad m => MonadAtoms m where+ toAtom :: Txt -> m Int+ maybeToAtom :: Txt -> m (Maybe Int)+ fromAtom :: Int -> m Txt+ table :: m AtomTable++instance Monad m => MonadAtoms (AtomsT m) where+ toAtom x = AtomsT $ do+ t <- get+ case Map.lookup x (to t) of+ Just j -> return $! j+ Nothing -> do + let i = lastID t+ i' = i + 1 + !t' = t { lastID = i'+ , to = Map.insert x i (to t) + , from = IntMap.insert i x (from t) }+ put t'+ return $! lastID t++ maybeToAtom x = + AtomsT $ do+ t <- get+ return . Map.lookup x . to $ t+ + fromAtom i = AtomsT $ do+ t <- get+ return $ (from t) IntMap.! i+ table = AtomsT get++empty :: AtomTable+empty = T 0 Map.empty IntMap.empty++runAtomsT :: AtomsT t t1 -> AtomTable -> t (t1, AtomTable)+runAtomsT (AtomsT x) s = runStateT x s++runAtoms :: Atoms t -> AtomTable -> (t, AtomTable)+runAtoms (Atoms x) s = runIdentity (runAtomsT x s)+++evalAtoms :: Atoms t -> t+evalAtoms = fst . flip runAtoms empty++evalAtomsT :: (Monad m) => AtomsT m a -> m a+evalAtomsT = liftM fst . flip runAtomsT empty++newtype AtomsT m r = AtomsT (StateT AtomTable m r)+ deriving (Functor,Monad,MonadTrans,MonadIO)++newtype Atoms r = Atoms (AtomsT Identity r)+ deriving (Functor,Monad,MonadAtoms)
+ lib/Helper/Commands.hs view
@@ -0,0 +1,62 @@+module Helper.Commands + ( Command+ , CommandName+ , Help+ , CommandSpec (..)+ , module System.Console.GetOpt+ , defaultMain+ , usage+ )+where+import Text.PrettyPrint(renderStyle,render,nest,vcat,hsep,style+ ,Mode(..),mode,text,(<>),($$),($+$),(<+>))+import System.Console.GetOpt+import System.Environment (getArgs)+import System.IO (stderr,hPutStr)+import qualified Data.List as List+++type Command opts = (opts -> [String] -> IO ())+type CommandName = String+type Help = String+data CommandSpec opts = CommandSpec (Command opts)+ Help + [OptDescr (opts -> opts)]+ [String]++defaultMain :: opts -> [(String, CommandSpec opts)] -> String -> IO ()+defaultMain def commands header = do+ args <- getArgs+ let theUsage = usage commands header+ case args of+ [] -> theUsage []+ command:opts -> case List.lookup command commands of+ Nothing -> theUsage ["Invalid command: " ++ command]+ Just spec -> runCommand theUsage def spec opts++runCommand :: ([String] -> IO ()) + -> opts + -> CommandSpec opts + -> [String] + -> IO ()+runCommand theUsage def (CommandSpec command help optDesc argnames) args = + case getOpt Permute optDesc args of+ (o,n,[] ) -> command (foldr ($) def o) n+ (_,_,errs) -> theUsage errs++usage :: [(String, CommandSpec t)] -> String -> [String] -> IO ()+usage commands header errs = hPutStr stderr . render + $ vcat (List.map text errs)+ $$ usageMsg commands header++usageMsg commands header = + text header+ $+$ (vcat (List.map commandUsage commands))++commandUsage (name , CommandSpec command help optionDesc args) = + text name <> text ":"+ $$ (nest 10 (text help))+ $$ (text name <+> text (if null optionDesc then "" else "[OPTION...]")+ <+> hsep (map text args))+ <+> (nest 10 (text $ usageInfo "" optionDesc))+
+ lib/Helper/ListZipper.hs view
@@ -0,0 +1,76 @@+module Helper.ListZipper + ( + ListZipper(..)+ , focus+ , left+ , right+ , reset+ , fromList+ , toZippers+ , toList+ , next+ , atEnd + , at+ )+where+import Data.Maybe+import Data.Monoid+import Data.Foldable (Foldable,foldMap)+++data ListZipper a = LZ [a] (Maybe a) [a] deriving (Show,Eq,Ord)++left :: ListZipper a -> [a]+left (LZ xs _ _) = xs++focus :: ListZipper a -> Maybe a+focus (LZ _ x _) = x++right :: ListZipper a -> [a]+right (LZ _ _ ys) = ys++fromList [] = LZ [] Nothing [] +fromList (x:xs) = LZ [] (Just x) xs++toZippers xs = let zs = iterate next . fromList $ xs+ in map snd . zip xs $ zs++toList (LZ xs (Just x) ys) = reverse xs ++ [x] ++ ys+toList (LZ xs Nothing []) = reverse xs++next :: ListZipper a -> ListZipper a+next = nextWith id id+nextWith f g (LZ lxs (Just x) rxs) =+ case rxs of+ y:ys -> LZ (f x:lxs) (Just (g y)) ys+ [] -> LZ (f x:lxs) Nothing []++atEnd :: ListZipper a -> Bool+atEnd = isNothing . focus++reset (LZ [] (Just y) ys) = LZ [] (Just y) ys+reset (LZ [] Nothing []) = LZ [] Nothing []+reset (LZ xs (Just y) ys) = LZ [] (Just z) (zs++[y]++ys)+ where z:zs = reverse xs +reset (LZ xs Nothing []) = LZ [] (Just z) zs+ where z:zs = reverse xs++from :: (Monoid m) => Maybe m -> m+from Nothing = mempty+from (Just x) = x++index 1 (x:xs) = Just x+index i [] = Nothing+index i (x:xs) = index (i-1) xs++at :: (Monoid m) => ListZipper m -> Int -> m+at z 0 = from . focus $ z+at z i | i < 0 = from . index (negate i) . left $ z+at z i = from . index i . right $ z++instance Functor ListZipper where+ fmap f (LZ ls x rs) = LZ (fmap f ls) (fmap f x) (fmap f rs) +instance Foldable ListZipper where+ foldMap f (LZ ls x rs) = mconcat $ fmap f (reverse ls) + ++ [from $ fmap f x] ++ fmap f rs+
+ lib/Helper/Text.hs view
@@ -0,0 +1,123 @@+{-# LANGUAGE OverloadedStrings + , TypeSynonymInstances + #-}+module Helper.Text + ( Txt+ , module Data.Text.Lazy + , module Data.Text.Lazy.Encoding+ , splitOn+ , show+ , read+ , reads+ , readDouble+ , readInt+ , normalize+ , fromString+ , toString+ , getContents+ , readFile + , getLine+ , writeFile + , putStr + , putStrLn + , interact + , hPutStr + , hPutStrLn+ )+ where+import Data.Text.Lazy hiding (splitOn)+import Data.Text.Lazy.Encoding+import Data.Text.Lazy.Read+import System.IO (Handle)+import qualified Data.Text.Lazy.IO as IO+import qualified Data.Text.IO as StrictIO+import qualified Data.ByteString.Lazy.Char8 as ByteString+import qualified Data.Text as Strict+import Data.Binary+import qualified Helper.Utils as Utils+import Prelude hiding ( show+ , reverse+ , map+ , read+ , reads+ , getContents+ , readFile + , getLine+ , writeFile + , putStr + , putStrLn + , interact + )+import qualified Prelude++type Txt = Text++instance Binary Txt where+ put = put . encodeUtf8+ get = fmap decodeUtf8 get++splitOn :: Char -> Txt -> [Txt]+splitOn c = Prelude.map pack . Utils.splitOn c . unpack++show :: (Show a) => a -> Txt+show = pack . Prelude.show++read :: (Read a) => Txt -> a+read = Prelude.read . unpack++reads :: (Read a) => Txt -> [(a,Txt)]+reads = Prelude.map (\ (r,s) -> (r,pack s)) . Prelude.reads . unpack++nan :: Double+nan = 0/0++readDouble :: Txt -> Double +readDouble "NaN" = nan+readDouble t = case double t of+ Right (d,"") -> d+ Left err -> error $ "Helper.Text.readDouble: " ++ err++readInt :: Txt -> Int+readInt t = case decimal t of+ Right (d,"") -> d+ Left err -> error $ "Helper.Text.readDouble: " ++ err++fromString :: String -> Txt+fromString = pack++toString :: Txt -> String+toString = unpack++normalize :: Txt -> Txt+normalize = fromChunks . return . Strict.concat . toChunks++getContents :: IO Txt+getContents = decodeUtf8 `fmap` ByteString.getContents++readFile :: FilePath -> IO Txt+readFile f = decodeUtf8 `fmap` ByteString.readFile f++writeFile :: FilePath -> Txt -> IO ()+writeFile f = ByteString.writeFile f . encodeUtf8++putStr :: Txt -> IO ()+putStr = ByteString.putStr . encodeUtf8++putStrLn :: Txt -> IO ()+putStrLn = ByteString.putStrLn . encodeUtf8++interact :: (Txt -> Txt) -> IO ()+interact f = ByteString.interact (encodeUtf8 . f . decodeUtf8)++hPutStr :: Handle -> Txt -> IO ()+hPutStr h = ByteString.hPutStr h . encodeUtf8++hPutStrLn :: Handle -> Txt -> IO ()+hPutStrLn h s = do ByteString.hPutStr h . encodeUtf8 $ s+ ByteString.hPutStr h . encodeUtf8 $ "\n"++getLine :: IO Txt+getLine = do+ ln <- StrictIO.getLine+ return $ fromChunks [ln]+
+ lib/Helper/Utils.hs view
@@ -0,0 +1,44 @@+{-# LANGUAGE BangPatterns #-}++module Helper.Utils + ( splitOn+ , splitWith+ , padRight+ , uniq+ , accuracy+ , mean+ , (#)+ )+where+import Data.List (foldl')+import qualified Data.Set as Set+import qualified Data.Map as Map++splitOn :: (Eq a) => a -> [a] -> [[a]]+splitOn = splitWith . (==)++splitWith :: (a -> Bool) -> [a] -> [[a]]+splitWith f s = case dropWhile f s of+ [] -> []+ s' -> w : splitWith f s''+ where (w, s'') = break f s'++padRight :: a -> Int -> [a] -> [a]+padRight x i xs = take i (xs ++ repeat x)++uniq :: (Ord a) => [a] -> [a]+uniq = Set.toList . Set.fromList++accuracy predicted testset = + fromIntegral (foldl' (+) 0 (zipWith ((fromEnum .) . (==)) predicted + testset))+ / + fromIntegral (length testset)++{-# SPECIALIZE mean :: [Double] -> Double #-}+mean :: (Fractional a) => [a] -> a+mean = uncurry (/) + . foldl' (\ (!s,!n) x -> (s+x,n+1)) (0,0)++(#) :: (Show k,Ord k) => Map.Map k a -> k -> a+m # i = Map.findWithDefault (error $ "#: not found: " ++ show i) i m
sequor.cabal view
@@ -1,5 +1,5 @@ Name: sequor-Version: 0.2.2+Version: 0.2.3 Description: A sequence labeler based on Collins's sequence perceptron. Synopsis: A sequence labeler based on Collins's sequence perceptron. Homepage: http://code.google.com/p/sequor/@@ -18,8 +18,8 @@ Executable sequor Main-is: Main.hs- Other-modules: Aux.ListZipper, Aux.Utils, Aux.Text, - Aux.Atom, Aux.Commands, CorpusReader,+ Other-modules: Helper.ListZipper, Helper.Utils, Helper.Text, + Helper.Atom, Helper.Commands, CorpusReader, FeatureTemplate, Config, Perceptron.Vector, Perceptron.Sequence, Features, Labeler, Hashable Build-Depends: base >= 3 && < 5, containers >= 0.2,
src/Config.hs view
@@ -3,7 +3,7 @@ ( Config (..), Flags(..) ) where import Data.Char-import Aux.Atom (AtomTable)+import Helper.Atom (AtomTable) import qualified Data.Binary as B import Control.Monad (ap) import FeatureTemplate (Feature)
src/CorpusReader.hs view
@@ -6,10 +6,10 @@ , fromWords ) where-import Aux.ListZipper -import Aux.Utils (splitWith)-import qualified Aux.Text as Text-import Aux.Text (Txt)+import Helper.ListZipper +import Helper.Utils (splitWith)+import qualified Helper.Text as Text+import Helper.Text (Txt) import Data.Maybe (isJust)
src/FeatureTemplate.hs view
@@ -6,8 +6,8 @@ ) where import Data.Binary -import Aux.Text(Txt)-import qualified Aux.Text as Text+import Helper.Text(Txt)+import qualified Helper.Text as Text import qualified Data.List as List import qualified Data.Char as Char
src/Features.hs view
@@ -10,16 +10,16 @@ ) where -import qualified Aux.Text as Text-import Aux.Text (Txt)-import qualified Aux.ListZipper as LZ-import Aux.ListZipper (ListZipper,at)+import qualified Helper.Text as Text+import Helper.Text (Txt)+import qualified Helper.ListZipper as LZ+import Helper.ListZipper (ListZipper,at) import CorpusReader (Token,fromWords) import qualified Data.Char as Char import Data.List (group,sort) import qualified Data.IntSet as IntSet import qualified Data.IntMap as IntMap-import Aux.Atom (MonadAtoms,AtomTable,from,toAtom,maybeToAtom)+import Helper.Atom (MonadAtoms,AtomTable,from,toAtom,maybeToAtom) import Data.Maybe (catMaybes,isNothing) import Control.Monad (liftM2) import Data.Monoid (mappend)
src/Hashable.hs view
@@ -29,7 +29,7 @@ import Data.List (foldl') import qualified Data.ByteString as B import qualified Data.ByteString.Lazy as BL-import qualified Aux.Text as Text+import qualified Helper.Text as Text -- | The class containing a function 'hash' which computes the hash values of -- given value.
src/Labeler.hs view
@@ -14,21 +14,21 @@ import qualified Data.IntSet as IntSet import Data.List (foldl',tails) import Data.Maybe (fromMaybe)-import Aux.ListZipper+import Helper.ListZipper import qualified Perceptron.Sequence as P import Perceptron.Sequence (Options(..)) import CorpusReader (Token)-import Aux.Utils (splitWith,uniq)+import Helper.Utils (splitWith,uniq) import Text.Printf-import Aux.Atom+import Helper.Atom import Control.Monad.RWS import Features (inputFeatures,features,maybeFeatures,outputFeatures ,indexFeatures) import qualified Data.Array as A import qualified Data.Vector.Unboxed as V import qualified Data.Binary as Binary-import qualified Aux.Text as Text-import Aux.Text(Txt)+import qualified Helper.Text as Text+import Helper.Text(Txt) import Data.Char import Data.Maybe (catMaybes) import Config
src/Main.hs view
@@ -2,14 +2,14 @@ where import qualified Labeler as L import CorpusReader (corpus,corpusLabeled)-import qualified Aux.Text as Text-import qualified Aux.ListZipper as Z+import qualified Helper.Text as Text+import qualified Helper.ListZipper as Z import qualified Data.Binary as Binary import qualified Data.ByteString.Lazy as ByteString import System.Environment (getArgs) import System.IO (hPutStrLn,stderr) import FeatureTemplate (parse)-import Aux.Commands ( CommandSpec (..),defaultMain , usage +import Helper.Commands ( CommandSpec (..),defaultMain , usage , Command , OptDescr(Option), ArgDescr(ReqArg,NoArg)) import Config(Flags(..))
src/Perceptron/Sequence.hs view
@@ -30,9 +30,9 @@ import Config import Data.List (inits,foldl',sortBy) import Data.Ord (comparing)-import Aux.ListZipper +import Helper.ListZipper import qualified Data.Binary as Binary-import Aux.Utils (uniq)+import Helper.Utils (uniq) data Model = Model { options :: Options , weights :: UArray I Float }