diff options
| author | aarne <aarne@cs.chalmers.se> | 2008-06-25 16:54:35 +0000 |
|---|---|---|
| committer | aarne <aarne@cs.chalmers.se> | 2008-06-25 16:54:35 +0000 |
| commit | e9e80fc389365e24d4300d7d5390c7d833a96c50 (patch) | |
| tree | f0b58473adaa670bd8fc52ada419d8cad470ee03 /old-examples/uusisuomi/kotus/Kotus.hs | |
| parent | b96b36f43de3e2f8b58d5f539daa6f6d47f25870 (diff) | |
changed names of resource-1.3; added a note on homepage on release
Diffstat (limited to 'old-examples/uusisuomi/kotus/Kotus.hs')
| -rw-r--r-- | old-examples/uusisuomi/kotus/Kotus.hs | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/old-examples/uusisuomi/kotus/Kotus.hs b/old-examples/uusisuomi/kotus/Kotus.hs new file mode 100644 index 000000000..ad63a1e14 --- /dev/null +++ b/old-examples/uusisuomi/kotus/Kotus.hs @@ -0,0 +1,55 @@ +import List +import Char + +kotus = "sanat.xxmmll" + +main = do + ss <- readFile kotus >>= return . lines + let ws = [w | Just w <- map analyse ss] + writeFile "kotus.gf" $ unlines $ treat ws +-- mapM putStrLn $ treat ws + +treat = map mkLin . entries + +entries = zip [10001..] . filter isNoun + +isNoun x = ((<5) . read . take 1 . fst) x && (all isAlpha . snd) x + +mkLin (n,(pa,ex)) = + "fun n" ++ show n ++ "_" ++ ex ++ " : N ;\n" ++ + "lin n" ++ show n ++ "_" ++ ex ++ " = ud d" ++ pa ++ " \"" ++ ex ++ "\" ;" + +-- treat = map mkRule . paradigms + +mkRule ((pa,ex),nu) = + " " ++ pos ++ pa ++ " : Str -> " ++ poss ++ + "Forms -- " ++ show nu ++ " " ++ ex ++ "\n = \\s -> ;" + where + (pos,poss) = if read (take 2 pa) < 52 then ("d","N") else ("c","V") + +-- paradigms = map info . groupByFst . sort + +info x = (last x, length x) +--info = last + +-- groupByFst = groupBy (\ x y -> fst x == fst y) + +-- <st><s>aaloe</s><t><tn>3</tn></t></st> +-- <st><s>vuoksi</s><hn>1</hn><t><tn>7</tn></t></st> +-- <st><s>visiitti</s><t><tn>5</tn><av>C</av></t></st> + +analyse s = + let + rest = drop 7 s + (word,end) = span (/='<') rest + lst = drop 6 $ dropWhile (/='t') end + (num,gr) = span isDigit lst + para = (replicate (2 - length num) '0' ++ num) ++ ['A' | isPrefixOf "av" (drop 6 gr)] + in case num of + "" -> Nothing + "0" -> Nothing + _ | length num > 2 -> Nothing + _ -> if last word == 't' then Nothing else Just (para,word) + +sub cs s = isPrefixOf cs s || isPrefixOf cs (drop 1 s) + |
