mirror of
https://github.com/GrammaticalFramework/gf-core.git
synced 2026-05-06 17:52:51 -06:00
finnish kotus word list
This commit is contained in:
41
examples/uusisuomi/kotus/Kotus.hs
Normal file
41
examples/uusisuomi/kotus/Kotus.hs
Normal file
@@ -0,0 +1,41 @@
|
||||
import List
|
||||
import Char
|
||||
|
||||
kotus = "sanat.xxmmll"
|
||||
|
||||
main = do
|
||||
ss <- readFile kotus >>= return . lines
|
||||
let ws = map analyse ss
|
||||
mapM putStrLn $ treat ws
|
||||
|
||||
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
|
||||
(para,word)
|
||||
|
||||
sub cs s = isPrefixOf cs s || isPrefixOf cs (drop 1 s)
|
||||
|
||||
Reference in New Issue
Block a user