diff options
| author | aarne <aarne@cs.chalmers.se> | 2006-03-01 17:36:34 +0000 |
|---|---|---|
| committer | aarne <aarne@cs.chalmers.se> | 2006-03-01 17:36:34 +0000 |
| commit | c30936dc16adf799c94722c54635b914aeca33c6 (patch) | |
| tree | 68dc016a17274c490fc538672cbdda000290b82e | |
| parent | 8cf236bfbba7212908d35bed9b20b6b879913851 (diff) | |
refreshing gfe example
| -rw-r--r-- | examples/animal/Animals.gf | 12 | ||||
| -rw-r--r-- | examples/animal/AnimalsEng.gf | 16 | ||||
| -rw-r--r-- | examples/animal/AnimalsFre.gf | 15 | ||||
| -rw-r--r-- | examples/animal/AnimalsSwe.gf | 15 | ||||
| -rw-r--r-- | examples/animal/Questions.gf | 10 | ||||
| -rw-r--r-- | examples/animal/QuestionsEng.gf | 2 | ||||
| -rw-r--r-- | examples/animal/QuestionsFre.gf | 2 | ||||
| -rw-r--r-- | examples/animal/QuestionsI.gf | 22 | ||||
| -rw-r--r-- | examples/animal/QuestionsI.gfe | 17 | ||||
| -rw-r--r-- | examples/animal/QuestionsSwe.gf | 2 | ||||
| -rw-r--r-- | examples/animal/mkAnimals.gfs | 4 | ||||
| -rw-r--r-- | src/GF/Compile/MkConcrete.hs | 18 |
12 files changed, 125 insertions, 10 deletions
diff --git a/examples/animal/Animals.gf b/examples/animal/Animals.gf new file mode 100644 index 000000000..33b56e740 --- /dev/null +++ b/examples/animal/Animals.gf @@ -0,0 +1,12 @@ +-- The Question grammar specialized to animals. + +abstract Animals = Questions ** { + + flags startcat=Phrase ; + + fun + -- a lexicon of animals and actions among them + Dog, Cat, Mouse, Lion, Zebra : Entity ; + Chase, Eat, See : Action ; +} + diff --git a/examples/animal/AnimalsEng.gf b/examples/animal/AnimalsEng.gf new file mode 100644 index 000000000..22942b735 --- /dev/null +++ b/examples/animal/AnimalsEng.gf @@ -0,0 +1,16 @@ +--# -path=.:present:prelude +--resource/english:resource/abstract:resource/../prelude + +concrete AnimalsEng of Animals = QuestionsEng ** + open LangEng, ParadigmsEng, IrregEng in { + + lin + Dog = regN "dog" ; + Cat = regN "cat" ; + Mouse = mk2N "mouse" "mice" ; + Lion = regN "lion" ; + Zebra = regN "zebra" ; + Chase = dirV2 (regV "chase") ; + Eat = dirV2 eat_V ; + See = dirV2 see_V ; +} diff --git a/examples/animal/AnimalsFre.gf b/examples/animal/AnimalsFre.gf new file mode 100644 index 000000000..5c09490a1 --- /dev/null +++ b/examples/animal/AnimalsFre.gf @@ -0,0 +1,15 @@ +--# -path=.:present:prelude + +concrete AnimalsFre of Animals = QuestionsFre ** + open LangFre, ParadigmsFre, IrregFre in { + + lin + Dog = regN "chien" masculine ; + Cat = regN "chat" masculine ; + Mouse = regN "souris" feminine ; + Lion = regN "lion" masculine ; + Zebra = regN "zèbre" masculine ; + Chase = dirV2 (regV "chasser") ; + Eat = dirV2 (regV "manger") ; + See = voir_V2 ; +} diff --git a/examples/animal/AnimalsSwe.gf b/examples/animal/AnimalsSwe.gf new file mode 100644 index 000000000..34275ae16 --- /dev/null +++ b/examples/animal/AnimalsSwe.gf @@ -0,0 +1,15 @@ +--# -path=.:present:prelude + +concrete AnimalsSwe of Animals = QuestionsSwe ** + open LangSwe, ParadigmsSwe, IrregSwe in { + + lin + Dog = regN "hund" utrum ; + Cat = mk2N "katt" "katter" ; + Mouse = mkN "mus" "musen" "möss" "mössen" ; + Lion = mk2N "lejon" "lejon" ; + Zebra = regN "zebra" utrum ; + Chase = dirV2 (regV "jaga") ; + Eat = dirV2 äta_V ; + See = dirV2 se_V ; +} diff --git a/examples/animal/Questions.gf b/examples/animal/Questions.gf new file mode 100644 index 000000000..bb25e785d --- /dev/null +++ b/examples/animal/Questions.gf @@ -0,0 +1,10 @@ +-- Simple questions and answers, in present tense. + +abstract Questions = { + cat + Phrase ; Entity ; Action ; + fun + Who : Action -> Entity -> Phrase ; -- who chases X + Whom : Entity -> Action -> Phrase ; -- whom does X chase + Answer : Entity -> Action -> Entity -> Phrase ; -- X chases Y +} diff --git a/examples/animal/QuestionsEng.gf b/examples/animal/QuestionsEng.gf new file mode 100644 index 000000000..8a4c5c406 --- /dev/null +++ b/examples/animal/QuestionsEng.gf @@ -0,0 +1,2 @@ +concrete QuestionsEng of Questions = QuestionsI with + (Lang = LangEng) ; diff --git a/examples/animal/QuestionsFre.gf b/examples/animal/QuestionsFre.gf new file mode 100644 index 000000000..dab23b2ba --- /dev/null +++ b/examples/animal/QuestionsFre.gf @@ -0,0 +1,2 @@ +concrete QuestionsFre of Questions = QuestionsI with + (Lang = LangFre) ; diff --git a/examples/animal/QuestionsI.gf b/examples/animal/QuestionsI.gf new file mode 100644 index 000000000..f1f549283 --- /dev/null +++ b/examples/animal/QuestionsI.gf @@ -0,0 +1,22 @@ +-- File generated by GF from QuestionsI.gfe +--# -resource=../../lib/resource-1.0/english/LangEng.gf + +-- to compile: gf -examples QuestionsI.gfe +-- or use directly gf <mkAnimals.gfs + +incomplete concrete QuestionsI of Questions = open Lang in { + lincat + Phrase = Phr ; + Entity = N ; + Action = V2 ; + + lin + Who love_V2 man_N = PhrUtt NoPConj (UttAdv (AdvSC (EmbedQS (UseQCl TPres ASimul PPos (QuestVP whoSg_IP (ComplV2 love_V2 (DetCN (DetPl (PlQuant IndefArt) NoNum NoOrd) (UseN man_N)))))))) NoVoc ; -- AMBIGUOUS: +-- PhrUtt NoPConj (UttQS (UseQCl TPres ASimul PPos (QuestVP whoSg_IP (ComplV2 love_V2 (DetCN (DetPl (PlQuant IndefArt) NoNum NoOrd) (UseN man_N)))))) NoVoc ; + + Whom man_N love_V2 = PhrUtt NoPConj (UttQS (UseQCl TPres ASimul PPos (QuestSlash whoPl_IP (SlashV2 (DetCN (DetSg (SgQuant DefArt) NoOrd) (UseN man_N)) love_V2)))) NoVoc ; -- AMBIGUOUS: +-- PhrUtt NoPConj (UttQS (UseQCl TPres ASimul PPos (QuestSlash whoSg_IP (SlashV2 (DetCN (DetSg (SgQuant DefArt) NoOrd) (UseN man_N)) love_V2)))) NoVoc ; + + Answer woman_N love_V2 man_N = 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 ; + +} diff --git a/examples/animal/QuestionsI.gfe b/examples/animal/QuestionsI.gfe new file mode 100644 index 000000000..ee18106f2 --- /dev/null +++ b/examples/animal/QuestionsI.gfe @@ -0,0 +1,17 @@ +--# -resource=../../lib/resource-1.0/english/LangEng.gf + +-- to compile: gf -examples QuestionsI.gfe +-- or use directly gf <mkAnimals.gfs + +incomplete concrete QuestionsI of Questions = open Lang in { + lincat + Phrase = Phr ; + Entity = N ; + Action = V2 ; + + lin + Who love_V2 man_N = in Phr "who loves men" ; + Whom man_N love_V2 = in Phr "whom does the man love" ; + Answer woman_N love_V2 man_N = in Phr "the woman loves men" ; + +} diff --git a/examples/animal/QuestionsSwe.gf b/examples/animal/QuestionsSwe.gf new file mode 100644 index 000000000..9d59ecb2e --- /dev/null +++ b/examples/animal/QuestionsSwe.gf @@ -0,0 +1,2 @@ +concrete QuestionsSwe of Questions = QuestionsI with + (Lang = LangSwe) ; diff --git a/examples/animal/mkAnimals.gfs b/examples/animal/mkAnimals.gfs new file mode 100644 index 000000000..304263eb9 --- /dev/null +++ b/examples/animal/mkAnimals.gfs @@ -0,0 +1,4 @@ + i -ex AnimalsEng.gf ;; s + i AnimalsFre.gf ;; s + i AnimalsSwe.gf ;; s + pm | wf animals.gfcm diff --git a/src/GF/Compile/MkConcrete.hs b/src/GF/Compile/MkConcrete.hs index d96e3e774..c8b5e338e 100644 --- a/src/GF/Compile/MkConcrete.hs +++ b/src/GF/Compile/MkConcrete.hs @@ -18,10 +18,11 @@ import GF.Grammar.Values (Tree,tree2exp) import GF.Grammar.PrGrammar (prt_) import GF.Grammar.Grammar (Term(Q,QC)) --- import GF.Grammar.Macros (composSafeOp, record2subst) -import GF.Compile.ShellState (firstStateGrammar) +import GF.Compile.ShellState --(firstStateGrammar,stateGrammarWords) import GF.Compile.PGrammar (pTerm) import GF.Compile.Compile import GF.API +import GF.API.IOGrammar import qualified GF.Embed.EmbedAPI as EA import GF.Data.Operations @@ -43,9 +44,6 @@ import Data.List -- Format of resource path (on first line): -- --# -resource=PATH -- Other lines are copied verbatim. --- The resource has to be built with --- i -src -optimize=share SOURCE --- because mcfg parsing is used. -- A sequence of files can be processed with the same resource without -- rebuilding the grammar and parser. @@ -62,12 +60,12 @@ mkConcretes files = do mkCncGroups (res,files) = do putStrLnFlush $ "Going to preprocess examples in " ++ unwords files putStrLn $ "Compiling resource " ++ res - egr <- appIOE $ - optFile2grammar (options [beSilent]) res - -- [useOptimizer "share",fromSource,beSilent,notEmitCode]) res --- for -mcfg - gr <- err (\s -> putStrLn s >> error "resource file rejected") return egr - let parser cat = errVal ([],"No parse") . - optParseArgErrMsg (options [newMParser, firstCat cat, beVerbose]) gr + egr <- appIOE $ shellStateFromFiles (options [beSilent]) emptyShellState res + gr <- err (\s -> putStrLn s >> error "resource grammar rejected") + (return . firstStateGrammar) egr + let parser cat = + errVal ([],"No parse") . + optParseArgErrMsg (options [newMParser, firstCat cat, beVerbose]) gr let morpho = isKnownWord gr putStrLn "Building parser" mapM_ (mkConcrete parser morpho) files |
