extending proto resource API

This commit is contained in:
aarne
2005-11-23 21:38:11 +00:00
parent f0e40a923d
commit b29877c590
22 changed files with 362 additions and 102 deletions

View File

@@ -1,20 +1,32 @@
resource ResEng = {
resource ResEng = ParamX ** {
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 ;
Case = Nom | Acc | Gen ;
VForm = VInf | VPres | VPast | VPPart | VPresPart ;
Ord = ODir | OQuest ;
oper
Agr = {n : Number ; p : Person} ;
agrP3 : Number -> {a : Agr} = \n -> {a = {n = n ; p = P3}} ;
regN : Str -> {s : Number => Case => Str} = \car -> {
s = table {
Sg => table {
Gen => car + "'s" ;
_ => car
} ;
Pl => table {
Gen => car + "s'" ;
_ => car + "s"
}
}
} ;
regV : Str -> {s : VForm => Str} = \walk -> {
s = table {
VInf => walk ;
@@ -24,7 +36,7 @@ resource ResEng = {
}
} ;
mkNP : (i,me,my : Str) -> Number -> Person -> {s : Case => Str ; a : Agr} =
mkNP : (i,me,my : Str) -> Number -> Person -> {s : Case => Str ; a : Agr} =
\i,me,my,n,p -> {
s = table {
Nom => i ;
@@ -42,12 +54,12 @@ resource ResEng = {
} ;
VP : Type = {
s : Tense => Anteriority => Ord => Pol => Agr => {fin, inf : Str} ;
s : Tense => Anteriority => Polarity => Ord => Agr => {fin, inf : Str} ;
s2 : Agr => Str
} ;
predV : Verb -> VP = \verb -> {
s = \\t,ant,ord,b,agr =>
s = \\t,ant,b,ord,agr =>
let
inf = verb.s ! VInf ;
fin = presVerb verb agr ;
@@ -57,30 +69,30 @@ resource ResEng = {
{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)
<Pres,Simul,Pos,ODir> => vf fin [] ;
<Pres,Simul,Pos,OQuest> => vf (does agr) inf ;
<Pres,Simul,Neg,_> => vf (doesnt agr) inf ;
<Pres,Anter,Pos,_> => vf (have agr) part ;
<Pres,Anter,Neg,_> => vf (havent agr) part ;
<Past,Simul,Pos,ODir> => vf past [] ;
<Past,Simul,Pos,OQuest> => vf "did" inf ;
<Past,Simul,Neg,_> => vf "didn't" inf ;
<Past,Anter,Pos,_> => vf "had" part ;
<Past,Anter,Neg,_> => vf "hadn't" part ;
<Fut, Simul,Pos,_> => vf "will" inf ;
<Fut, Simul,Neg,_> => vf "won't" inf ;
<Fut, Anter,Pos,_> => vf "will" ("have" ++ part) ;
<Fut, Anter,Neg,_> => vf "won't" ("have" ++ part) ;
<Cond,Simul,Pos,_> => vf "would" inf ;
<Cond,Simul,Neg,_> => vf "wouldn't" inf ;
<Cond,Anter,Pos,_> => vf "would" ("have" ++ part) ;
<Cond,Anter,Neg,_> => vf "wouldn't" ("have" ++ part)
} ;
s2 = \\_ => []
} ;
predAux : Aux -> VP = \verb -> {
s = \\t,ant,ord,b,agr =>
s = \\t,ant,b,ord,agr =>
let
inf = verb.inf ;
fin = verb.pres ! b ! agr ;
@@ -91,19 +103,19 @@ resource ResEng = {
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 ;
<Pres,Anter,Pos,_> => vf (have agr) part ;
<Pres,Anter,Neg,_> => 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)
<Past,Anter,Pos,_> => vf "had" part ;
<Past,Anter,Neg,_> => vf "hadn't" part ;
<Fut, Simul,Pos,_> => vf "will" inf ;
<Fut, Simul,Neg,_> => vf "won't" inf ;
<Fut, Anter,Pos,_> => vf "will" ("have" ++ part) ;
<Fut, Anter,Neg,_> => vf "won't" ("have" ++ part) ;
<Cond,Simul,Pos,_> => vf "would" inf ;
<Cond,Simul,Neg,_> => vf "wouldn't" inf ;
<Cond,Anter,Pos,_> => vf "would" ("have" ++ part) ;
<Cond,Anter,Neg,_> => vf "wouldn't" ("have" ++ part)
} ;
s2 = \\_ => []
} ;
@@ -117,7 +129,7 @@ resource ResEng = {
agrVerb (verb.s ! VPres) (verb.s ! VInf) ;
infVP : VP -> Agr -> Str = \vp,a ->
(vp.s ! Fut ! Simul ! ODir ! PNeg ! a).inf ++ vp.s2 ! a ;
(vp.s ! Fut ! Simul ! Neg ! ODir ! a).inf ++ vp.s2 ! a ;
agrVerb : Str -> Str -> Agr -> Str = \has,have,agr ->
case agr of {
@@ -130,7 +142,7 @@ resource ResEng = {
does = agrVerb "does" "do" ;
doesnt = agrVerb "doesn't" "don't" ;
Aux = {pres,past : Pol => Agr => Str ; inf,ppart : Str} ;
Aux = {pres,past : Polarity => Agr => Str ; inf,ppart : Str} ;
auxBe : Aux = {
pres = \\b,a => agrVerb (posneg b "is") (posneg b "are") a ;
@@ -139,9 +151,11 @@ resource ResEng = {
ppart = "been"
} ;
posneg : Pol -> Str -> Str = \p,s -> case p of {
PPos => s ;
PNeg => s + "n't"
posneg : Polarity -> Str -> Str = \p,s -> case p of {
Pos => s ;
Neg => s + "n't"
} ;
conjThat : Str = "that" ;
}