Skip to content
Snippets Groups Projects
Commit 3807b311 authored by Alice Brenon's avatar Alice Brenon
Browse files

Convert the linearization script to take TSV as input and handle the structure...

Convert the linearization script to take TSV as input and handle the structure itself, making it simpler to call
parent 7ac58bd8
No related branches found
No related tags found
No related merge requests found
#!/usr/bin/env -S runhaskell --ghc-arg="-Wall" --ghc-arg="-i lib/haskell"
import GEODE.Metadata (ArticleRecord, Document(..), ReadTSV(..), Record(..))
import System.Directory (createDirectoryIfMissing)
import System.Environment (getArgs)
import System.FilePath ((</>), takeDirectory)
import System.Script (syntax)
import Text.Filter (xargs)
import Text.Filter.Linearize (linearize)
to :: FilePath -> FilePath -> Bool -> ArticleRecord -> IO ()
to source target inferParagraphs article = do
createDirectoryIfMissing True (takeDirectory output)
readFile (source </> path) >>= writeFile output . linearize inferParagraphs
where
path = relativePath article "txt"
output = target </> path
main :: IO ()
main = getArgs >>= cli
where
cli [inferParagraphs, target] =
xargs (pure.linearize (inferParagraphs == "Y")) target
cli _ = syntax "[Y|N] TARGET_DIR"
cli [inferParagraphs, source, target] =
readTSV () >>= mapM_ (source `to` target $ inferParagraphs == "Y") . rows
cli _ = syntax "[Y|N] SOURCE_DIR TARGET_DIR"
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment