mirror of
https://github.com/GrammaticalFramework/comp-syntax-gu-mlt.git
synced 2026-02-09 23:01:06 -07:00
rename stuff + new ud lab draft
This commit is contained in:
225
labs1-2/grammar/english/MicroLangEng.gf
Normal file
225
labs1-2/grammar/english/MicroLangEng.gf
Normal file
@@ -0,0 +1,225 @@
|
||||
--# -path=.:../abstract
|
||||
concrete MicroLangEng of MicroLang = open MicroResEng, Prelude in {
|
||||
|
||||
-----------------------------------------------------
|
||||
---------------- Grammar part -----------------------
|
||||
-----------------------------------------------------
|
||||
|
||||
lincat
|
||||
Utt = {s : Str} ;
|
||||
|
||||
S = {s : Str} ;
|
||||
VP = {verb : Verb ; compl : Str} ; ---s special case of Mini
|
||||
Comp = {s : Str} ;
|
||||
AP = Adjective ;
|
||||
CN = Noun ;
|
||||
NP = {s : Case => Str ; a : Agreement} ;
|
||||
Pron = {s : Case => Str ; a : Agreement} ;
|
||||
Det = {s : Str ; n : Number} ;
|
||||
Prep = {s : Str} ;
|
||||
V = Verb ;
|
||||
V2 = Verb2 ;
|
||||
A = Adjective ;
|
||||
N = Noun ;
|
||||
Adv = {s : Str} ;
|
||||
|
||||
lin
|
||||
UttS s = s ;
|
||||
UttNP np = {s = np.s ! Acc} ;
|
||||
|
||||
PredVPS np vp = {
|
||||
s = np.s ! Nom ++ vp.verb.s ! agr2vform np.a ++ vp.compl
|
||||
} ;
|
||||
|
||||
UseV v = {
|
||||
verb = v ;
|
||||
compl = [] ;
|
||||
} ;
|
||||
|
||||
ComplV2 v2 np = {
|
||||
verb = v2 ;
|
||||
compl = v2.c ++ np.s ! Acc -- NP object in the accusative, preposition first
|
||||
} ;
|
||||
|
||||
UseComp comp = {
|
||||
verb = be_Verb ; -- the verb is the copula "be"
|
||||
compl = comp.s
|
||||
} ;
|
||||
|
||||
CompAP ap = ap ;
|
||||
|
||||
AdvVP vp adv =
|
||||
vp ** {compl = vp.compl ++ adv.s} ;
|
||||
|
||||
DetCN det cn = {
|
||||
s = \\c => det.s ++ cn.s ! det.n ;
|
||||
a = Agr det.n ;
|
||||
} ;
|
||||
|
||||
UsePron p = p ;
|
||||
|
||||
a_Det = {s = pre {"a"|"e"|"i"|"o" => "an" ; _ => "a"} ; n = Sg} ; --- a/an can get wrong
|
||||
aPl_Det = {s = "" ; n = Pl} ;
|
||||
the_Det = {s = "the" ; n = Sg} ;
|
||||
thePl_Det = {s = "the" ; n = Pl} ;
|
||||
|
||||
UseN n = n ;
|
||||
|
||||
AdjCN ap cn = {
|
||||
s = table {n => ap.s ++ cn.s ! n}
|
||||
} ;
|
||||
|
||||
PositA a = a ;
|
||||
|
||||
PrepNP prep np = {s = prep.s ++ np.s ! Acc} ;
|
||||
|
||||
in_Prep = {s = "in"} ;
|
||||
on_Prep = {s = "on"} ;
|
||||
with_Prep = {s = "with"} ;
|
||||
|
||||
he_Pron = {
|
||||
s = table {Nom => "he" ; Acc => "him"} ;
|
||||
a = Agr Sg ;
|
||||
} ;
|
||||
she_Pron = {
|
||||
s = table {Nom => "she" ; Acc => "her"} ;
|
||||
a = Agr Sg ;
|
||||
} ;
|
||||
they_Pron = {
|
||||
s = table {Nom => "they" ; Acc => "them"} ;
|
||||
a = Agr Pl ;
|
||||
} ;
|
||||
|
||||
-----------------------------------------------------
|
||||
---------------- Lexicon part -----------------------
|
||||
-----------------------------------------------------
|
||||
|
||||
lin already_Adv = mkAdv "already" ;
|
||||
lin animal_N = mkN "animal" ;
|
||||
lin apple_N = mkN "apple" ;
|
||||
lin baby_N = mkN "baby" ;
|
||||
lin bad_A = mkA "bad" ;
|
||||
lin beer_N = mkN "beer" ;
|
||||
lin big_A = mkA "big" ;
|
||||
lin bike_N = mkN "bike" ;
|
||||
lin bird_N = mkN "bird" ;
|
||||
lin black_A = mkA "black" ;
|
||||
lin blood_N = mkN "blood" ;
|
||||
lin blue_A = mkA "blue" ;
|
||||
lin boat_N = mkN "boat" ;
|
||||
lin book_N = mkN "book" ;
|
||||
lin boy_N = mkN "boy" ;
|
||||
lin bread_N = mkN "bread" ;
|
||||
lin break_V2 = mkV2 (mkV "break" "broke" "broken") ;
|
||||
lin buy_V2 = mkV2 (mkV "buy" "bought" "bought") ;
|
||||
lin car_N = mkN "car" ;
|
||||
lin cat_N = mkN "cat" ;
|
||||
lin child_N = mkN "child" "children" ;
|
||||
lin city_N = mkN "city" ;
|
||||
lin clean_A = mkA "clean" ;
|
||||
lin clever_A = mkA "clever" ;
|
||||
lin cloud_N = mkN "cloud" ;
|
||||
lin cold_A = mkA "cold" ;
|
||||
lin come_V = mkV "come" "came" "come" ;
|
||||
lin computer_N = mkN "computer" ;
|
||||
lin cow_N = mkN "cow" ;
|
||||
lin dirty_A = mkA "dirty" ;
|
||||
lin dog_N = mkN "dog" ;
|
||||
lin drink_V2 = mkV2 (mkV "drink" "drank" "drunk") ;
|
||||
lin eat_V2 = mkV2 (mkV "eat" "ate" "eaten") ;
|
||||
lin find_V2 = mkV2 (mkV "find" "found" "found") ;
|
||||
lin fire_N = mkN "fire" ;
|
||||
lin fish_N = mkN "fish" "fish" ;
|
||||
lin flower_N = mkN "flower" ;
|
||||
lin friend_N = mkN "friend" ;
|
||||
lin girl_N = mkN "girl" ;
|
||||
lin good_A = mkA "good" ;
|
||||
lin go_V = mkV "go" "went" "gone" ;
|
||||
lin grammar_N = mkN "grammar" ;
|
||||
lin green_A = mkA "green" ;
|
||||
lin heavy_A = mkA "heavy" ;
|
||||
lin horse_N = mkN "horse" ;
|
||||
lin hot_A = mkA "hot" ;
|
||||
lin house_N = mkN "house" ;
|
||||
-- lin john_PN = mkPN "John" ;
|
||||
lin jump_V = mkV "jump" ;
|
||||
lin kill_V2 = mkV2 "kill" ;
|
||||
-- lin know_VS = mkVS (mkV "know" "knew" "known") ;
|
||||
lin language_N = mkN "language" ;
|
||||
lin live_V = mkV "live" ;
|
||||
lin love_V2 = mkV2 (mkV "love") ;
|
||||
lin man_N = mkN "man" "men" ;
|
||||
lin milk_N = mkN "milk" ;
|
||||
lin music_N = mkN "music" ;
|
||||
lin new_A = mkA "new" ;
|
||||
lin now_Adv = mkAdv "now" ;
|
||||
lin old_A = mkA "old" ;
|
||||
-- lin paris_PN = mkPN "Paris" ;
|
||||
lin play_V = mkV "play" ;
|
||||
lin read_V2 = mkV2 (mkV "read" "read" "read") ;
|
||||
lin ready_A = mkA "ready" ;
|
||||
lin red_A = mkA "red" ;
|
||||
lin river_N = mkN "river" ;
|
||||
lin run_V = mkV "run" "ran" "run" ;
|
||||
lin sea_N = mkN "sea" ;
|
||||
lin see_V2 = mkV2 (mkV "see" "saw" "seen") ;
|
||||
lin ship_N = mkN "ship" ;
|
||||
lin sleep_V = mkV "sleep" "slept" "slept" ;
|
||||
lin small_A = mkA "small" ;
|
||||
lin star_N = mkN "star" ;
|
||||
lin swim_V = mkV "swim" "swam" "swum" ;
|
||||
lin teach_V2 = mkV2 (mkV "teach" "taught" "taught") ;
|
||||
lin train_N = mkN "train" ;
|
||||
lin travel_V = mkV "travel" ;
|
||||
lin tree_N = mkN "tree" ;
|
||||
lin understand_V2 = mkV2 (mkV "understand" "understood" "understood") ;
|
||||
lin wait_V2 = mkV2 "wait" "for" ;
|
||||
lin walk_V = mkV "walk" ;
|
||||
lin warm_A = mkA "warm" ;
|
||||
lin water_N = mkN "water" ;
|
||||
lin white_A = mkA "white" ;
|
||||
lin wine_N = mkN "wine" ;
|
||||
lin woman_N = mkN "woman" "women" ;
|
||||
lin yellow_A = mkA "yellow" ;
|
||||
lin young_A = mkA "young" ;
|
||||
|
||||
---------------------------
|
||||
-- Paradigms part ---------
|
||||
---------------------------
|
||||
|
||||
oper
|
||||
mkN = overload {
|
||||
mkN : Str -> Noun -- predictable noun, e.g. car-cars, boy-boys, fly-flies, bush-bushes
|
||||
= \n -> lin N (smartNoun n) ;
|
||||
mkN : Str -> Str -> Noun -- irregular noun, e.g. man-men
|
||||
= \sg,pl -> lin N (mkNoun sg pl) ;
|
||||
} ;
|
||||
|
||||
mkA : Str -> A
|
||||
= \s -> lin A {s = s} ;
|
||||
|
||||
mkV = overload {
|
||||
mkV : (inf : Str) -> V -- predictable verb, e.g. play-plays, cry-cries, wash-washes
|
||||
= \s -> lin V (smartVerb s) ;
|
||||
mkV : (inf,pres,part : Str) -> V -- irregular verb, e.g. drink-drank-drunk
|
||||
= \inf,pres,part -> lin V (irregVerb inf pres part) ;
|
||||
} ;
|
||||
|
||||
mkV2 = overload {
|
||||
mkV2 : Str -> V2 -- predictable verb with direct object, e.g. "wash"
|
||||
= \s -> lin V2 (smartVerb s ** {c = []}) ;
|
||||
mkV2 : Str -> Str -> V2 -- predictable verb with preposition, e.g. "wait - for"
|
||||
= \s,p -> lin V2 (smartVerb s ** {c = p}) ;
|
||||
mkV2 : V -> V2 -- any verb with direct object, e.g. "drink"
|
||||
= \v -> lin V2 (v ** {c = []}) ;
|
||||
mkV2 : V -> Str -> V2 -- any verb with preposition
|
||||
= \v,p -> lin V2 (v ** {c = p}) ;
|
||||
} ;
|
||||
|
||||
mkAdv : Str -> Adv
|
||||
= \s -> lin Adv {s = s} ;
|
||||
|
||||
mkPrep : Str -> Prep
|
||||
= \s -> lin Prep {s = s} ;
|
||||
|
||||
}
|
||||
1
labs1-2/grammar/english/MicroLangEng.labels
Normal file
1
labs1-2/grammar/english/MicroLangEng.labels
Normal file
@@ -0,0 +1 @@
|
||||
UseComp {"es","sont"} AUX cop head
|
||||
75
labs1-2/grammar/english/MicroResEng.gf
Normal file
75
labs1-2/grammar/english/MicroResEng.gf
Normal file
@@ -0,0 +1,75 @@
|
||||
resource MicroResEng = open Prelude in {
|
||||
|
||||
param
|
||||
Number = Sg | Pl ;
|
||||
Case = Nom | Acc ;
|
||||
|
||||
|
||||
Agreement = Agr Number ; ---s Person to be added
|
||||
|
||||
-- all forms of normal Eng verbs, although not yet used in MiniGrammar
|
||||
VForm = Inf | PresSg3 | Past | PastPart | PresPart ;
|
||||
|
||||
oper
|
||||
Noun : Type = {s : Number => Str} ;
|
||||
|
||||
mkNoun : Str -> Str -> Noun = \sg,pl -> {
|
||||
s = table {Sg => sg ; Pl => pl}
|
||||
} ;
|
||||
|
||||
regNoun : Str -> Noun = \sg -> mkNoun sg (sg + "s") ;
|
||||
|
||||
-- smart paradigm
|
||||
smartNoun : Str -> Noun = \sg -> case sg of {
|
||||
_ + ("ay"|"ey"|"oy"|"uy") => regNoun sg ;
|
||||
x + "y" => mkNoun sg (x + "ies") ;
|
||||
_ + ("ch"|"sh"|"s"|"o") => mkNoun sg (sg + "es") ;
|
||||
_ => regNoun sg
|
||||
} ;
|
||||
|
||||
Adjective : Type = {s : Str} ;
|
||||
|
||||
Verb : Type = {s : VForm => Str} ;
|
||||
|
||||
mkVerb : (inf,pres,past,pastpart,prespart : Str) -> Verb
|
||||
= \inf,pres,past,pastpart,prespart -> {
|
||||
s = table {
|
||||
Inf => inf ;
|
||||
PresSg3 => pres ;
|
||||
Past => past ;
|
||||
PastPart => pastpart ;
|
||||
PresPart => prespart
|
||||
}
|
||||
} ;
|
||||
|
||||
regVerb : (inf : Str) -> Verb = \inf ->
|
||||
mkVerb inf (inf + "s") (inf + "ed") (inf + "ed") (inf + "ing") ;
|
||||
|
||||
-- regular verbs with predictable variations
|
||||
smartVerb : Str -> Verb = \inf -> case inf of {
|
||||
pl + ("a"|"e"|"i"|"o"|"u") + "y" => regVerb inf ;
|
||||
cr + "y" => mkVerb inf (cr + "ies") (cr + "ied") (cr + "ied") (inf + "ing") ;
|
||||
lov + "e" => mkVerb inf (inf + "s") (lov + "ed") (lov + "ed") (lov + "ing") ;
|
||||
kis + ("s"|"sh"|"x"|"o") => mkVerb inf (inf + "es") (inf + "ed") (inf + "ed") (inf + "ing") ;
|
||||
_ => regVerb inf
|
||||
} ;
|
||||
|
||||
-- normal irregular verbs e.g. drink,drank,drunk
|
||||
irregVerb : (inf,past,pastpart : Str) -> Verb =
|
||||
\inf,past,pastpart ->
|
||||
let verb = smartVerb inf
|
||||
in mkVerb inf (verb.s ! PresSg3) past pastpart (verb.s ! PresPart) ;
|
||||
|
||||
-- two-place verb with "case" as preposition; for transitive verbs, c=[]
|
||||
Verb2 : Type = Verb ** {c : Str} ;
|
||||
|
||||
be_Verb : Verb = mkVerb "are" "is" "was" "been" "being" ; ---s to be generalized
|
||||
|
||||
|
||||
---s a very simplified verb agreement function for Micro
|
||||
agr2vform : Agreement -> VForm = \a -> case a of {
|
||||
Agr Sg => PresSg3 ;
|
||||
Agr Pl => Inf
|
||||
} ;
|
||||
|
||||
}
|
||||
234
labs1-2/grammar/english/MiniGrammarEng.gf
Normal file
234
labs1-2/grammar/english/MiniGrammarEng.gf
Normal file
@@ -0,0 +1,234 @@
|
||||
--# -path=.:../abstract
|
||||
concrete MiniGrammarEng of MiniGrammar = open MiniResEng, Prelude in {
|
||||
|
||||
|
||||
lincat
|
||||
Utt = {s : Str} ;
|
||||
Pol = {s : Str ; isTrue : Bool} ; -- the s field is empty, but needed for parsing
|
||||
Temp = {s : Str ; isPres : Bool} ;
|
||||
|
||||
S = {s : Str} ;
|
||||
QS = {s : Str} ;
|
||||
Cl = { -- word order is fixed in S and QS
|
||||
subj : Str ; -- subject
|
||||
verb : Bool => Bool => {fin,inf : Str} ; -- dep. on Pol,Temp, e.g. "does","sleep"
|
||||
compl : Str -- after verb: complement, adverbs
|
||||
} ;
|
||||
QCl = Cl ** {isWh : Bool} ;
|
||||
Imp = {s : Bool => Str} ;
|
||||
VP = {verb : GVerb ; compl : Str} ;
|
||||
Comp = {s : Str} ;
|
||||
AP = Adjective ;
|
||||
CN = Noun ;
|
||||
NP = {s : Case => Str ; a : Agreement} ;
|
||||
IP = {s : Case => Str ; a : Agreement} ;
|
||||
Pron = {s : Case => Str ; a : Agreement} ;
|
||||
Det = {s : Str ; n : Number} ;
|
||||
Conj = {s : Str} ;
|
||||
Prep = {s : Str} ;
|
||||
V = Verb ;
|
||||
V2 = Verb2 ;
|
||||
VS = Verb ;
|
||||
VV = Verb ; ---- only VV to VP
|
||||
A = Adjective ;
|
||||
N = Noun ;
|
||||
PN = {s : Str} ;
|
||||
Adv = {s : Str} ;
|
||||
IAdv = {s : Str} ;
|
||||
|
||||
lin
|
||||
UttS s = s ;
|
||||
UttQS s = s ;
|
||||
UttNP np = {s = np.s ! Acc} ; -- Acc: produce "me" rather than "I"
|
||||
UttAdv adv = adv ;
|
||||
UttIAdv iadv = iadv ;
|
||||
UttImpSg pol imp = {s = pol.s ++ imp.s ! pol.isTrue} ;
|
||||
|
||||
UseCl temp pol cl =
|
||||
let clt = cl.verb ! pol.isTrue ! temp.isPres -- isTrue regulates if "do" is used
|
||||
in {
|
||||
s = pol.s ++ temp.s ++ --- needed for parsing: a GF hack
|
||||
cl.subj ++ -- she
|
||||
clt.fin ++ -- does
|
||||
negation pol.isTrue ++ -- not
|
||||
clt.inf ++ -- drink
|
||||
cl.compl -- beer
|
||||
} ;
|
||||
|
||||
UseQCl temp pol qcl =
|
||||
let
|
||||
isWh = qcl.isWh ;
|
||||
clt = qcl.verb ! andB isWh pol.isTrue ! temp.isPres ; -- no "do" in present positive Wh questions
|
||||
verbsubj = case isWh of {
|
||||
True => qcl.subj ++ clt.fin ; -- no inversion in Wh questions
|
||||
False => clt.fin ++ qcl.subj
|
||||
}
|
||||
|
||||
in {
|
||||
s = pol.s ++ temp.s ++
|
||||
verbsubj ++
|
||||
negation pol.isTrue ++ -- not
|
||||
clt.inf ++ -- drink
|
||||
qcl.compl -- beer
|
||||
} ;
|
||||
|
||||
PredVP np vp = {
|
||||
subj = np.s ! Nom ;
|
||||
compl = vp.compl ;
|
||||
verb = \\plain,isPres => case <vp.verb.isAux, plain, isPres, np.a> of {
|
||||
|
||||
-- non-auxiliary verbs, negative/question present: "does (not) drink"
|
||||
<False,False,True,Agr Sg Per3> => {fin = "does" ; inf = vp.verb.s ! VF Inf} ;
|
||||
<False,False,True,_ > => {fin = "do" ; inf = vp.verb.s ! VF Inf} ;
|
||||
|
||||
-- non-auxiliary, plain present ; auxiliary, all present: "drinks", "is (not)"
|
||||
<_,_, True, Agr Sg Per1> => {fin = vp.verb.s ! PresSg1 ; inf = []} ;
|
||||
<_,_, True, Agr Sg Per3> => {fin = vp.verb.s ! VF PresSg3 ; inf = []} ;
|
||||
<_,_, True, _> => {fin = vp.verb.s ! PresPl ; inf = []} ;
|
||||
|
||||
-- all verbs, past: "has (not) drunk", "has (not) been"
|
||||
<_,_, False,Agr Sg Per3> => {fin = "has" ; inf = vp.verb.s ! VF PastPart} ;
|
||||
<_,_, False,_ > => {fin = "have" ; inf = vp.verb.s ! VF PastPart}
|
||||
|
||||
-- the negation word "not" is put in place in UseCl, UseQCl
|
||||
}
|
||||
} ;
|
||||
|
||||
QuestCl cl = cl ** {isWh = False} ; -- since the parts are the same, we don't need to change anything
|
||||
|
||||
QuestVP ip vp = PredVP ip vp ** {isWh = True} ;
|
||||
|
||||
ImpVP vp = {
|
||||
s = table {
|
||||
True => vp.verb.s ! VF Inf ++ vp.compl ; -- in Eng, imperative = infinitive
|
||||
False => "do not" ++ vp.verb.s ! VF Inf ++ vp.compl
|
||||
}
|
||||
} ;
|
||||
|
||||
UseV v = {
|
||||
verb = verb2gverb v ; -- lift ordinary verbs to generalized verbs
|
||||
compl = []
|
||||
} ;
|
||||
|
||||
ComplV2 v2 np = {
|
||||
verb = verb2gverb v2 ;
|
||||
compl = v2.c ++ np.s ! Acc -- NP object in the accusative, preposition first
|
||||
} ;
|
||||
|
||||
ComplVS vs s = {
|
||||
verb = verb2gverb vs ;
|
||||
compl = "that" ++ s.s ;
|
||||
} ;
|
||||
|
||||
ComplVV vv vp = {
|
||||
verb = verb2gverb vv ;
|
||||
compl = "to" ++ vp.verb.s ! VF Inf ++ vp.compl ;
|
||||
} ;
|
||||
|
||||
UseComp comp = {
|
||||
verb = be_GVerb ; -- the verb is the copula "be"
|
||||
compl = comp.s
|
||||
} ;
|
||||
|
||||
CompAP ap = ap ;
|
||||
|
||||
CompNP np = {
|
||||
s = np.s ! Nom -- NP complement is in the nominative
|
||||
} ;
|
||||
|
||||
CompAdv adv = adv ;
|
||||
|
||||
AdvVP vp adv =
|
||||
vp ** {compl = vp.compl ++ adv.s} ;
|
||||
|
||||
DetCN det cn = {
|
||||
s = table {c => det.s ++ cn.s ! det.n} ;
|
||||
a = Agr det.n Per3 -- this kind of NP is always third person
|
||||
} ;
|
||||
|
||||
UsePN pn = {
|
||||
s = \\_ => pn.s ;
|
||||
a = Agr Sg Per3
|
||||
} ;
|
||||
|
||||
UsePron p = p ; -- Pron is worst-case NP
|
||||
|
||||
MassNP cn = {
|
||||
s = \\_ => cn.s ! Sg ;
|
||||
a = Agr Sg Per3
|
||||
} ;
|
||||
|
||||
a_Det = {s = pre {"a"|"e"|"i"|"o" => "an" ; _ => "a"} ; n = Sg} ; --- a/an can get wrong
|
||||
aPl_Det = {s = "" ; n = Pl} ;
|
||||
the_Det = {s = "the" ; n = Sg} ;
|
||||
thePl_Det = {s = "the" ; n = Pl} ;
|
||||
|
||||
UseN n = n ;
|
||||
|
||||
AdjCN ap cn = {
|
||||
s = table {n => ap.s ++ cn.s ! n}
|
||||
} ;
|
||||
|
||||
PositA a = a ;
|
||||
|
||||
PrepNP prep np = {s = prep.s ++ np.s ! Acc} ;
|
||||
|
||||
CoordS conj a b = {s = a.s ++ conj.s ++ b.s} ;
|
||||
|
||||
PPos = {s = [] ; isTrue = True} ;
|
||||
PNeg = {s = [] ; isTrue = False} ;
|
||||
|
||||
TSim = {s = [] ; isPres = True} ;
|
||||
TAnt = {s = [] ; isPres = False} ;
|
||||
|
||||
and_Conj = {s = "and"} ;
|
||||
or_Conj = {s = "or"} ;
|
||||
|
||||
every_Det = {s = "every" ; n = Sg} ;
|
||||
|
||||
in_Prep = {s = "in"} ;
|
||||
on_Prep = {s = "on"} ;
|
||||
with_Prep = {s = "with"} ;
|
||||
|
||||
i_Pron = {
|
||||
s = table {Nom => "I" ; Acc => "me"} ;
|
||||
a = Agr Sg Per1
|
||||
} ;
|
||||
youSg_Pron = {
|
||||
s = \\_ => "you" ;
|
||||
a = Agr Sg Per2
|
||||
} ;
|
||||
he_Pron = {
|
||||
s = table {Nom => "he" ; Acc => "him"} ;
|
||||
a = Agr Sg Per3
|
||||
} ;
|
||||
she_Pron = {
|
||||
s = table {Nom => "she" ; Acc => "her"} ;
|
||||
a = Agr Sg Per3
|
||||
} ;
|
||||
we_Pron = {
|
||||
s = table {Nom => "we" ; Acc => "us"} ;
|
||||
a = Agr Pl Per1
|
||||
} ;
|
||||
youPl_Pron = {
|
||||
s = \\_ => "you" ;
|
||||
a = Agr Pl Per2
|
||||
} ;
|
||||
they_Pron = {
|
||||
s = table {Nom => "they" ; Acc => "them"} ;
|
||||
a = Agr Pl Per3
|
||||
} ;
|
||||
|
||||
whoSg_IP = {
|
||||
s = table {Nom => "who" ; Acc => "whom"} ;
|
||||
a = Agr Sg Per3
|
||||
} ;
|
||||
|
||||
where_IAdv = {s = "where"} ;
|
||||
why_IAdv = {s = "why"} ;
|
||||
|
||||
have_V2 = mkVerb "have" "has" "had" "had" "having" ** {c = []} ;
|
||||
|
||||
want_VV = regVerb "want" ;
|
||||
|
||||
}
|
||||
3
labs1-2/grammar/english/MiniLangEng.gf
Normal file
3
labs1-2/grammar/english/MiniLangEng.gf
Normal file
@@ -0,0 +1,3 @@
|
||||
--# -path=.:../abstract
|
||||
|
||||
concrete MiniLangEng of MiniLang = MiniGrammarEng, MiniLexiconEng ;
|
||||
6
labs1-2/grammar/english/MiniLangEng.labels
Normal file
6
labs1-2/grammar/english/MiniLangEng.labels
Normal file
@@ -0,0 +1,6 @@
|
||||
UseCl, UseQCl, ImpVP {"not"} PART advmod head
|
||||
UseComp {"is","are","am","was","were","been","be"} AUX cop head
|
||||
PredVP, QuestVP {"has","had","have","do","does"} AUX aux head
|
||||
ImpVP {"do"} AUX aux head
|
||||
ComplVS {"that"} SCONJ mark ccomp
|
||||
ComplVV {"to"} PART mark xcomp
|
||||
94
labs1-2/grammar/english/MiniLexiconEng.gf
Normal file
94
labs1-2/grammar/english/MiniLexiconEng.gf
Normal file
@@ -0,0 +1,94 @@
|
||||
concrete MiniLexiconEng of MiniLexicon = MiniGrammarEng **
|
||||
open
|
||||
MiniParadigmsEng
|
||||
in {
|
||||
lin already_Adv = mkAdv "already" ;
|
||||
lin animal_N = mkN "animal" ;
|
||||
lin apple_N = mkN "apple" ;
|
||||
lin baby_N = mkN "baby" ;
|
||||
lin bad_A = mkA "bad" ;
|
||||
lin beer_N = mkN "beer" ;
|
||||
lin big_A = mkA "big" ;
|
||||
lin bike_N = mkN "bike" ;
|
||||
lin bird_N = mkN "bird" ;
|
||||
lin black_A = mkA "black" ;
|
||||
lin blood_N = mkN "blood" ;
|
||||
lin blue_A = mkA "blue" ;
|
||||
lin boat_N = mkN "boat" ;
|
||||
lin book_N = mkN "book" ;
|
||||
lin boy_N = mkN "boy" ;
|
||||
lin bread_N = mkN "bread" ;
|
||||
lin break_V2 = mkV2 (mkV "break" "broke" "broken") ;
|
||||
lin buy_V2 = mkV2 (mkV "buy" "bought" "bought") ;
|
||||
lin car_N = mkN "car" ;
|
||||
lin cat_N = mkN "cat" ;
|
||||
lin child_N = mkN "child" "children" ;
|
||||
lin city_N = mkN "city" ;
|
||||
lin clean_A = mkA "clean" ;
|
||||
lin clever_A = mkA "clever" ;
|
||||
lin cloud_N = mkN "cloud" ;
|
||||
lin cold_A = mkA "cold" ;
|
||||
lin come_V = mkV "come" "came" "come" ;
|
||||
lin computer_N = mkN "computer" ;
|
||||
lin cow_N = mkN "cow" ;
|
||||
lin dirty_A = mkA "dirty" ;
|
||||
lin dog_N = mkN "dog" ;
|
||||
lin drink_V2 = mkV2 (mkV "drink" "drank" "drunk") ;
|
||||
lin eat_V2 = mkV2 (mkV "eat" "ate" "eaten") ;
|
||||
lin find_V2 = mkV2 (mkV "find" "found" "found") ;
|
||||
lin fire_N = mkN "fire" ;
|
||||
lin fish_N = mkN "fish" "fish" ;
|
||||
lin flower_N = mkN "flower" ;
|
||||
lin friend_N = mkN "friend" ;
|
||||
lin girl_N = mkN "girl" ;
|
||||
lin good_A = mkA "good" ;
|
||||
lin go_V = mkV "go" "went" "gone" ;
|
||||
lin grammar_N = mkN "grammar" ;
|
||||
lin green_A = mkA "green" ;
|
||||
lin heavy_A = mkA "heavy" ;
|
||||
lin horse_N = mkN "horse" ;
|
||||
lin hot_A = mkA "hot" ;
|
||||
lin house_N = mkN "house" ;
|
||||
lin john_PN = mkPN "John" ;
|
||||
lin jump_V = mkV "jump" ;
|
||||
lin kill_V2 = mkV2 "kill" ;
|
||||
lin know_VS = mkVS (mkV "know" "knew" "known") ;
|
||||
lin language_N = mkN "language" ;
|
||||
lin live_V = mkV "live" ;
|
||||
lin love_V2 = mkV2 (mkV "love") ;
|
||||
lin man_N = mkN "man" "men" ;
|
||||
lin milk_N = mkN "milk" ;
|
||||
lin music_N = mkN "music" ;
|
||||
lin new_A = mkA "new" ;
|
||||
lin now_Adv = mkAdv "now" ;
|
||||
lin old_A = mkA "old" ;
|
||||
lin paris_PN = mkPN "Paris" ;
|
||||
lin play_V = mkV "play" ;
|
||||
lin read_V2 = mkV2 (mkV "read" "read" "read") ;
|
||||
lin ready_A = mkA "ready" ;
|
||||
lin red_A = mkA "red" ;
|
||||
lin river_N = mkN "river" ;
|
||||
lin run_V = mkV "run" "ran" "run" ;
|
||||
lin sea_N = mkN "sea" ;
|
||||
lin see_V2 = mkV2 (mkV "see" "saw" "seen") ;
|
||||
lin ship_N = mkN "ship" ;
|
||||
lin sleep_V = mkV "sleep" "slept" "slept" ;
|
||||
lin small_A = mkA "small" ;
|
||||
lin star_N = mkN "star" ;
|
||||
lin swim_V = mkV "swim" "swam" "swum" ;
|
||||
lin teach_V2 = mkV2 (mkV "teach" "taught" "taught") ;
|
||||
lin train_N = mkN "train" ;
|
||||
lin travel_V = mkV "travel" ;
|
||||
lin tree_N = mkN "tree" ;
|
||||
lin understand_V2 = mkV2 (mkV "understand" "understood" "understood") ;
|
||||
lin wait_V2 = mkV2 "wait" "for" ;
|
||||
lin walk_V = mkV "walk" ;
|
||||
lin warm_A = mkA "warm" ;
|
||||
lin water_N = mkN "water" ;
|
||||
lin white_A = mkA "white" ;
|
||||
lin wine_N = mkN "wine" ;
|
||||
lin woman_N = mkN "woman" "women" ;
|
||||
lin yellow_A = mkA "yellow" ;
|
||||
lin young_A = mkA "young" ;
|
||||
|
||||
}
|
||||
49
labs1-2/grammar/english/MiniParadigmsEng.gf
Normal file
49
labs1-2/grammar/english/MiniParadigmsEng.gf
Normal file
@@ -0,0 +1,49 @@
|
||||
resource MiniParadigmsEng = open
|
||||
|
||||
MiniGrammarEng,
|
||||
MiniResEng
|
||||
|
||||
in {
|
||||
|
||||
oper
|
||||
mkN = overload {
|
||||
mkN : Str -> Noun -- predictable noun, e.g. car-cars, boy-boys, fly-flies, bush-bushes
|
||||
= \n -> lin N (smartNoun n) ;
|
||||
mkN : Str -> Str -> Noun -- irregular noun, e.g. man-men
|
||||
= \sg,pl -> lin N (mkNoun sg pl) ;
|
||||
} ;
|
||||
|
||||
mkPN : Str -> PN
|
||||
= \s -> lin PN {s = s} ;
|
||||
|
||||
mkA : Str -> A
|
||||
= \s -> lin A {s = s} ;
|
||||
|
||||
mkV = overload {
|
||||
mkV : (inf : Str) -> V -- predictable verb, e.g. play-plays, cry-cries, wash-washes
|
||||
= \s -> lin V (smartVerb s) ;
|
||||
mkV : (inf,pres,part : Str) -> V -- irregular verb, e.g. drink-drank-drunk
|
||||
= \inf,pres,part -> lin V (irregVerb inf pres part) ;
|
||||
} ;
|
||||
|
||||
mkV2 = overload {
|
||||
mkV2 : Str -> V2 -- predictable verb with direct object, e.g. "wash"
|
||||
= \s -> lin V2 (smartVerb s ** {c = []}) ;
|
||||
mkV2 : Str -> Str -> V2 -- predictable verb with preposition, e.g. "wait - for"
|
||||
= \s,p -> lin V2 (smartVerb s ** {c = p}) ;
|
||||
mkV2 : V -> V2 -- any verb with direct object, e.g. "drink"
|
||||
= \v -> lin V2 (v ** {c = []}) ;
|
||||
mkV2 : V -> Str -> V2 -- any verb with preposition
|
||||
= \v,p -> lin V2 (v ** {c = p}) ;
|
||||
} ;
|
||||
|
||||
mkVS : V -> VS
|
||||
= \v -> lin VS v ;
|
||||
|
||||
mkAdv : Str -> Adv
|
||||
= \s -> lin Adv {s = s} ;
|
||||
|
||||
mkPrep : Str -> Prep
|
||||
= \s -> lin Prep {s = s} ;
|
||||
|
||||
}
|
||||
99
labs1-2/grammar/english/MiniResEng.gf
Normal file
99
labs1-2/grammar/english/MiniResEng.gf
Normal file
@@ -0,0 +1,99 @@
|
||||
resource MiniResEng = open Prelude in {
|
||||
|
||||
param
|
||||
Number = Sg | Pl ;
|
||||
Case = Nom | Acc ;
|
||||
Person = Per1 | Per2 | Per3 ;
|
||||
|
||||
Agreement = Agr Number Person ;
|
||||
|
||||
-- all forms of normal Eng verbs, although not yet used in MiniGrammar
|
||||
VForm = Inf | PresSg3 | Past | PastPart | PresPart ;
|
||||
|
||||
oper
|
||||
Noun : Type = {s : Number => Str} ;
|
||||
|
||||
mkNoun : Str -> Str -> Noun = \sg,pl -> {
|
||||
s = table {Sg => sg ; Pl => pl}
|
||||
} ;
|
||||
|
||||
regNoun : Str -> Noun = \sg -> mkNoun sg (sg + "s") ;
|
||||
|
||||
-- smart paradigm
|
||||
smartNoun : Str -> Noun = \sg -> case sg of {
|
||||
_ + ("ay"|"ey"|"oy"|"uy") => regNoun sg ;
|
||||
x + "y" => mkNoun sg (x + "ies") ;
|
||||
_ + ("ch"|"sh"|"s"|"o") => mkNoun sg (sg + "es") ;
|
||||
_ => regNoun sg
|
||||
} ;
|
||||
|
||||
Adjective : Type = {s : Str} ;
|
||||
|
||||
Verb : Type = {s : VForm => Str} ;
|
||||
|
||||
mkVerb : (inf,pres,past,pastpart,prespart : Str) -> Verb
|
||||
= \inf,pres,past,pastpart,prespart -> {
|
||||
s = table {
|
||||
Inf => inf ;
|
||||
PresSg3 => pres ;
|
||||
Past => past ;
|
||||
PastPart => pastpart ;
|
||||
PresPart => prespart
|
||||
}
|
||||
} ;
|
||||
|
||||
regVerb : (inf : Str) -> Verb = \inf ->
|
||||
mkVerb inf (inf + "s") (inf + "ed") (inf + "ed") (inf + "ing") ;
|
||||
|
||||
-- regular verbs with predictable variations
|
||||
smartVerb : Str -> Verb = \inf -> case inf of {
|
||||
pl + ("a"|"e"|"i"|"o"|"u") + "y" => regVerb inf ;
|
||||
cr + "y" => mkVerb inf (cr + "ies") (cr + "ied") (cr + "ied") (inf + "ing") ;
|
||||
lov + "e" => mkVerb inf (inf + "s") (lov + "ed") (lov + "ed") (lov + "ing") ;
|
||||
kis + ("s"|"sh"|"x"|"o") => mkVerb inf (inf + "es") (inf + "ed") (inf + "ed") (inf + "ing") ;
|
||||
_ => regVerb inf
|
||||
} ;
|
||||
|
||||
-- normal irregular verbs e.g. drink,drank,drunk
|
||||
irregVerb : (inf,past,pastpart : Str) -> Verb =
|
||||
\inf,past,pastpart ->
|
||||
let verb = smartVerb inf
|
||||
in mkVerb inf (verb.s ! PresSg3) past pastpart (verb.s ! PresPart) ;
|
||||
|
||||
negation : Bool -> Str = \b -> case b of {True => [] ; False => "not"} ;
|
||||
|
||||
-- two-place verb with "case" as preposition; for transitive verbs, c=[]
|
||||
Verb2 : Type = Verb ** {c : Str} ;
|
||||
|
||||
-- generalized verb, here just "be"
|
||||
param
|
||||
GVForm = VF VForm | PresSg1 | PresPl | PastPl ;
|
||||
|
||||
oper
|
||||
GVerb : Type = {
|
||||
s : GVForm => Str ;
|
||||
isAux : Bool
|
||||
} ;
|
||||
|
||||
be_GVerb : GVerb = {
|
||||
s = table {
|
||||
PresSg1 => "am" ;
|
||||
PresPl => "are" ;
|
||||
PastPl => "were" ;
|
||||
VF vf => (mkVerb "be" "is" "was" "been" "being").s ! vf
|
||||
} ;
|
||||
isAux = True
|
||||
} ;
|
||||
|
||||
-- in VP formation, all verbs are lifted to GVerb, but morphology doesn't need to know this
|
||||
verb2gverb : Verb -> GVerb = \v -> {s =
|
||||
table {
|
||||
PresSg1 => v.s ! Inf ;
|
||||
PresPl => v.s ! Inf ;
|
||||
PastPl => v.s ! Past ;
|
||||
VF vf => v.s ! vf
|
||||
} ;
|
||||
isAux = False
|
||||
} ;
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user