experimenting with English VP

This commit is contained in:
aarne
2005-11-22 22:00:47 +00:00
parent 712272f0e4
commit e79321be37
30 changed files with 255 additions and 8875 deletions

View File

@@ -0,0 +1,13 @@
abstract Cat = {
cat
S ;
Cl ;
VP ;
NP ;
AP ;
Comp ;
V ;
V2 ;
VV ;
Adv ;
}

View File

@@ -0,0 +1,16 @@
concrete CatEng of Cat = open ResEng in {
lincat
S = {s : Str} ;
Cl = {s : Tense => Anteriority => Ord => Pol => Str} ;
VP = {
s : Tense => Anteriority => Ord => Pol => Agr => {fin, inf : Str} ;
s2 : Agr => Str
} ;
NP = {s : Case => Str ; a : Agr} ;
AP = {s : Str} ;
Comp = {s : Agr => Str} ;
V = Verb ; -- = {s : VForm => Str} ;
V2 = Verb ** {s2 : Str} ;
VV = Verb ** {s2 : Str} ;
Adv = {s : Str} ;
}

View File

@@ -0,0 +1,17 @@
abstract Fun = Cat ** {
fun
Pred : NP -> VP -> Cl ;
UseV : V -> VP ;
ComplV2 : V2 -> NP -> VP ;
ComplVV : VV -> VP -> VP ;
UseComp : Comp -> VP ;
AdvVP : VP -> Adv -> VP ;
UseVV : VV -> V2 ;
CompAP : AP -> Comp ;
CompNP : NP -> Comp ;
CompAdv : Adv -> Comp ;
}

View File

@@ -0,0 +1,32 @@
concrete FunEng of Fun = CatEng ** open ResEng in {
flags optimize=all_subs ;
lin
Pred np vp = {
s = \\t,a,o,b =>
let
agr = np.a ;
verb = vp.s ! t ! a ! o ! b ! agr ;
subj = np.s ! Nom ;
compl = vp.s2 ! agr
in
case o of {
ODir => subj ++ verb.fin ++ verb.inf ++ compl ;
OQuest => verb.fin ++ subj ++ verb.inf ++ compl
}
} ;
UseV = predV ;
ComplV2 v np = insertObj (\\_ => v.s2 ++ np.s ! Acc) (predV v) ;
ComplVV v vp = insertObj (\\a => v.s2 ++ infVP vp a) (predV v) ;
UseComp comp = insertObj comp.s (predAux auxBe) ;
AdvVP vp adv = insertObj (\\_ => adv.s) vp ;
UseVV vv = {s = vv.s ; s2 = []} ; -- no "to"
CompAP ap = {s = \\_ => ap.s} ;
CompNP np = {s = \\_ => np.s ! Acc} ;
CompAdv a = {s = \\_ => a.s} ;
}

View File

@@ -0,0 +1,12 @@
abstract Lex = Cat ** {
fun
walk_V : V ;
kill_V2 : V2 ;
want_VV : VV ;
big_AP : AP ;
i_NP, he_NP, we_NP : NP ;
here_Adv : Adv ;
}

View File

@@ -0,0 +1,14 @@
concrete LexEng of Lex = CatEng ** open ResEng in {
lin
walk_V = regV "walk" ;
kill_V2 = regV "kill" ** {s2 = []} ;
want_VV = regV "want" ** {s2 = "to"} ;
big_AP = {s = "big"} ;
i_NP = mkNP "I" "me" "my" Sg P1 ;
he_NP = mkNP "he" "him" "his" Sg P3 ;
we_NP = mkNP "we" "us" "our" Pl P1 ;
here_Adv = {s = "here"} ;
}

View File

@@ -0,0 +1,147 @@
resource ResEng = {
param
Number = Sg | Pl ;
Person = P1 | P2 | P3 ;
Case = Nom | Acc | Gen ;
Anteriority = Simul | Anter ;
Tense = Pres | Past | Fut | Cond ;
Pol = PPos | PNeg ;
Ord = ODir | OQuest ;
VForm = VInf | VPres | VPast | VPPart | VPresPart ;
oper
Agr = {n : Number ; p : Person} ;
regV : Str -> {s : VForm => Str} = \walk -> {
s = table {
VInf => walk ;
VPres => walk + "s" ;
VPast | VPPart => walk + "ed" ;
VPresPart => walk + "ing"
}
} ;
mkNP : (i,me,my : Str) -> Number -> Person -> {s : Case => Str ; a : Agr} =
\i,me,my,n,p -> {
s = table {
Nom => i ;
Acc => me ;
Gen => my
} ;
a = {
n = n ;
p = p
}
} ;
Verb : Type = {
s : VForm => Str
} ;
VP : Type = {
s : Tense => Anteriority => Ord => Pol => Agr => {fin, inf : Str} ;
s2 : Agr => Str
} ;
predV : Verb -> VP = \verb -> {
s = \\t,ant,ord,b,agr =>
let
inf = verb.s ! VInf ;
fin = presVerb verb agr ;
past = verb.s ! VPast ;
part = verb.s ! VPPart ;
vf : Str -> Str -> {fin, inf : Str} = \x,y ->
{fin = x ; inf = y} ;
in
case <t,ant,b,ord> of {
<Pres,Simul,PPos,ODir> => vf fin [] ;
<Pres,Simul,PPos,OQuest> => vf (does agr) inf ;
<Pres,Simul,PNeg,_> => vf (doesnt agr) inf ;
<Pres,Anter,PPos,_> => vf (have agr) part ;
<Pres,Anter,PNeg,_> => vf (havent agr) part ;
<Past,Simul,PPos,ODir> => vf past [] ;
<Past,Simul,PPos,OQuest> => vf "did" inf ;
<Past,Simul,PNeg,_> => vf "didn't" inf ;
<Past,Anter,PPos,_> => vf "had" part ;
<Past,Anter,PNeg,_> => vf "hadn't" part ;
<Fut, Simul,PPos,_> => vf "will" inf ;
<Fut, Simul,PNeg,_> => vf "won't" inf ;
<Fut, Anter,PPos,_> => vf "will" ("have" ++ part) ;
<Fut, Anter,PNeg,_> => vf "won't" ("have" ++ part) ;
<Cond,Simul,PPos,_> => vf "would" inf ;
<Cond,Simul,PNeg,_> => vf "wouldn't" inf ;
<Cond,Anter,PPos,_> => vf "would" ("have" ++ part) ;
<Cond,Anter,PNeg,_> => vf "wouldn't" ("have" ++ part)
} ;
s2 = \\_ => []
} ;
predAux : Aux -> VP = \verb -> {
s = \\t,ant,ord,b,agr =>
let
inf = verb.inf ;
fin = verb.pres ! b ! agr ;
past = verb.past ! b ! agr ;
part = verb.ppart ;
vf : Str -> Str -> {fin, inf : Str} = \x,y ->
{fin = x ; inf = y} ;
in
case <t,ant,b,ord> of {
<Pres,Simul,_, _> => vf fin [] ;
<Pres,Anter,PPos,_> => vf (have agr) part ;
<Pres,Anter,PNeg,_> => vf (havent agr) part ;
<Past,Simul,_, _> => vf fin [] ;
<Past,Anter,PPos,_> => vf "had" part ;
<Past,Anter,PNeg,_> => vf "hadn't" part ;
<Fut, Simul,PPos,_> => vf "will" inf ;
<Fut, Simul,PNeg,_> => vf "won't" inf ;
<Fut, Anter,PPos,_> => vf "will" ("have" ++ part) ;
<Fut, Anter,PNeg,_> => vf "won't" ("have" ++ part) ;
<Cond,Simul,PPos,_> => vf "would" inf ;
<Cond,Simul,PNeg,_> => vf "wouldn't" inf ;
<Cond,Anter,PPos,_> => vf "would" ("have" ++ part) ;
<Cond,Anter,PNeg,_> => vf "wouldn't" ("have" ++ part)
} ;
s2 = \\_ => []
} ;
insertObj : (Agr => Str) -> VP -> VP = \obj,vp -> {
s = vp.s ;
s2 = \\a => vp.s2 ! a ++ obj ! a
} ;
presVerb : {s : VForm => Str} -> Agr -> Str = \verb ->
agrVerb (verb.s ! VPres) (verb.s ! VInf) ;
infVP : VP -> Agr -> Str = \vp,a ->
(vp.s ! Fut ! Simul ! ODir ! PNeg ! a).inf ++ vp.s2 ! a ;
agrVerb : Str -> Str -> Agr -> Str = \has,have,agr ->
case agr of {
{n = Sg ; p = P3} => has ;
_ => have
} ;
have = agrVerb "has" "have" ;
havent = agrVerb "hasn't" "haven't" ;
does = agrVerb "does" "do" ;
doesnt = agrVerb "doesn't" "don't" ;
Aux = {pres,past : Pol => Agr => Str ; inf,ppart : Str} ;
auxBe : Aux = {
pres = \\b,a => agrVerb (posneg b "is") (posneg b "are") a ;
past = \\b,a => agrVerb (posneg b "was") (posneg b "were") a ;
inf = "be" ;
ppart = "been"
} ;
posneg : Pol -> Str -> Str = \p,s -> case p of {
PPos => s ;
PNeg => s + "n't"
} ;
}

View File

@@ -0,0 +1 @@
abstract Test = Fun, Lex ** {} ;

View File

@@ -0,0 +1 @@
concrete TestEng of Test = FunEng, LexEng ** {} ;