-- automatically generated by BNF Converter module Main where import System.IO ( stdin,stderr,hPutStr, hGetContents ) import System.Exit import System.Environment import Data.List (partition, (\\)) import Extract.Lex import Extract.Par import Extract.Skel import Extract.Print import Extract.Abs import Extract.ErrM import Paradigm import Translate main :: IO () main = do xs <- getArgs case check_options xs of Ok _ -> if (elem "-h" xs) then do prErr welcome prErr help_message else do let (opts,fs) = partition ((=='-') . head) xs case fs of [parafile,corpus] -> do result <- get_paradigms parafile case result of Bad s -> do prErr welcome prErr s Ok ps -> do prErr welcome ffind opts ps corpus parafile _ -> do prErr welcome prErr help_message Bad s -> do prErr welcome prErr s welcome :: String welcome = unlines [ "", "********************************************", "* Lexicon Extraction *", "* with *", "* Constraint Grammar *", "********************************************", "* (c) Markus Forsberg & Aarne Ranta 2012 *", "* under GNU General Public License. *", "********************************************" ] help_message :: String help_message = unlines [" Help message: ", " extract [Option(s)] rule_file corpus_file ", " Options: ", " -h Display this message ", " -c Enable context ", " -nobad Output only identified words ", " -e evidence as comment ", " -u no duplicates ", " -r Reverse words ", " -i Print id " ] check_options xs = case filter (\s -> head s == '-') (xs \\ options) of [] -> return () xs -> Bad $ "Invalid options: " ++ unwords xs options = ["-h", "-nobad", "-e", "-u", "-r", "-c"] prErr s = hPutStr stderr (s ++ "\n")