summaryrefslogtreecommitdiff
path: root/examples/big/MkDict.hs
diff options
context:
space:
mode:
Diffstat (limited to 'examples/big/MkDict.hs')
-rw-r--r--examples/big/MkDict.hs26
1 files changed, 26 insertions, 0 deletions
diff --git a/examples/big/MkDict.hs b/examples/big/MkDict.hs
new file mode 100644
index 000000000..c57b5ea7d
--- /dev/null
+++ b/examples/big/MkDict.hs
@@ -0,0 +1,26 @@
+infile = "mywordlist1"
+
+main = do
+ s <- readFile infile
+ mapM_ (putStrLn . mkOne) $ lines s
+
+mkOne s = case words s of
+ "--":_ -> ""
+ ('(':_):w:cat:ws ->
+ let
+ (c,f) = mkCatf (nopar cat) (more ws)
+ in unwords $ [c, f, w]
+ _ -> "-- " ++ s
+ where
+ more ws = case ws of
+ _ | elem "(REG" ws -> "irreg"
+ _ -> "reg"
+ nopar = filter (flip notElem "()")
+ mkCatf c r = case c of
+ "Noun" -> ("N","regN")
+ "Adject" -> ("A","regA")
+ "Adject_LONG" -> ("A","longA")
+ "Verb" -> ("V","regV")
+ "PNoun" -> ("PN","regPN")
+ _ -> (c,"mk" ++ c)
+