packages feed

concraft-pl 0.3.1 → 0.4.0

raw patch · 6 files changed

+98/−19 lines, 6 filesdep +split

Dependencies added: split

Files

concraft-pl.cabal view
@@ -1,5 +1,5 @@ name:               concraft-pl-version:            0.3.1+version:            0.4.0 synopsis:           Morphological tagger for Polish description:     A morphological tagger for Polish based on the concraft library.@@ -14,6 +14,8 @@ homepage:           http://zil.ipipan.waw.pl/Concraft build-type:         Simple +data-files: config/nkjp-tagset.cfg+ library     hs-source-dirs: src @@ -32,6 +34,7 @@       , transformers       , network       , lazy-io+      , split                   >= 0.2      && < 0.3      exposed-modules:         NLP.Concraft.Polish
+ config/nkjp-tagset.cfg view
@@ -0,0 +1,64 @@+# NKJP tagset definition++[ATTR]++# Attributes and their values+nmb     = sg pl+cas     = nom gen dat acc inst loc voc+gnd     = m1 m2 m3 f n # n1 n2 n3 p1 p2 p3+per     = pri sec ter+deg     = pos com sup+asp     = imperf perf+ngt     = aff neg+acm     = congr rec+acn     = akc nakc+ppr     = npraep praep+agg     = agl nagl+vlc     = nwok wok+dot     = pun npun+# sentiment               = spos sneg++[RULE]++# Parsing rules definitions.++adja    =+adjp    =+adjc    =+conj    =+comp    =+interp  = +pred    =+xxx     =+adv     = [deg]+imps    = asp+inf     = asp+pant    = asp+pcon    = asp+qub     = [vlc]+prep    = cas [vlc]+siebie  = cas+subst   = nmb cas gnd+depr    = nmb cas gnd+ger     = nmb cas gnd asp ngt+ppron12 = nmb cas gnd per [acn]+ppron3  = nmb cas gnd per [acn] [ppr]+num     = nmb cas gnd acm+numcol  = nmb cas gnd acm+adj     = nmb cas gnd deg+pact    = nmb cas gnd asp ngt+ppas    = nmb cas gnd asp ngt+winien  = nmb gnd asp+praet   = nmb gnd asp [agg]+bedzie  = nmb per asp+fin     = nmb per asp+impt    = nmb per asp+aglt    = nmb per asp vlc++# `ign` is a special tag and we treat in a special way.+# ign     = ++brev    = dot+burk    =+interj  =+
src/NLP/Concraft/Polish.hs view
@@ -22,6 +22,8 @@  import qualified Control.Monad.LazyIO as LazyIO import           Control.Applicative ((<$>))+import qualified Data.List.Split as Split+import qualified Data.Char as Char import qualified Data.Text as T import qualified Data.Text.Lazy as L import qualified Data.Set as S@@ -93,8 +95,10 @@ tag' :: MacaPool -> C.Concraft -> L.Text -> IO [[Sent Tag]] tag' pool concraft     = LazyIO.mapM (tag pool concraft . L.toStrict)-    . map L.strip-    . L.splitOn "\n\n"+    . map L.unlines+    . Split.splitWhen+        (L.all Char.isSpace)+    . L.lines   -- | Tag an already analysed sentence.
src/NLP/Concraft/Polish/Maca.hs view
@@ -115,15 +115,13 @@  readMacaSent :: Handle -> IO (Sent Tag) readMacaSent h =-    Plain.parseSent <$> getTxt +    Plain.parseSent . L.unlines <$> getTxt   where     getTxt = do         x <- L.hGetLine h         if L.null x-            then return x-            else do   -                xs <- getTxt-                return (x `L.append` "\n" `L.append` xs)+            then return []+            else (x:) <$> getTxt   ----------------------------
src/NLP/Concraft/Polish/Server.hs view
@@ -18,6 +18,8 @@ import           System.IO (Handle, hFlush) import qualified Control.Monad.LazyIO as LazyIO import qualified Network as N+import qualified Data.Char as Char+import qualified Data.List.Split as Split import qualified Data.Binary as B import qualified Data.ByteString.Lazy as BS import qualified Data.Text as T@@ -75,8 +77,10 @@ tag' :: N.HostName -> N.PortID -> L.Text -> IO [[Sent Tag]] tag' host port     = LazyIO.mapM (tag host port . L.toStrict)-    . map L.strip-    . L.splitOn "\n\n"+    . map L.unlines+    . Split.splitWhen+        (L.all Char.isSpace)+    . L.lines   -------------------------------------------------
tools/concraft-pl.hs view
@@ -23,7 +23,7 @@ import qualified NLP.Concraft.Polish.Morphosyntax as X import qualified NLP.Concraft.Polish.Format.Plain as P -import           Paths_concraft_pl (version)+import           Paths_concraft_pl (version, getDataFileName) import           Data.Version (showVersion)  @@ -51,7 +51,7 @@     { trainPath	    :: FilePath     , evalPath      :: Maybe FilePath     , format        :: Format-    , tagsetPath    :: FilePath+    , tagsetPath    :: Maybe FilePath     , noAna         :: Bool     -- , discardHidden :: Bool     , iterNum       :: Double@@ -77,7 +77,7 @@     , host          :: String     , port          :: Int }   | Compare-    { tagsetPath    :: FilePath+    { tagsetPath    :: Maybe FilePath     , refPath       :: FilePath     , otherPath     :: FilePath     , format        :: Format }@@ -86,9 +86,9 @@  trainMode :: Concraft trainMode = Train-    { tagsetPath = def &= argPos 0 &= typ "TAGSET-PATH"-    , trainPath = def &= argPos 1 &= typ "TRAIN-FILE"+    { trainPath = def &= argPos 1 &= typ "TRAIN-FILE"     , evalPath = def &= typFile &= help "Evaluation file"+    , tagsetPath = def &= typFile &= help "Tagset definition file"     , format = enum [Plain &= help "Plain format"]     , noAna = False &= help "Do not perform reanalysis"     -- , discardHidden = False &= help "Discard hidden features"@@ -127,9 +127,9 @@  compareMode :: Concraft compareMode = Compare-    { tagsetPath = def &= argPos 0 &= typ "TAGSET-PATH"-    , refPath   = def &= argPos 1 &= typ "REFERENCE-FILE"+    { refPath   = def &= argPos 1 &= typ "REFERENCE-FILE"     , otherPath = def &= argPos 2 &= typ "OTHER-FILE"+    , tagsetPath = def &= typFile &= help "Tagset definition file"     , format  = enum [Plain &= help "Plain input format"] }  @@ -153,7 +153,10 @@   exec Train{..} = do-    tagset <- parseTagset tagsetPath <$> readFile tagsetPath+    tagsetPath' <- case tagsetPath of+        Nothing -> getDataFileName "config/nkjp-tagset.cfg"+        Just x  -> return x+    tagset <- parseTagset tagsetPath' <$> readFile tagsetPath'     let train0 = parseFileO  format trainPath     let eval0  = parseFileO' format evalPath     concraft <- C.train (trainConf tagset) train0 eval0@@ -206,7 +209,10 @@   exec Compare{..} = do-    tagset <- parseTagset tagsetPath <$> readFile tagsetPath+    tagsetPath' <- case tagsetPath of+        Nothing -> getDataFileName "config/nkjp-tagset.cfg" +        Just x  -> return x+    tagset <- parseTagset tagsetPath' <$> readFile tagsetPath'     let convert = map (X.packSeg tagset) . concat     xs <- convert <$> parseFile format refPath     ys <- convert <$> parseFile format otherPath