diff options
| author | aarne <aarne@cs.chalmers.se> | 2008-01-02 16:54:22 +0000 |
|---|---|---|
| committer | aarne <aarne@cs.chalmers.se> | 2008-01-02 16:54:22 +0000 |
| commit | cbfb9d5e7d76616b5490083a9f4071fd977c2ec0 (patch) | |
| tree | bdbd570e6615b2fe2aa0c6033472750d0f5b75fc /examples/uusisuomi/MkLex.hs | |
| parent | b3da2791fdea27bd5061ad939e31915e36c03f1d (diff) | |
experiment with Finnish morphology
Diffstat (limited to 'examples/uusisuomi/MkLex.hs')
| -rw-r--r-- | examples/uusisuomi/MkLex.hs | 85 |
1 files changed, 85 insertions, 0 deletions
diff --git a/examples/uusisuomi/MkLex.hs b/examples/uusisuomi/MkLex.hs new file mode 100644 index 000000000..77b8beb4a --- /dev/null +++ b/examples/uusisuomi/MkLex.hs @@ -0,0 +1,85 @@ +module Main where + +import System +import Char + +-- generate Finnish lexicon implementations with 1 or more +-- characteristic arguments +-- usage: runghc MkLex.hs 3 + +main = do + i:_ <- getArgs + ss <- readFile src >>= return . filter (not . (all isSpace)) . lines + initiate i + mapM_ (mkLex (read i) . uncurry (++)) (zip nums ss) + putStrLn "}" + +--src = "correct-NSK.txt" +--tgt = "NSK" +src = "correct-Omat.txt" +tgt = "Omat" + +initiate i = mapM_ putStrLn [ + "--# -path=.:alltenses", + "", + header i, + "" + ] + where + header i = case i of + "0" -> "abstract " ++ tgt ++ "Abs = Cat ** {\n\nfun testN : N -> Utt ;\n" + _ -> unlines [ + "concrete " ++ tgt ++ i ++ + " of " ++ tgt ++ "Abs = CatFin ** open Nominal, ResFin, Prelude in {", + "", + "lin testN talo = let t = talo.s in ss (", + " t ! NCase Sg Nom ++", + " t ! NCase Sg Gen ++", + " t ! NCase Sg Part ++", + " t ! NCase Sg Ess ++", + " t ! NCase Sg Illat ++", + " t ! NCase Pl Gen ++", + " t ! NCase Pl Part ++", + " t ! NCase Pl Ess ++", + " t ! NCase Pl Iness ++", + " t ! NCase Pl Illat", + " ) ;" + ] + +nums = map prt [1 ..] where + prt i = (if i < 10 then "0" else "") ++ show i ++ ". " + +mkLex 0 line = case words line of + num:sana:_ -> do + let nimi = "n" ++ init num ++ "_" ++ sana + putStrLn $ "fun " ++ nimi ++ "_N : N ;" + _ -> return () + +mkLex 1 line = case words line of + num:sana:_ -> do + let nimi = "n" ++ init num ++ "_" ++ sana + putStrLn $ "lin " ++ nimi ++ "_N = mk1N \"" ++ sana ++ "\" ;" + _ -> return () + +mkLex 2 line = case words line of + num:sana:sanan:_ -> do + let nimi = "n" ++ init num ++ "_" ++ sana + putStrLn $ "lin " ++ nimi ++ + "_N = mk2N \"" ++ sana ++ "\" \"" ++ sanan ++ "\" ;" + _ -> return () + +mkLex 3 line = case words line of + num:sana:sanan:_:_:_:_:sanoja:_ -> do + let nimi = "n" ++ init num ++ "_" ++ sana + putStrLn $ "lin " ++ nimi ++ + "_N = mk3N \"" ++ sana ++ "\" \"" ++ sanan ++ "\" \"" ++ sanoja ++ "\" ;" + _ -> return () + +mkLex 4 line = case words line of + num:sana:sanan:sanaa:_:_:_:sanoja:_ -> do + let nimi = "n" ++ init num ++ "_" ++ sana + putStrLn $ "lin " ++ nimi ++ + "_N = mk4N \"" ++ sana ++ "\" \"" ++ sanan ++ + "\" \"" ++ sanaa ++ "\" \"" ++ sanoja ++ "\" ;" + _ -> return () + |
