1
0
forked from GitHub/gf-core

make help and treebank options

This commit is contained in:
aarne
2006-03-05 20:30:37 +00:00
parent 2657c51e04
commit 65d841bc1b
4 changed files with 26 additions and 18 deletions

View File

@@ -4,14 +4,17 @@ incomplete concrete QuestionsI of Questions = open Lang in {
lin Answer = \woman_N -> \love_V2 -> \man_N -> % Lang.PhrUtt % Lang.NoPConj (% Lang.UttS (% Lang.UseCl % Lang.TPres % Lang.ASimul % Lang.PPos (% Lang.PredVP (% Lang.DetCN (% Lang.DetSg (% Lang.SgQuant % Lang.DefArt)% Lang.NoOrd)(% Lang.UseN % Lang.woman_N)) (% Lang.ComplV2 % Lang.love_V2 (% Lang.DetCN (% Lang.DetPl (% Lang.PlQuant % Lang.IndefArt)% Lang.NoNum % Lang.NoOrd)(% Lang.UseN % Lang.man_N)))))) % Lang.NoVoc ; lin Answer = \woman_N -> \love_V2 -> \man_N -> % Lang.PhrUtt % Lang.NoPConj (% Lang.UttS (% Lang.UseCl % Lang.TPres % Lang.ASimul % Lang.PPos (% Lang.PredVP (% Lang.DetCN (% Lang.DetSg (% Lang.SgQuant % Lang.DefArt)% Lang.NoOrd)(% Lang.UseN % Lang.woman_N)) (% Lang.ComplV2 % Lang.love_V2 (% Lang.DetCN (% Lang.DetPl (% Lang.PlQuant % Lang.IndefArt)% Lang.NoNum % Lang.NoOrd)(% Lang.UseN % Lang.man_N)))))) % Lang.NoVoc ;
lincat Entity = N ; lincat Entity = N ;
lincat Phrase = Phr ; lincat Phrase = Phr ;
lin Who = \love_V2 -> \man_N -> in Phr "who lovs men" ; lin Who = \love_V2 -> \man_N -> % Lang.PhrUtt % Lang.NoPConj (% Lang.UttAdv (% Lang.AdvSC (% Lang.EmbedQS (% Lang.UseQCl % Lang.TPres % Lang.ASimul % Lang.PPos (% Lang.QuestVP % Lang.whoSg_IP (% Lang.ComplV2 % Lang.love_V2 (% Lang.DetCN (% Lang.DetPl (% Lang.PlQuant % Lang.IndefArt)% Lang.NoNum % Lang.NoOrd)(% Lang.UseN % Lang.man_N)))))))) % Lang.NoVoc ;
lin Whom = \man_N -> \love_V2 -> % Lang.PhrUtt % Lang.NoPConj (% Lang.UttQS (% Lang.UseQCl % Lang.TPres % Lang.ASimul % Lang.PPos (% Lang.QuestSlash % Lang.whoPl_IP (% Lang.SlashV2 (% Lang.DetCN (% Lang.DetSg (% Lang.SgQuant % Lang.DefArt)% Lang.NoOrd)(% Lang.UseN % Lang.man_N)) % Lang.love_V2)))) % Lang.NoVoc ; lin Whom = \man_N -> \love_V2 -> % Lang.PhrUtt % Lang.NoPConj (% Lang.UttQS (% Lang.UseQCl % Lang.TPres % Lang.ASimul % Lang.PPos (% Lang.QuestSlash % Lang.whoPl_IP (% Lang.SlashV2 (% Lang.DetCN (% Lang.DetSg (% Lang.SgQuant % Lang.DefArt)% Lang.NoOrd)(% Lang.UseN % Lang.man_N)) % Lang.love_V2)))) % Lang.NoVoc ;
} }
{- {-
NO PARSE Who AMBIGUOUS in Who
who lovs men who loves men
unknown words: lovs PhrUtt NoPConj (UttQS (UseQCl TPres ASimul PPos (QuestVP whoSg_IP (ComplV2 love_V2 (DetCN (DetPl (PlQuant IndefArt) NoNum NoOrd) (UseN man_N)))))) NoVoc
AMBIGUOUS Whom AMBIGUOUS in Whom
whom does the man love whom does the man love
PhrUtt NoPConj (UttQS (UseQCl TPres ASimul PPos (QuestSlash whoSg_IP (SlashV2 (DetCN (DetSg (SgQuant DefArt) NoOrd) (UseN man_N)) love_V2)))) NoVoc PhrUtt NoPConj (UttQS (UseQCl TPres ASimul PPos (QuestSlash whoSg_IP (SlashV2 (DetCN (DetSg (SgQuant DefArt) NoOrd) (UseN man_N)) love_V2)))) NoVoc
PARSED in Answer
the woman loves men
PhrUtt NoPConj (UttS (UseCl TPres ASimul PPos (PredVP (DetCN (DetSg (SgQuant DefArt) NoOrd) (UseN woman_N)) (ComplV2 love_V2 (DetCN (DetPl (PlQuant IndefArt) NoNum NoOrd) (UseN man_N)))))) NoVoc
-} -}

View File

@@ -48,7 +48,7 @@ main = do
doGF os fs = case 0 of doGF os fs = case 0 of
_ | opt getHelp -> do _ | opt getHelp || any opt (map iOpt ["h", "-help", "-h"])-> do
putStrLnFlush $ encodeUTF8 helpMsg putStrLnFlush $ encodeUTF8 helpMsg
_ | opt forJava -> do _ | opt forJava -> do
@@ -99,10 +99,11 @@ helpMsg = unlines [
" -edit start the editor GUI (same as command 'jgf')", " -edit start the editor GUI (same as command 'jgf')",
" -ex first compile .gfe files as needed, then .gf files", " -ex first compile .gfe files as needed, then .gf files",
" -examples batch-compile .gfe files by parsing examples", " -examples batch-compile .gfe files by parsing examples",
" -help show this message", " -treebank use a treebank, instead of a grammar, as parser",
" -make batch-compile files", " -make batch-compile files",
" -noemit do not emit code when compiling", " -noemit do not emit code when compiling",
" -v be verbose when compiling", " -v be verbose when compiling",
" -help show this message",
"Also all flags for import (i) are interpreted; see 'help import'.", "Also all flags for import (i) are interpreted; see 'help import'.",
"An example combination of flags is", "An example combination of flags is",
" gf -batch -nocpu -s", " gf -batch -nocpu -s",

View File

@@ -67,9 +67,9 @@ mkCncGroups opts0 ((res,path),files) = do
let treebank = oElem (iOpt "treebank") opts let treebank = oElem (iOpt "treebank") opts
egr <- appIOE $ shellStateFromFiles opts emptyShellState res egr <- appIOE $ shellStateFromFiles opts emptyShellState res
(parser,morpho) <- if treebank then do (parser,morpho) <- if treebank then do
tb <- err (\_ -> error "no treebank") tb <- err (\_ -> error $ "no treebank of name" +++ path)
return return
(egr >>= flip findTreebank (zIdent (unsuffixFile res))) (egr >>= flip findTreebank (zIdent path))
return (\_ -> flip (,) "Not in treebank" . map pTrm . lookupTreebank tb, return (\_ -> flip (,) "Not in treebank" . map pTrm . lookupTreebank tb,
isWordInTreebank tb) isWordInTreebank tb)
else do else do
@@ -91,9 +91,11 @@ getResPath :: FilePath -> IO (String,String)
getResPath file = do getResPath file = do
s <- liftM lines $ readFileIf file s <- liftM lines $ readFileIf file
case filter (not . all isSpace) s of case filter (not . all isSpace) s of
res:path:_ | is "resource" res && is "path" path -> return (val res, val path) res:path:_ | is "resource" res && is "path" path -> return (val res, val path)
res:path:_ | is "resource" res && is "treebank" path -> return (val res, val path)
res:_ | is "resource" res -> return (val res, "") res:_ | is "resource" res -> return (val res, "")
_ -> error "expected --# -resource=FILE and optional --# -path=PATH" _ -> error
"expected --# -resource=FILE and optional --# -path=PATH or --# -treebank=IDENT"
where where
val = dropWhile (isSpace) . tail . dropWhile (not . (=='=')) val = dropWhile (isSpace) . tail . dropWhile (not . (=='='))
is tag s = case words s of is tag s = case words s of
@@ -133,12 +135,14 @@ mkModule parser morpho (name,src) = case src of
Example (Vr cat) s -> parse cat s t Example (Vr cat) s -> parse cat s t
_ -> composOp mkTrm t _ -> composOp mkTrm t
parse cat s t = case parser (prt_ cat) s of parse cat s t = case parser (prt_ cat) s of
(tr:[], _) -> return tr (tr:[], _) -> do
updateSTM ((("PARSED in" +++ prt_ name) : s : [prt_ tr]) ++)
return tr
(tr:trs,_) -> do (tr:trs,_) -> do
updateSTM ((("AMBIGUOUS" +++ prt_ name) : s : map prt_ trs) ++) updateSTM ((("AMBIGUOUS in" +++ prt_ name) : s : map prt_ trs) ++)
return tr return tr
([],ms) -> do ([],ms) -> do
updateSTM ((("NO PARSE" +++ prt_ name) : s : ms : [morph s]) ++) updateSTM ((("NO PARSE in" +++ prt_ name) : s : ms : [morph s]) ++)
return t return t
morph s = case [w | w <- words s, not (morpho w)] of morph s = case [w | w <- words s, not (morpho w)] of
[] -> "" [] -> ""

View File

@@ -168,11 +168,11 @@ testValidFlag st co f x = case f of
optionsOfCommand :: Command -> ([String],[String]) optionsOfCommand :: Command -> ([String],[String])
optionsOfCommand co = case co of optionsOfCommand co = case co of
CSetFlag -> both "utf8 table struct record all multi" CSetFlag ->
"cat lang lexer parser number depth rawtrees unlexer optimize path conversion printer" both "utf8 table struct record all multi"
"cat lang lexer parser number depth rawtrees unlexer optimize path conversion printer"
CImport _ -> CImport _ ->
both "old v s src gfc retain nocf nocheckcirc cflexer noemit o make ex prob treebank" both "old v s src make gfc retain nocf nocheckcirc cflexer noemit o make ex prob treebank"
"abs cnc res path optimize conversion cat preproc probs noparse" "abs cnc res path optimize conversion cat preproc probs noparse"
CRemoveLanguage _ -> none CRemoveLanguage _ -> none
CEmptyState -> none CEmptyState -> none