From f847344de8b0b378b60f4646c8037abd456e4faf Mon Sep 17 00:00:00 2001 From: aarne Date: Mon, 3 Oct 2011 14:17:56 +0000 Subject: [PATCH] demo grammar for the resource: mini/MiniGrammar. Generated automatically from MiniGrammarEng by make. Will replace the old demo/ grammars as one that illustrates the grammar structures while being lighter than Lang and generating less junk. --- lib/src/demo/DemoFin.gf | 22 ++++- lib/src/mini/Makefile | 10 +++ lib/src/mini/MiniGrammar.gf | 141 +++++++++++++++++++++++++++++++ lib/src/mini/MiniGrammarEng.gf | 147 +++++++++++++++++++++++++++++++++ lib/src/mini/MkMini.hs | 18 ++++ 5 files changed, 337 insertions(+), 1 deletion(-) create mode 100644 lib/src/mini/Makefile create mode 100644 lib/src/mini/MiniGrammar.gf create mode 100644 lib/src/mini/MiniGrammarEng.gf create mode 100644 lib/src/mini/MkMini.hs diff --git a/lib/src/demo/DemoFin.gf b/lib/src/demo/DemoFin.gf index 7a256c5bf..6d5f230be 100644 --- a/lib/src/demo/DemoFin.gf +++ b/lib/src/demo/DemoFin.gf @@ -1,6 +1,26 @@ --# -path=.:alltenses -concrete DemoFin of Demo = LangFin ** +concrete DemoFin of Demo = LangFin - [ + PredetNP, PPartNP, AdvNP, RelNP, DetNP, DetQuantOrd, + NumDigits, AdNum, OrdDigits, OrdNumeral, OrdSuperl, MassNP, + ComplN2, ComplN3, UseN2, Use2N3, Use3N3, AdjCN, RelCN, + AdvCN, SentCN, ApposCN, + PassV2, CompAdv, + -- CompNP, + SlashV2V, SlashV2VNP, --- + ComparA, ComplA2, ReflA2, UseA2, UseComparA, CAdvAP, AdjOrd, SentAP, AdAP, + PredSCVP, AdvSlash, SlashPrep, SlashVS, + EmbedS, EmbedQS, EmbedVP, UseSlash, AdvS, RelS, + CompIP, + PConjConj, VocNP, UttVP, + FunRP, + nothing_NP, nobody_NP, please_Voc, otherwise_PConj, therefore_PConj, but_PConj, + language_title_Utt, whatPl_IP, whoPl_IP, if_then_Conj, either7or_DConj, + both7and_DConj, much_Det, that_Subj, no_Quant, + ImpersCl, GenericCl, CleftNP, CleftAdv, ProgrVP, ImpPl1, ImpP3, + -- ExistNP, --- + ConsNP, ConsAdv, ConsS, ConsRS, ConsAP + ] ** open LangFin in { lin diff --git a/lib/src/mini/Makefile b/lib/src/mini/Makefile new file mode 100644 index 000000000..accbc4c5c --- /dev/null +++ b/lib/src/mini/Makefile @@ -0,0 +1,10 @@ +all: src pgf + +src: + runghc MkMini.hs + +pgf: src + gf -make -optimize-pgf MiniGrammar???.gf +RTS -K100M + +gf: src + gf -batch MiniGrammar???.gf diff --git a/lib/src/mini/MiniGrammar.gf b/lib/src/mini/MiniGrammar.gf new file mode 100644 index 000000000..5ce1e73cd --- /dev/null +++ b/lib/src/mini/MiniGrammar.gf @@ -0,0 +1,141 @@ +--# -path=.:alltenses + +abstract MiniGrammar = Lexicon, Grammar [ + +-- the "mini" resource of GF book, chapter 9 + +-- cat + S, -- sentence + Cl, -- clause + NP, -- noun phrase + VP, -- verb phrase + AP, -- adjectival phrase + CN, -- common noun + Det, -- determiner + N, -- noun + A, -- adjective + V, -- verb (one-place, intransitive) + V2, -- two-place verb (two-place, transitive or prepositional) + AdA, -- ad-adjective + Tense, -- tense + Pol, -- polarity + Conj, -- conjunction + +-- fun + UseCl , -- Tense -> Pol -> Cl -> S, + PredVP , -- NP -> VP -> Cl, +--- ComplV2, -- V2 -> NP -> VP, + DetCN , -- Det -> CN -> NP, +--- ModCN , -- AP -> CN -> CN, + +--- CompAP , -- AP -> VP, + AdAP , -- AdA -> AP -> AP, + +--- ConjS , -- Conj -> S -> S -> S, +--- ConjAP , -- Conj -> AP -> AP -> AP, +--- ConjNP , -- Conj -> NP -> NP -> NP, + + UseV , -- V -> VP, + UseN , -- N -> CN, + PositA, -- A -> AP, + +--- a_Det, the_Det, + every_Det, -- Det, +--- this_Det, these_Det, -- Det, +--- that_Det, those_Det, -- Det, +--- i_NP, youSg_NP, he_NP, she_NP, we_NP, youPl_NP, they_NP, -- NP, + very_AdA, -- AdA, + + TTAnt, -- Tense -> Ant -> Temp ; + PPos, PNeg, -- Pol, + TPres, TPast, TFut, TCond, -- Tense, + ASimul, AAnter, + + and_Conj, or_Conj, -- Conj, + +-- extension of the mini grammar + +-- cat + Utt, -- utterance (sentence or question) e.g. "does she walk" + QS, -- question (fixed tense) e.g. "who doesn't walk" + QCl, -- question clause (variable tense) e.g. "who walks" + ClSlash, -- clause missing noun phrase e.g. "she walks with" + Adv, -- adverb e.g. "here" + Prep, -- preposition (and/or case) e.g. "with" + VS, -- sentence-complement verb e.g. "know" + VQ, -- question-complement verb e.g. "wonder" + VV, -- verb-phrase-complement verb e.g. "want" + IP, -- interrogative pronoun e.g. "who" + PN, -- proper name e.g. "John" + Subj, -- subjunction e.g. "because" + IAdv, -- interrogative adverb e.g. "why" + + ListAP, + ListNP, + ListS, + Temp, + Comp, + Ant, + Imp, + +-- fun + UttS , -- S -> Utt, + UttQS, -- QS -> Utt, + + UseQCl, -- Tense -> Pol -> QCl -> QS, + + QuestCl , -- Cl -> QCl, -- does she walk + QuestVP , -- IP -> VP -> QCl, -- who walks + QuestSlash, -- IP -> ClSlash -> QCl, -- who does she walk with + QuestIAdv , -- IAdv -> Cl -> QCl, -- why does she walk + +--- SubjCl, -- Cl -> Subj -> S -> Cl, -- she walks because we run + +--- CompAdv, -- Adv -> VP, -- be here + PrepNP , -- Prep -> NP -> Adv, -- in the house + + ComplVS, -- VS -> S -> VP, -- know that she walks + ComplVQ, -- VQ -> QS -> VP, -- wonder who walks + ComplVV, -- VV -> VP -> VP, -- want to walk + +--- SlashV2 , -- NP -> V2 -> ClSlash, -- she loves +--- SlashPrep, -- Cl -> Prep -> ClSlash, -- she walks with + + AdvVP, -- VP -> Adv -> VP, -- walk in the city + + UsePN, -- PN -> NP, -- John +--- AdvNP, -- NP -> Adv -> NP, -- the man in the city + + who_IP , -- IP, + here_Adv, -- Adv, + by_Prep, in_Prep, of_Prep, with_Prep, -- Prep, + can_VV, must_VV, want_VV, -- VV, + although_Subj, because_Subj, when_Subj, -- Subj, + when_IAdv, where_IAdv, why_IAdv-- IAdv, + +] ** { + +flags startcat = Utt ; + +-- functions with different type + +fun + ComplV2 : V2 -> NP -> VP ; + ModCN : AP -> CN -> CN ; + CompAP : AP -> VP ; + ConjS : Conj -> S -> S -> S ; + ConjAP : Conj -> AP -> AP -> AP ; + ConjNP : Conj -> NP -> NP -> NP ; + a_Det, the_Det : Det ; + this_Det, these_Det : Det ; + that_Det, those_Det : Det ; + i_NP, youSg_NP, he_NP, she_NP, we_NP, youPl_NP, they_NP : NP ; + SubjS : S -> Subj -> S -> S ; -- she walks because we run + CompAdv : Adv -> VP ; -- be here + SlashV2 : NP -> V2 -> ClSlash ; -- she loves + SlashPrep : Cl -> Prep -> ClSlash ; -- she walks with + AdvCN : CN -> Prep -> NP -> CN ; -- man in the city + + +} + diff --git a/lib/src/mini/MiniGrammarEng.gf b/lib/src/mini/MiniGrammarEng.gf new file mode 100644 index 000000000..76a20a926 --- /dev/null +++ b/lib/src/mini/MiniGrammarEng.gf @@ -0,0 +1,147 @@ +--# -path=.:alltenses + +concrete MiniGrammarEng of MiniGrammar = LexiconEng, GrammarEng [ + +-- the "mini" resource of GF book, chapter 9 + +-- cat + S, -- sentence + Cl, -- clause + NP, -- noun phrase + VP, -- verb phrase + AP, -- adjectival phrase + CN, -- common noun + Det, -- determiner + N, -- noun + A, -- adjective + V, -- verb (one-place, intransitive) + V2, -- two-place verb (two-place, transitive or prepositional) + AdA, -- ad-adjective + Tense, -- tense + Pol, -- polarity + Conj, -- conjunction + +-- fun + UseCl , -- Tense -> Pol -> Cl -> S, + PredVP , -- NP -> VP -> Cl, +--- ComplV2, -- V2 -> NP -> VP, + DetCN , -- Det -> CN -> NP, +--- ModCN , -- AP -> CN -> CN, + +--- CompAP , -- AP -> VP, + AdAP , -- AdA -> AP -> AP, + +--- ConjS , -- Conj -> S -> S -> S, +--- ConjAP , -- Conj -> AP -> AP -> AP, +--- ConjNP , -- Conj -> NP -> NP -> NP, + + UseV , -- V -> VP, + UseN , -- N -> CN, + PositA, -- A -> AP, + +--- a_Det, the_Det, + every_Det, -- Det, +--- this_Det, these_Det, -- Det, +--- that_Det, those_Det, -- Det, +--- i_NP, youSg_NP, he_NP, she_NP, we_NP, youPl_NP, they_NP, -- NP, + very_AdA, -- AdA, + + TTAnt, -- Tense -> Ant -> Temp ; + PPos, PNeg, -- Pol, + TPres, TPast, TFut, TCond, -- Tense, + ASimul, AAnter, + + and_Conj, or_Conj, -- Conj, + +-- extension of the mini grammar + +-- cat + Utt, -- utterance (sentence or question) e.g. "does she walk" + QS, -- question (fixed tense) e.g. "who doesn't walk" + QCl, -- question clause (variable tense) e.g. "who walks" + ClSlash, -- clause missing noun phrase e.g. "she walks with" + Adv, -- adverb e.g. "here" + Prep, -- preposition (and/or case) e.g. "with" + VS, -- sentence-complement verb e.g. "know" + VQ, -- question-complement verb e.g. "wonder" + VV, -- verb-phrase-complement verb e.g. "want" + IP, -- interrogative pronoun e.g. "who" + PN, -- proper name e.g. "John" + Subj, -- subjunction e.g. "because" + IAdv, -- interrogative adverb e.g. "why" + + ListAP, + ListNP, + ListS, + Temp, + Comp, + Ant, + + Imp, Bool, True, False, Voc, + +-- fun + UttS , -- S -> Utt, + UttQS, -- QS -> Utt, + + UseQCl, -- Tense -> Pol -> QCl -> QS, + + QuestCl , -- Cl -> QCl, -- does she walk + QuestVP , -- IP -> VP -> QCl, -- who walks + QuestSlash, -- IP -> ClSlash -> QCl, -- who does she walk with + QuestIAdv , -- IAdv -> Cl -> QCl, -- why does she walk + +--- SubjCl, -- Cl -> Subj -> S -> Cl, -- she walks because we run + +--- CompAdv, -- Adv -> VP, -- be here + PrepNP , -- Prep -> NP -> Adv, -- in the house + +--- ComplVS, -- VS -> S -> VP, -- know that she walks +--- ComplVQ, -- VQ -> QS -> VP, -- wonder who walks +--- ComplVV, -- VV -> VP -> VP, -- want to walk + +--- SlashV2 , -- NP -> V2 -> ClSlash, -- she loves +--- SlashPrep, -- Cl -> Prep -> ClSlash, -- she walks with + + AdvVP, -- VP -> Adv -> VP, -- walk in the city + + UsePN, -- PN -> NP, -- John +--- AdvNP, -- NP -> Adv -> NP, -- the man in the city + + who_IP , -- IP, + here_Adv, -- Adv, + by_Prep, in_Prep, of_Prep, with_Prep, -- Prep, + can_VV, must_VV, want_VV, -- VV, + although_Subj, because_Subj, when_Subj, -- Subj, + when_IAdv, where_IAdv, why_IAdv-- IAdv, + +] ** open SyntaxEng, (S = SyntaxEng) in { + +-- functions with different type + +lin + ComplV2 v np = mkVP v np ; + ModCN ap cn = lin CN (mkCN ) ; + CompAP ap = mkVP (lin AP ap) ; + ConjS co x y = mkS co x y ; + ConjAP co x y = mkAP co x y ; + ConjNP co x y = mkNP co x y ; + a_Det = mkDet a_Quant ; + the_Det = mkDet the_Quant ; + this_Det = S.this_Det ; + these_Det = S.these_Det ; + that_Det = S.that_Det ; + those_Det = S.those_Det ; + i_NP = S.i_NP ; + youSg_NP = S.you_NP ; + he_NP = S.he_NP ; + she_NP = S.she_NP ; + we_NP = S.we_NP ; + youPl_NP = S.youPl_NP ; + they_NP = S.they_NP ; +-- SubjS s subj s = mkS s (mkAdv subj s) ; + CompAdv adv = mkVP adv ; +-- SlashV2 np v2 = mkClSlash np v2 ; + SlashPrep cl p = mkClSlash cl p ; + AdvCN cn p pp = mkCN (mkAdv p pp) ; + +} diff --git a/lib/src/mini/MkMini.hs b/lib/src/mini/MkMini.hs new file mode 100644 index 000000000..6a160ba55 --- /dev/null +++ b/lib/src/mini/MkMini.hs @@ -0,0 +1,18 @@ +src = "Eng" +langs = ["Afr","Bul","Cat","Dan","Dut","Fin","Fre","Ger","Ita", + "Nep","Nor","Pes","Pol","Pnb","Ron","Rus","Spa","Swe","Urd"] + +file lng = "MiniGrammar" ++ lng ++ ".gf" + +main = do + s <- readFile (file src) + mapM_ (mkMiniFile s) langs + +mkMiniFile s lng = + writeFile (file lng) (mkMini lng s) + +mkMini lng s = case s of + 'E':'n':'g':cs -> lng ++ mkMini lng cs + c:cs -> c : mkMini lng cs + _ -> s +