blob: a63e7e1a8d02b964067b355fb1bd0290a5107295 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
|
-- Copyright (C) 2011 Nikita Frolov
import qualified Data.Text as T
import qualified Data.Text.IO as UTF8
import System.IO
import System.Environment
import Control.Monad
import Control.Monad.State
main :: IO ()
main = do
args <- getArgs
forM_ args $ \ f -> do
entries <- UTF8.readFile f >>= (return . T.lines)
forM_ entries $ \ entry ->
do
let ws = T.words entry
form = head ws
tags = toPairs $ tail ws
forM_ tags $ \ (lemma, tag) ->
do
UTF8.putStrLn $ T.concat [lemma, sp, form, sp, tag]
where sp = T.singleton ' '
toPairs xs = zip (stride 2 xs) (stride 2 (drop 1 xs))
where stride _ [] = []
stride n (x:xs) = x : stride n (drop (n-1) xs)
|