mirror of
https://github.com/GrammaticalFramework/gf-core.git
synced 2026-05-20 00:22:51 -06:00
interface for shallow parsing + basic lexicon
This commit is contained in:
37
lib/resource/MkLexicon.hs
Normal file
37
lib/resource/MkLexicon.hs
Normal file
@@ -0,0 +1,37 @@
|
||||
module MkLexicon where
|
||||
|
||||
import Char
|
||||
|
||||
allLines o f = do
|
||||
s <- readFile f
|
||||
mapM_ (putStrLn . o) (filter noComm (lines s))
|
||||
|
||||
|
||||
-- discard comments and empty lines
|
||||
|
||||
noComm s = case s of
|
||||
'-':'-':_ -> False
|
||||
"" -> False
|
||||
_ -> True
|
||||
|
||||
-- postfix with category
|
||||
|
||||
postfix p s = takeWhile (not . isSpace) s ++ "_" ++ p
|
||||
|
||||
-- make fun rule
|
||||
|
||||
mkFun s =
|
||||
let (w,p) = span (/='_') s in
|
||||
" " ++ s ++ " : " ++ tail p ++ " ;"
|
||||
|
||||
-- make regular lin rule
|
||||
|
||||
mkLin s =
|
||||
let (w,p) = span (/='_') s in
|
||||
" " ++ s ++ " = " ++ lin (tail p) w ++ " ;"
|
||||
where
|
||||
lin cat w = case cat of
|
||||
"V2" -> "dirV2 (regV" ++ " \"" ++ w ++ "\")"
|
||||
'V':_ -> "mk" ++ cat ++ " (regV" ++ " \"" ++ w ++ "\")"
|
||||
_ -> "reg" ++ cat ++ " \"" ++ w ++ "\""
|
||||
|
||||
Reference in New Issue
Block a user