mirror of
https://github.com/GrammaticalFramework/comp-syntax-gu-mlt.git
synced 2026-02-09 06:41:07 -07:00
intro grammars from the lecture
This commit is contained in:
35
lab2/intro/Intro.gf
Normal file
35
lab2/intro/Intro.gf
Normal file
@@ -0,0 +1,35 @@
|
|||||||
|
abstract Intro = {
|
||||||
|
|
||||||
|
cat
|
||||||
|
S ;
|
||||||
|
NP ;
|
||||||
|
VP ;
|
||||||
|
CN ;
|
||||||
|
Det ;
|
||||||
|
Pron ;
|
||||||
|
Subj ;
|
||||||
|
N ;
|
||||||
|
A ;
|
||||||
|
V2 ;
|
||||||
|
Adv ;
|
||||||
|
|
||||||
|
fun
|
||||||
|
PredVP : NP -> VP -> S ;
|
||||||
|
AdvS : S -> Adv -> S ;
|
||||||
|
ComplV2 : V2 -> NP -> VP ;
|
||||||
|
DetCN : Det -> CN -> NP ;
|
||||||
|
UsePron : Pron -> NP ;
|
||||||
|
AdjCN : A -> CN -> CN ;
|
||||||
|
UseN : N -> CN ;
|
||||||
|
SubjS : Subj -> S -> Adv ;
|
||||||
|
|
||||||
|
the_Det : Det ;
|
||||||
|
we_Pron : Pron ;
|
||||||
|
because_Subj : Subj ;
|
||||||
|
|
||||||
|
cat_N : N ;
|
||||||
|
black_A : A ;
|
||||||
|
see_V2 : V2 ;
|
||||||
|
now_Adv : Adv ;
|
||||||
|
|
||||||
|
}
|
||||||
39
lab2/intro/IntroEng.gf
Normal file
39
lab2/intro/IntroEng.gf
Normal file
@@ -0,0 +1,39 @@
|
|||||||
|
concrete IntroEng of Intro = {
|
||||||
|
|
||||||
|
lincat
|
||||||
|
S = Str ;
|
||||||
|
NP = {s : Case => Str ; a : Agr} ;
|
||||||
|
VP = Agr => Str ;
|
||||||
|
CN = Str ;
|
||||||
|
Det = Str ;
|
||||||
|
Pron = {s : Case => Str ; a : Agr} ;
|
||||||
|
Subj = Str ;
|
||||||
|
N = Str ;
|
||||||
|
A = Str ;
|
||||||
|
V2 = Agr => Str ;
|
||||||
|
Adv = Str ;
|
||||||
|
|
||||||
|
lin
|
||||||
|
PredVP np vp = np.s ! Nom ++ vp ! np.a ;
|
||||||
|
AdvS s adv = s ++ adv ;
|
||||||
|
ComplV2 v2 np = table {a => v2 ! a ++ np.s ! Acc} ;
|
||||||
|
DetCN det cn = {s = table {_ => det ++ cn} ; a = SgP3} ;
|
||||||
|
UsePron pron = pron ;
|
||||||
|
AdjCN a cn = a ++ cn ;
|
||||||
|
UseN n = n ;
|
||||||
|
SubjS subj s = subj ++ s ;
|
||||||
|
|
||||||
|
the_Det = "the" ;
|
||||||
|
we_Pron = {s = table {Nom => "we" ; Acc => "us"} ; a = Other} ;
|
||||||
|
because_Subj = "because" ;
|
||||||
|
|
||||||
|
cat_N = "cat" ;
|
||||||
|
black_A = "black" ;
|
||||||
|
see_V2 = table {SgP3 => "sees" ; Other => "see"} ;
|
||||||
|
now_Adv = "now" ;
|
||||||
|
|
||||||
|
param
|
||||||
|
Case = Nom | Acc ;
|
||||||
|
Agr = SgP3 | Other ;
|
||||||
|
|
||||||
|
}
|
||||||
43
lab2/intro/IntroFre.gf
Normal file
43
lab2/intro/IntroFre.gf
Normal file
@@ -0,0 +1,43 @@
|
|||||||
|
concrete IntroFre of Intro = {
|
||||||
|
|
||||||
|
lincat
|
||||||
|
S = Str ;
|
||||||
|
NP = {s : Case => Str ; a : Agr ; t : NPType} ;
|
||||||
|
VP = Agr => Str ;
|
||||||
|
CN = Str ;
|
||||||
|
Det = Str ;
|
||||||
|
Pron = {s : Case => Str ; a : Agr} ;
|
||||||
|
Subj = Str ;
|
||||||
|
N = Str ;
|
||||||
|
A = Str ;
|
||||||
|
V2 = Agr => Str ;
|
||||||
|
Adv = Str ;
|
||||||
|
|
||||||
|
lin
|
||||||
|
PredVP np vp = np.s ! Nom ++ vp ! np.a ;
|
||||||
|
AdvS s adv = s ++ adv ;
|
||||||
|
ComplV2 v2 np = case np.t of {
|
||||||
|
NPPron => table {a => np.s ! Acc ++ v2 ! a} ;
|
||||||
|
NPOther => table {a => v2 ! a ++ np.s ! Acc}
|
||||||
|
} ;
|
||||||
|
DetCN det cn = {s = table {_ => det ++ cn} ; a = SgP3 ; t = NPOther} ;
|
||||||
|
UsePron pron = pron ** {t = NPPron} ;
|
||||||
|
AdjCN a cn = cn ++ a ;
|
||||||
|
UseN n = n ;
|
||||||
|
SubjS subj s = subj ++ s ;
|
||||||
|
|
||||||
|
the_Det = "le" ;
|
||||||
|
we_Pron = {s = table {Nom => "nous" ; Acc => "nous"} ; a = Other} ;
|
||||||
|
because_Subj = "parce que" ;
|
||||||
|
|
||||||
|
cat_N = "chat" ;
|
||||||
|
black_A = "noir" ;
|
||||||
|
see_V2 = table {SgP3 => "voit" ; Other => "voyons"} ;
|
||||||
|
now_Adv = "maintenant" ;
|
||||||
|
|
||||||
|
param
|
||||||
|
Case = Nom | Acc ;
|
||||||
|
Agr = SgP3 | Other ;
|
||||||
|
NPType = NPPron | NPOther ;
|
||||||
|
|
||||||
|
}
|
||||||
37
lab2/intro/english.cf
Normal file
37
lab2/intro/english.cf
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
-- a tiny context-free grammar for English
|
||||||
|
-- subcategories with _ in them are an unscalable hack
|
||||||
|
|
||||||
|
-- combination rules
|
||||||
|
|
||||||
|
S ::= NP_subj_3 VP_3 | NP_subj VP | S Adv ;
|
||||||
|
|
||||||
|
VP ::= V2 NP_obj ;
|
||||||
|
VP_3 ::= V2_3 NP_obj ;
|
||||||
|
|
||||||
|
NP_subj_3 ::= Det CN | Pron_subj_3 ;
|
||||||
|
NP_subj ::= Pron_subj ;
|
||||||
|
NP_obj ::= Det CN | Pron_obj ;
|
||||||
|
|
||||||
|
CN ::= A N ;
|
||||||
|
|
||||||
|
Adv ::= Subj S ;
|
||||||
|
|
||||||
|
-- structural words
|
||||||
|
|
||||||
|
Det ::= "the" ;
|
||||||
|
|
||||||
|
Pron_subj ::= "we" ;
|
||||||
|
Pron_obj ::= "us" ;
|
||||||
|
|
||||||
|
Subj ::= "because" ;
|
||||||
|
|
||||||
|
-- content words
|
||||||
|
|
||||||
|
N ::= "cat" ;
|
||||||
|
A ::= "black" ;
|
||||||
|
V2_3 ::= "sees" ;
|
||||||
|
V2 ::= "see" ;
|
||||||
|
Adv ::= "now" ;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Reference in New Issue
Block a user