summaryrefslogtreecommitdiff
path: root/examples/big/MkDict.hs
blob: 101019165de7de50a64426f206277d0b34951730 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import Char

infile = "mywordlist1"

main = do
  s <- readFile infile
  mapM_ (putStrLn . mkOne) $ lines s

mkOne s = case words s of
  "--":_ -> ""
  ('(':_):w:cat:ws -> unwords $ mkCatf (nopar cat) (more ws) w
  _ -> "-- " ++ s
 where
  more ws = case ws of
    _ | elem "(REG" ws -> "irreg"
    _ -> "reg"
  nopar = filter (flip notElem "()")
  mkCatf c r w = case c of
    "Noun" -> ["N","regN",w]
    "Adject" -> ["A","regA",w]
    "Adject_LONG" -> ["A","longA",w]
    "Verb" | r == "irreg" -> []
    "Verb"  -> ["V","regV",w]
    "V2" | r == "irreg" -> ["V2","irreg", w, "_V"]
    "V2" -> ["V2","regV2", w]
    "PNoun" -> ["PN","regPN",toUpper (head w): tail w]
    'V':'2':'_':prep | r == "irreg" -> 
                  ["V2","mkV2", w, "_V", map toLower prep]
    x:'2':'_':prep -> [[x]++"2","prep" ++[x]++"2", w, map toLower prep]
    _ -> [c,"mk" ++ c, w]