nkjp 0.3 → 0.3.1
raw patch · 2 files changed
+31/−1 lines, 2 filesnew-component:exe:nkjp2text
Files
- nkjp.cabal +6/−1
- tools/nkjp2text.hs +25/−0
nkjp.cabal view
@@ -1,5 +1,5 @@ name: nkjp-version: 0.3+version: 0.3.1 synopsis: Manipulating the National Corpus of Polish (NKJP) description: The library provides parsing and printing utilities for the@@ -43,4 +43,9 @@ executable named2enamex hs-source-dirs: ., tools main-is: named2enamex.hs+ ghc-options: -Wall -O2++executable nkjp2text+ hs-source-dirs: ., tools+ main-is: nkjp2text.hs ghc-options: -Wall -O2
+ tools/nkjp2text.hs view
@@ -0,0 +1,25 @@+{-# LANGUAGE OverloadedStrings #-}++import Control.Monad (forM_)+import System.Environment (getArgs)+import Data.Foldable (foldMap)+import qualified Data.Text.Lazy as L+import qualified Data.Text.Lazy.IO as L++import qualified Text.NKJP.Named as Ne+import qualified Text.NKJP.Morphosyntax as Mx++main :: IO ()+main = do+ [teiPath] <- getArgs+ fs <- Ne.readTrees teiPath+ forM_ fs $ \ts ->+ L.putStrLn . L.strip . showLeaves . getLeaves $ ts+ where+ getLeaves = concatMap (foldMap getRight)+ showLeaves = L.concat . map showLeaf+ showLeaf x = if Mx.nps x+ then Mx.orth x+ else " " `L.append` Mx.orth x+ getRight (Right x) = [x]+ getRight _ = []