{- ghc --make -o prompts2mlf prompts2mlf.hs -} import Data.Char import System.Environment utt2mlf line = let (n,u) = break (==':') line u' = trim $ drop 1 u in [show ("*/" ++ n ++ ".lab")] ++ map (map toUpper) (words u') ++ ["."] run_file utt_file = do us <- readFile utt_file let mlf = "#!MLF!#\n" ++ unlines (concatMap utt2mlf (lines us)) putStrLn mlf main = do args <- getArgs case args of [utt_file] -> run_file utt_file _ -> fail "Usage: prompts2mlf " trim = reverse . dropWhile isSpace . reverse . dropWhile isSpace