diff options
| author | aarne <aarne@chalmers.se> | 2011-03-14 18:48:08 +0000 |
|---|---|---|
| committer | aarne <aarne@chalmers.se> | 2011-03-14 18:48:08 +0000 |
| commit | a59df6b49575f54756615c6e2b860ea0972a81eb (patch) | |
| tree | f0c657f7250295f6dfc27903370bfbf189bd9146 /examples | |
| parent | b9ebd48a2c70cf1dd62b84dbdab3e4048593ddd3 (diff) | |
started a grammar for grammatical terms, covering the cats of the RGL
Diffstat (limited to 'examples')
| -rw-r--r-- | examples/grammar-terms/GrammarTerms.gf | 103 | ||||
| -rw-r--r-- | examples/grammar-terms/GrammarTermsEng.gf | 143 | ||||
| -rw-r--r-- | examples/grammar-terms/GrammarTermsGF.gf | 109 | ||||
| -rw-r--r-- | examples/grammar-terms/MkTerms.hs | 13 |
4 files changed, 368 insertions, 0 deletions
diff --git a/examples/grammar-terms/GrammarTerms.gf b/examples/grammar-terms/GrammarTerms.gf new file mode 100644 index 000000000..c87555fa2 --- /dev/null +++ b/examples/grammar-terms/GrammarTerms.gf @@ -0,0 +1,103 @@ +abstract GrammarTerms = { + +flags startcat = Rule ; + +cat + Rule ; + Cat ; + ParamType ; + ParamValue ; + Language ; + [Cat] {1} ; + [ParamType] {1} ; + +fun + RuleFun : Cat -> [Cat] -> Rule ; + RuleInherent : Cat -> [ParamType] -> Rule ; + RuleVariable : Cat -> [ParamType] -> Rule ; + +fun + CatA : Cat ; + CatA2 : Cat ; + CatAP : Cat ; + CatAdA : Cat ; + CatAdN : Cat ; + CatAdV : Cat ; + CatAdv : Cat ; + CatAnt : Cat ; + CatCAdv : Cat ; + CatCN : Cat ; + CatCard : Cat ; + CatCl : Cat ; + CatClSlash : Cat ; + CatComp : Cat ; + CatConj : Cat ; + CatDet : Cat ; + CatDig : Cat ; + CatDigits : Cat ; + CatIAdv : Cat ; + CatIComp : Cat ; + CatIDet : Cat ; + CatIP : Cat ; + CatIQuant : Cat ; + CatImp : Cat ; + CatImpForm : Cat ; + CatInterj : Cat ; + CatListAP : Cat ; + CatListAdv : Cat ; + CatListNP : Cat ; + CatListRS : Cat ; + CatListS : Cat ; + CatN : Cat ; + CatN2 : Cat ; + CatN3 : Cat ; + CatNP : Cat ; + CatNum : Cat ; + CatNumeral : Cat ; + CatOrd : Cat ; + CatPConj : Cat ; + CatPN : Cat ; + CatPhr : Cat ; + CatPol : Cat ; + CatPredet : Cat ; + CatPrep : Cat ; + CatPron : Cat ; + CatPunct : Cat ; + CatQCl : Cat ; + CatQS : Cat ; + CatQuant : Cat ; + CatRCl : Cat ; + CatRP : Cat ; + CatRS : Cat ; + CatS : Cat ; + CatSC : Cat ; + CatSSlash : Cat ; + CatSub100 : Cat ; + CatSub1000 : Cat ; + CatSubj : Cat ; + CatTemp : Cat ; + CatTense : Cat ; + CatText : Cat ; + CatUnit : Cat ; + CatUtt : Cat ; + CatV : Cat ; + CatV2 : Cat ; + CatV2A : Cat ; + CatV2Q : Cat ; + CatV2S : Cat ; + CatV2V : Cat ; + CatV3 : Cat ; + CatVA : Cat ; + CatVP : Cat ; + CatVPSlash : Cat ; + CatVQ : Cat ; + CatVS : Cat ; + CatVV : Cat ; + CatVoc : Cat ; + + PTGender : ParamType ; + PTNumber : ParamType ; + PTCase : ParamType ; + PTTense : ParamType ; + +} diff --git a/examples/grammar-terms/GrammarTermsEng.gf b/examples/grammar-terms/GrammarTermsEng.gf new file mode 100644 index 000000000..301020549 --- /dev/null +++ b/examples/grammar-terms/GrammarTermsEng.gf @@ -0,0 +1,143 @@ +--# -path=.:present + +concrete GrammarTermsEng of GrammarTerms = + open SyntaxEng, (S = SyntaxEng), ParadigmsEng, (P = ParadigmsEng) in { + +lincat + Rule = Utt ; + Cat = CN ; + ParamType = CN ; + ParamValue = NP ; + Language = {name : CN ; adj : AP} ; + [Cat] = NP ; + [ParamType] = {indef, bare : NP} ; + +lin + RuleFun c cs = + mkUtt (mkS (mkCl (mkNP a_Det c) (mkVP can_VV + (mkVP (passiveVP construct_V2) (S.mkAdv from_Prep cs))))) ; + RuleInherent c ps = + mkUtt (mkS (mkCl (mkNP aPl_Det c) have_V2 ps.indef)) ; + RuleVariable c ps = + mkUtt (mkS (mkCl (mkNP aPl_Det c) + (mkVP (passiveVP inflect_V2) (S.mkAdv for_Prep ps.bare)))) ; + +oper + construct_V2 = mkV2 "construct" ; + inflect_V2 = mkV2 "inflect" ; + +lin + BaseCat c = mkNP a_Det c ; + ConsCat c cs = mkNP and_Conj (mkNP a_Det c) cs ; + + BaseParamType c = { + indef = mkNP a_Det c ; + bare = mkNP c + } ; + ConsParamType c cs = { + indef = mkNP and_Conj (mkNP a_Det c) cs.indef ; + bare = mkNP and_Conj (mkNP c) cs.bare + } ; + +lin + CatA = mkCN (mkN "adjective") ; + CatA2 = mkCN (mkN "two-place adjective") ; + CatAP = mkCN (mkA "adjectival") (mkN "phrase") ; + CatAdA = mkCN (mkA "adjective-modifying") (mkN "adverb") ; + CatAdN = mkCN (mkN "numeral-modifying adverb") ; + CatAdV = mkCN (mkN "sentential adverb") ; + CatAdv = mkCN (mkN "verb-phrase-modifying adverb") ; + CatAnt = mkCN (mkN "anteriority") ; + CatCAdv = mkCN (mkN "comparative adverb") ; + CatCN = mkCN (mkN "common noun phrase") ; + CatCard = mkCN (mkN "cardinal number") ; + CatCl = mkCN (mkN "declarative clause") ; + CatClSlash = slash (mkCN (mkN "clause")) ; + CatComp = funOf (mkN "complement") (mkN "copula") ; + CatConj = mkCN (mkN "conjunction") ; + CatDet = mkCN (mkN "determiner phrase") ; + CatDig = mkCN (mkN "digit") ; + CatDigits = funOfPl (mkN "sequence") (mkN "digit") ; + CatIAdv = mkCN (mkN "interrogative adverb") ; + CatIComp = + mkCN (mkA "interrogative") (funOf (mkN "complement") (mkN "copula")) ; + CatIDet = mkCN (mkN "interrogative determiner") ; + CatIP = mkCN (mkN "interrogative pronoun") ; + CatIQuant = mkCN (mkN "interrogative quantifier") ; + CatImp = mkCN (mkN "imperative") ; + CatImpForm = funOf (mkN "form") (mkN "imperative") ; + CatInterj = mkCN (mkN "interjection") ; + CatListAP = funOfPl (mkN "list") (mkN "adjectival phrase") ; + CatListAdv = funOfPl (mkN "list") (mkN "adverb") ; + CatListNP = funOfPl (mkN "list") (mkN "noun phrase") ; + CatListRS = funOfPl (mkN "list") (mkN "relative clause") ; + CatListS = funOfPl (mkN "list") (mkN "sentence") ; + CatN = mkCN (mkN "noun") ; + CatN2 = mkCN (mkN "two-place relational noun") ; + CatN3 = mkCN (mkN "three-place relational noun") ; + CatNP = mkCN (mkN "noun phrase") ; + CatNum = mkCN (mkN "number-determining element") ; + CatNumeral = mkCN (mkN "numeral expression") ; + CatOrd = mkCN (mkN "ordinal") ; + CatPConj = mkCN (mkN "phrase conjunction") ; + CatPN = mkCN (mkN "proper name") ; + CatPhr = mkCN (mkN "phrase") (S.mkAdv in_Prep (mkNP a_Det (mkN "text"))) ; + CatPol = mkCN (mkN "polarity") ; + CatPredet = mkCN (mkN "predeterminer") ; + CatPrep = mkCN (mkN "preposition") ; + CatPron = mkCN (mkN "personal pronoun") ; + CatPunct = mkCN (mkN "punctuation mark") ; + CatQCl = mkCN (mkN "question clause") ; + CatQS = mkCN (mkN "question") ; + CatQuant = mkCN (mkN "quantifier") ; + CatRCl = mkCN (mkN "relative clause") ; + CatRP = mkCN (mkN "relative pronoun") ; + CatRS = mkCN (mkN "relative sentence") ; + CatS = mkCN (mkN "declarative sentence") ; + CatSC = mkCN (mkN "embedded clause") ; + CatSSlash = slash (mkCN (mkN "sentence")) ; + CatSub100 = mkCN (mkN "numeral") (S.mkAdv under_Prep (mkNP (mkPN "100"))) ; + CatSub1000 = mkCN (mkN "numeral") (S.mkAdv under_Prep (mkNP (mkPN "1000"))) ; + CatSubj = mkCN (mkN "subjunction") ; + CatTemp = mkCN (mkN "temporal and aspectual feature") ; + CatTense = mkCN (mkN "tense") ; + CatText = mkCN (mkN "text") ; + CatUnit = mkCN (mkN "numeral") (S.mkAdv under_Prep (mkNP (mkPN "10"))) ; + CatUtt = mkCN (mkN "utterance") ; + CatV = mkCN (mkN "intransitive verb") ; + CatV2 = mkCN (mkN "two-place verb") ; + CatV2A = + mkCN (mkN "verb") (P.mkAdv "with noun phrase and adjective complements") ; + CatV2Q = + mkCN (mkN "verb") (P.mkAdv "with noun phrase and question complements") ; + CatV2S = + mkCN (mkN "verb") (P.mkAdv "with noun phrase and sentence complements") ; + CatV2V = + mkCN (mkN "verb") (P.mkAdv "with noun phrase and verb phrase complements") ; + CatV3 = mkCN (mkN "three-place verb") ; + CatVA = + mkCN (mkN "verb") (P.mkAdv "with an adjective complement") ; + CatVP = mkCN (mkN "verb phrase") ; + CatVPSlash = slash (mkCN (mkN "verb phrase")) ; + CatVQ = + mkCN (mkN "verb") (P.mkAdv "with a question complement") ; + CatVS = + mkCN (mkN "verb") (P.mkAdv "with a sentence complement") ; + CatVV = + mkCN (mkN "verb") (P.mkAdv "with a verb-phrase complement") ; + CatVoc = mkCN (mkN "vocative") ; + + PTGender = mkCN (mkN "gender") ; + PTNumber = mkCN (mkN "number") ; + PTCase = mkCN (mkN "case") ; + PTTense = mkCN (mkN "tense") ; + +oper + slash : CN -> CN = \cn -> + mkCN (mkAP (mkA2 (mkA "missing") []) (mkNP a_Det (mkN "noun phrase"))) cn ; + + funOf : N -> N -> CN = \f,x -> + mkCN (mkN2 f possess_Prep) (mkNP a_Det x) ; + funOfPl : N -> N -> CN = \f,x -> + mkCN (mkN2 f possess_Prep) (mkNP aPl_Det x) ; +} diff --git a/examples/grammar-terms/GrammarTermsGF.gf b/examples/grammar-terms/GrammarTermsGF.gf new file mode 100644 index 000000000..268be0588 --- /dev/null +++ b/examples/grammar-terms/GrammarTermsGF.gf @@ -0,0 +1,109 @@ +concrete GrammarTermsGF of GrammarTerms = + open Prelude in { + +lincat + Rule = Str ; + Cat = Str ; + ParamType = Str ; + ParamValue = Str ; + Language = Str ; + [Cat] = Str ; + [ParamType] = Str ; + +lin + RuleFun c cs = cs ++ "->" ++ c ; + RuleInherent c ps = "lincat" ++ c ++ ":" ++ "{" ++ ps ++ "}" ; + RuleVariable c ps = "lincat" ++ c ++ ":" ++ ps ++ "=>" ++ "Str" ; + +lin + BaseCat c = c ; + ConsCat c cs = c ++ "->" ++ cs ; + + BaseParamType c = c ; + ConsParamType c cs = c ++ "," ++ cs ; + +lin + CatA = "A" ; + CatA2 = "A2" ; + CatAP = "AP" ; + CatAdA = "AdA" ; + CatAdN = "AdN" ; + CatAdV = "AdV" ; + CatAdv = "Adv" ; + CatAnt = "Ant" ; + CatCAdv = "CAdv" ; + CatCN = "CN" ; + CatCard = "Card" ; + CatCl = "Cl" ; + CatClSlash = "ClSlash" ; + CatComp = "Comp" ; + CatConj = "Conj" ; + CatDet = "Det" ; + CatDig = "Dig" ; + CatDigits = "Digits" ; + CatIAdv = "IAdv" ; + CatIComp = "IComp" ; + CatIDet = "IDet" ; + CatIP = "IP" ; + CatIQuant = "IQuant" ; + CatImp = "Imp" ; + CatImpForm = "ImpForm" ; + CatInterj = "Interj" ; + CatListAP = "ListAP" ; + CatListAdv = "ListAdv" ; + CatListNP = "ListNP" ; + CatListRS = "ListRS" ; + CatListS = "ListS" ; + CatN = "N" ; + CatN2 = "N2" ; + CatN3 = "N3" ; + CatNP = "NP" ; + CatNum = "Num" ; + CatNumeral = "Numeral" ; + CatOrd = "Ord" ; + CatPConj = "PConj" ; + CatPN = "PN" ; + CatPhr = "Phr" ; + CatPol = "Pol" ; + CatPredet = "Predet" ; + CatPrep = "Prep" ; + CatPron = "Pron" ; + CatPunct = "Punct" ; + CatQCl = "QCl" ; + CatQS = "QS" ; + CatQuant = "Quant" ; + CatRCl = "RCl" ; + CatRP = "RP" ; + CatRS = "RS" ; + CatS = "S" ; + CatSC = "SC" ; + CatSSlash = "SSlash" ; + CatSub100 = "Sub100" ; + CatSub1000 = "Sub1000" ; + CatSubj = "Subj" ; + CatTemp = "Temp" ; + CatTense = "Tense" ; + CatText = "Text" ; + CatUnit = "Unit" ; + CatUtt = "Utt" ; + CatV = "V" ; + CatV2 = "V2" ; + CatV2A = "V2A" ; + CatV2Q = "V2Q" ; + CatV2S = "V2S" ; + CatV2V = "V2V" ; + CatV3 = "V3" ; + CatVA = "VA" ; + CatVP = "VP" ; + CatVPSlash = "VPSlash" ; + CatVQ = "VQ" ; + CatVS = "VS" ; + CatVV = "VV" ; + CatVoc = "Voc" ; + + PTGender = "Gender" ; + PTNumber = "Number" ; + PTCase = "Case" ; + PTTense = "Tense" ; + +} diff --git a/examples/grammar-terms/MkTerms.hs b/examples/grammar-terms/MkTerms.hs new file mode 100644 index 000000000..62daa55bd --- /dev/null +++ b/examples/grammar-terms/MkTerms.hs @@ -0,0 +1,13 @@ +main = interact (unlines . map (mkTerm . words) . lines) + +mkTerm ws = case ws of + "==":cat:"-":expl -> unlines [ + mkFun "Cat" cat, + mkLin "Cat" "mkN" cat (unwords (takeWhile (/= "==") expl)) + ] + +mkFun pref s = unwords ["fun", pref ++ s, ":", pref, ";"] +---mkLin pref p s e = unwords ["lin", pref ++ s, "=", p, quoted e, ";"] +mkLin pref p s e = unwords ["lin", pref ++ s, "=", quoted s, ";"] + +quoted s = "\"" ++ s ++ "\"" |
