forked from GitHub/gf-core
Resource with extended API
This commit is contained in:
@@ -37,11 +37,12 @@ lincat
|
||||
Fun = Function ;
|
||||
-- = CommNounPhrase ** {s2 : Preposition} ;
|
||||
Fun2 = Function ** {s3 : Preposition} ;
|
||||
Num = {s : Case => Str} ;
|
||||
|
||||
Adj1 = Adjective ;
|
||||
-- = {s : Str}
|
||||
-- = {s : AForm => Str}
|
||||
Adj2 = Adjective ** {s2 : Preposition} ;
|
||||
AdjDeg = {s : Degree => Str} ;
|
||||
AdjDeg = {s : Degree => AForm => Str} ;
|
||||
AP = Adjective ** {p : Bool} ;
|
||||
|
||||
V = Verb ;
|
||||
@@ -51,6 +52,7 @@ lincat
|
||||
-- = Verb ** {s3 : Preposition} ;
|
||||
V3 = TransVerb ** {s4 : Preposition} ;
|
||||
VS = Verb ;
|
||||
VV = Verb ** {isAux : Bool} ;
|
||||
|
||||
AdV = {s : Str ; p : Bool} ;
|
||||
|
||||
@@ -69,7 +71,7 @@ lincat
|
||||
ConjD = {s1 : Str ; s2 : Str ; n : Number} ;
|
||||
|
||||
ListS = {s1 : Str ; s2 : Str} ;
|
||||
ListAP = {s1 : Str ; s2 : Str ; p : Bool} ;
|
||||
ListAP = {s1,s2 : AForm => Str ; p : Bool} ;
|
||||
ListNP = {s1,s2 : NPForm => Str ; n : Number ; p : Person} ;
|
||||
|
||||
--.
|
||||
@@ -77,7 +79,7 @@ lincat
|
||||
lin
|
||||
UseN = noun2CommNounPhrase ;
|
||||
ModAdj = modCommNounPhrase ;
|
||||
ModGenOne = npGenDet singular ;
|
||||
ModGenOne = npGenDet singular noNum ;
|
||||
ModGenMany = npGenDet plural ;
|
||||
UsePN = nameNounPhrase ;
|
||||
UseFun = funAsCommNounPhrase ;
|
||||
@@ -91,14 +93,14 @@ lin
|
||||
|
||||
DetNP = detNounPhrase ;
|
||||
IndefOneNP = indefNounPhrase singular ;
|
||||
IndefManyNP = indefNounPhrase plural ;
|
||||
IndefManyNP = indefNounPhraseNum plural ;
|
||||
DefOneNP = defNounPhrase singular ;
|
||||
DefManyNP = defNounPhrase plural ;
|
||||
DefManyNP = defNounPhraseNum plural ;
|
||||
MassNP = detNounPhrase (mkDeterminer Sg []) ;
|
||||
IntNP n = detNounPhrase (mkDeterminer Pl n.s) ;
|
||||
DefIntNP n = detNounPhrase (mkDeterminer Pl ("the" ++ n.s)) ;
|
||||
|
||||
CNthatS = nounThatSentence ;
|
||||
UseInt i = {s = table {Nom => i.s ; Gen => i.s ++ "'s"}} ; ---
|
||||
NoNum = noNum ;
|
||||
|
||||
PredVP = predVerbPhrase ;
|
||||
PosV = predVerb True ;
|
||||
@@ -115,12 +117,17 @@ lin
|
||||
NegPassV = passVerb False ;
|
||||
PosNP = predNounPhrase True ;
|
||||
NegNP = predNounPhrase False ;
|
||||
PosAdV = predAdverb True ;
|
||||
NegAdV = predAdverb False ;
|
||||
PosVS = complSentVerb True ;
|
||||
NegVS = complSentVerb False ;
|
||||
--- PosVV = complVerbVerb True ;
|
||||
--- NegVV = complVerbVerb False ;
|
||||
VTrans = transAsVerb ;
|
||||
|
||||
AdvVP = adVerbPhrase ;
|
||||
AdjAdv a = advPost (a.s ! AAdv) ;
|
||||
PrepNP p = prepPhrase p.s ; ---
|
||||
AdvVP = adVerbPhrase ;
|
||||
AdvCN = advCommNounPhrase ;
|
||||
AdvAP = advAdjPhrase ;
|
||||
|
||||
@@ -129,8 +136,8 @@ lin
|
||||
OneVP = predVerbPhrase (nameNounPhrase (nameReg "one")) ;
|
||||
ThereIsCN A = prefixSS ["there is"] ---
|
||||
(defaultNounPhrase (indefNounPhrase singular A)) ;
|
||||
ThereAreCN A = prefixSS ["there are"]
|
||||
(defaultNounPhrase (indefNounPhrase plural A)) ;
|
||||
ThereAreCN n A = prefixSS ["there are"]
|
||||
(defaultNounPhrase (indefNounPhraseNum plural n A)) ;
|
||||
|
||||
IdRP = identRelPron ;
|
||||
FunRP = funRelPron ;
|
||||
@@ -151,7 +158,7 @@ lin
|
||||
IntVP = intVerbPhrase ;
|
||||
IntSlash = intSlash ;
|
||||
QuestAdv = questAdverbial ;
|
||||
IsThereCN = isThere singular ;
|
||||
IsThereCN = isThere singular noNum ;
|
||||
AreThereCN = isThere plural ;
|
||||
|
||||
ImperVP = imperVerbPhrase ;
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
--# -path=.:../../prelude
|
||||
|
||||
--1 A Simple English Resource Morphology
|
||||
--
|
||||
-- Aarne Ranta 2002
|
||||
@@ -7,7 +9,7 @@
|
||||
--
|
||||
-- We use the parameter types and word classes defined in $Types.gf$.
|
||||
|
||||
resource MorphoEng = TypesEng ** open Prelude in {
|
||||
resource MorphoEng = TypesEng ** open Prelude, (Predef=Predef) in {
|
||||
|
||||
--2 Nouns
|
||||
--
|
||||
@@ -90,25 +92,58 @@ oper
|
||||
|
||||
--2 Adjectives
|
||||
--
|
||||
-- For the comparison of adjectives, three forms are needed in the worst case.
|
||||
-- To form the adjectival and the adverbial forms, two strings are needed
|
||||
-- in the worst case.
|
||||
|
||||
mkAdjDegr : (_,_,_ : Str) -> AdjDegr = \good,better,best ->
|
||||
{s = table {Pos => good ; Comp => better ; Sup => best}} ;
|
||||
mkAdjective : Str -> Str -> Adjective = \free,freely -> {
|
||||
s = table {
|
||||
AAdj => free ;
|
||||
AAdv => freely
|
||||
}
|
||||
} ;
|
||||
|
||||
-- However, the ending "iy" is sufficient for most cases. This function
|
||||
-- automatically changes the word-final "y" to "i" ("happy" - "happily").
|
||||
-- N.B. this is not correct for "shy", but $mkAdjective$ has to be used.
|
||||
|
||||
adjDegrReg : Str -> AdjDegr = \long ->
|
||||
mkAdjDegr long (long + "er") (long + "est") ;
|
||||
regAdjective : Str -> Adjective = \free ->
|
||||
let
|
||||
y = Predef.dp 1 free
|
||||
in mkAdjective
|
||||
free
|
||||
(ifTok Str y "y" (Predef.tk 1 free + ("ily")) (free + "ly")) ;
|
||||
|
||||
adjDegrY : Str -> AdjDegr = \lovel ->
|
||||
mkAdjDegr (lovel + "y") (lovel + "ier") (lovel + "iest") ;
|
||||
-- For the comparison of adjectives, six forms are needed to cover all cases.
|
||||
-- But there is no adjective that actually needs all these.
|
||||
|
||||
mkAdjDegrWorst : (_,_,_,_,_,_ : Str) -> AdjDegr =
|
||||
\good,well,better,betterly,best,bestly ->
|
||||
{s = table {
|
||||
Pos => (mkAdjective good well).s ;
|
||||
Comp => (mkAdjective better betterly).s ;
|
||||
Sup => (mkAdjective best bestly).s
|
||||
}
|
||||
} ;
|
||||
|
||||
-- What is usually needed for irregular comparisons are just three forms,
|
||||
-- since the adverbial form is the same (in comparative or superlative)
|
||||
-- or formed in the regular way (positive).
|
||||
|
||||
adjDegrIrreg : (_,_,_ : Str) -> AdjDegr = \bad,worse,worst ->
|
||||
let badly = (regAdjective bad).s ! AAdv
|
||||
in mkAdjDegrWorst bad badly worse worse worst worst ;
|
||||
|
||||
-- Like above, the regular formation takes account of final "y".
|
||||
|
||||
adjDegrReg : Str -> AdjDegr = \happy ->
|
||||
let happi = ifTok Str (Predef.dp 1 happy) "y" (Predef.tk 1 happy + "i") happy
|
||||
in adjDegrIrreg happy (happi + "er") (happi + "est") ;
|
||||
|
||||
-- Many adjectives are 'inflected' by adding a comparison word.
|
||||
|
||||
adjDegrLong : Str -> AdjDegr = \ridiculous ->
|
||||
mkAdjDegr ridiculous ("more" ++ ridiculous) ("most" ++ ridiculous) ;
|
||||
adjDegrIrreg ridiculous ("more" ++ ridiculous) ("most" ++ ridiculous) ;
|
||||
|
||||
-- simple adjectives are just strings
|
||||
|
||||
simpleAdj : Str -> Adjective = ss ;
|
||||
|
||||
--3 Verbs
|
||||
--
|
||||
|
||||
@@ -92,12 +92,12 @@ oper
|
||||
mkAdj2 : (divisible, by : Str) -> Adj2 ;
|
||||
|
||||
-- Comparison adjectives have three forms. The common irregular
|
||||
-- cases are ones ending with "y" and a consonant that is duplicated.
|
||||
-- cases are ones ending with "y" and a consonant that is duplicated;
|
||||
-- the "y" ending is recognized by the function $aReg$.
|
||||
|
||||
mkAdjDeg : (good,better,best : Str) -> AdjDeg ;
|
||||
|
||||
aReg : (long : Str) -> AdjDeg ; -- long, longer, longest
|
||||
aHappy : (happy : Str) -> AdjDeg ; -- happy, happier, happiest
|
||||
aFat : (fat : Str) -> AdjDeg ; -- fat, fatter, fattest
|
||||
aRidiculous : (ridiculous : Str) -> AdjDeg ; -- -/more/most ridiculous
|
||||
|
||||
@@ -197,11 +197,10 @@ oper
|
||||
addGenN : (Str -> CommonNoun) -> Str -> Gender -> N = \f ->
|
||||
\s,g -> f s ** {g = g ; lock_N = <>} ;
|
||||
|
||||
mkAdj1 a = simpleAdj a ** {lock_Adj1 = <>} ;
|
||||
mkAdj2 = \s,p -> simpleAdj s ** {s2 = p} ** {lock_Adj2 = <>} ;
|
||||
mkAdjDeg a b c = mkAdjDegr a b c ** {lock_AdjDeg = <>} ;
|
||||
mkAdj1 a = regAdjective a ** {lock_Adj1 = <>} ;
|
||||
mkAdj2 = \s,p -> regAdjective s ** {s2 = p} ** {lock_Adj2 = <>} ;
|
||||
mkAdjDeg a b c = adjDegrIrreg a b c ** {lock_AdjDeg = <>} ;
|
||||
aReg a = adjDegrReg a ** {lock_AdjDeg = <>} ;
|
||||
aHappy = \happy -> adjDegrY (Predef.tk 1 happy) ** {lock_AdjDeg = <>} ;
|
||||
aFat = \fat -> let {fatt = fat + Predef.dp 1 fat} in
|
||||
mkAdjDeg fat (fatt + "er") (fatt + "est") ;
|
||||
aRidiculous a = adjDegrLong a ** {lock_AdjDeg = <>} ;
|
||||
|
||||
@@ -12,32 +12,35 @@ concrete StructuralEng of Structural =
|
||||
HeNP = pronHe ;
|
||||
SheNP = pronShe ;
|
||||
ItNP = pronIt ;
|
||||
WeNP = pronWe ;
|
||||
YeNP = pronYouPl ;
|
||||
WeNP = pronWithNum pronWe ;
|
||||
YeNP = pronWithNum pronYouPl ;
|
||||
YouNP = pronYouSg ;
|
||||
TheyNP = pronThey ;
|
||||
|
||||
EveryDet = everyDet ;
|
||||
AllDet = allDet ;
|
||||
AllDet = mkDeterminer Sg "all" ; --- all the missing
|
||||
AllsDet = mkDeterminerNum Pl "all" ;
|
||||
WhichDet = whichDet ;
|
||||
MostDet = mostDet ;
|
||||
WhichsDet = mkDeterminerNum Pl "which" ;
|
||||
MostsDet = mostDet ;
|
||||
MostDet = mkDeterminer Sg "most" ;
|
||||
SomeDet = mkDeterminer Sg "some" ;
|
||||
SomesDet = mkDeterminer Pl "some" ;
|
||||
SomesDet = mkDeterminerNum Pl "some" ;
|
||||
AnyDet = mkDeterminer Sg "any" ;
|
||||
AnysDet = mkDeterminer Pl "any" ;
|
||||
AnysDet = mkDeterminerNum Pl "any" ;
|
||||
NoDet = mkDeterminer Sg "no" ;
|
||||
NosDet = mkDeterminer Pl "no" ;
|
||||
NosDet = mkDeterminerNum Pl "no" ;
|
||||
ManyDet = mkDeterminer Sg "many" ;
|
||||
MuchDet = mkDeterminer Sg ["a lot of"] ; ---
|
||||
ThisDet = mkDeterminer Sg "this" ;
|
||||
TheseDet = mkDeterminer Pl "these" ;
|
||||
TheseDet = mkDeterminerNum Pl "these" ;
|
||||
ThatDet = mkDeterminer Sg "that" ;
|
||||
ThoseDet = mkDeterminer Pl "those" ;
|
||||
ThoseDet = mkDeterminerNum Pl "those" ;
|
||||
|
||||
ThisNP = nameNounPhrase (nameReg "this") ;
|
||||
TheseNP = nameNounPhrase (nameReg "these") ;
|
||||
ThatNP = nameNounPhrase (nameReg "that") ;
|
||||
ThoseNP = nameNounPhrase (nameReg "those") ;
|
||||
TheseNP n = nameNounPhrase {s = \\c => "these" ++ n.s ! c} ;
|
||||
ThoseNP n = nameNounPhrase {s = \\c => "those" ++ n.s ! c} ;
|
||||
|
||||
EverybodyNP = nameNounPhrase (nameReg "everybody") ;
|
||||
SomebodyNP = nameNounPhrase (nameReg "somebody") ;
|
||||
@@ -46,6 +49,11 @@ concrete StructuralEng of Structural =
|
||||
SomethingNP = nameNounPhrase (nameReg "something") ;
|
||||
NothingNP = nameNounPhrase (nameReg "nothing") ;
|
||||
|
||||
--- CanVV = vvCan ;
|
||||
--- CanKnowVV = vvCan ;
|
||||
--- MustVV = vvMust ;
|
||||
--- WantVV = verbNoPart (regVerbP3 "want") ** {isAux = False} ;
|
||||
|
||||
HowIAdv = ss "how" ;
|
||||
WhenIAdv = ss "when" ;
|
||||
WhereIAdv = ss "where" ;
|
||||
@@ -89,6 +97,7 @@ concrete StructuralEng of Structural =
|
||||
WithPrep = ss "with" ;
|
||||
WithoutPrep = ss "without" ;
|
||||
ByMeansPrep = ss "by" ;
|
||||
PartPrep = ss "of" ;
|
||||
AgentPrep = ss "by" ;
|
||||
|
||||
}
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
--# -path=.:../../prelude
|
||||
|
||||
--1 A Small English Resource Syntax
|
||||
--
|
||||
-- Aarne Ranta 2002
|
||||
@@ -45,10 +47,21 @@ oper
|
||||
nameNounPhrase : ProperName -> NounPhrase = \john ->
|
||||
{s = \\c => john.s ! toCase c ; n = Sg ; p = P3} ;
|
||||
|
||||
-- The following construction has to be refined for genitive forms:
|
||||
-- "we two", "us two" are OK, but "our two" is not.
|
||||
|
||||
Numeral : Type = {s : Case => Str} ;
|
||||
|
||||
pronWithNum : Pronoun -> Numeral -> Pronoun = \we,two ->
|
||||
{s = \\c => we.s ! c ++ two.s ! toCase c ; n = we.n ; p = we.p} ;
|
||||
|
||||
noNum : Numeral = {s = \\_ => []} ;
|
||||
|
||||
--2 Determiners
|
||||
--
|
||||
-- Determiners are inflected according to the nouns they determine.
|
||||
-- The determiner is not inflected.
|
||||
|
||||
Determiner : Type = {s : Str ; n : Number} ;
|
||||
|
||||
detNounPhrase : Determiner -> CommNounPhrase -> NounPhrase = \every, man ->
|
||||
@@ -57,50 +70,63 @@ oper
|
||||
p = P3
|
||||
} ;
|
||||
|
||||
mkDeterminer : Number -> Str -> Determiner = \n,det ->
|
||||
{s = det ;
|
||||
mkDeterminer : Number -> Str -> Determiner = \n,the ->
|
||||
mkDeterminerNum n the noNum ;
|
||||
|
||||
mkDeterminerNum : Number -> Str -> Numeral -> Determiner = \n,det,two ->
|
||||
{s = det ++ two.s ! Nom ;
|
||||
n = n
|
||||
} ;
|
||||
|
||||
everyDet = mkDeterminer Sg "every" ;
|
||||
allDet = mkDeterminer Pl "all" ;
|
||||
allDet = mkDeterminerNum Pl "all" ;
|
||||
mostDet = mkDeterminer Pl "most" ;
|
||||
aDet = mkDeterminer Sg artIndef ;
|
||||
plDet = mkDeterminer Pl [] ;
|
||||
plDet = mkDeterminerNum Pl [] ;
|
||||
theSgDet = mkDeterminer Sg "the" ;
|
||||
thePlDet = mkDeterminer Pl "the" ;
|
||||
thePlDet = mkDeterminerNum Pl "the" ;
|
||||
anySgDet = mkDeterminer Sg "any" ;
|
||||
anyPlDet = mkDeterminer Pl "any" ;
|
||||
anyPlDet = mkDeterminerNum Pl "any" ;
|
||||
|
||||
whichSgDet = mkDeterminer Sg "which" ;
|
||||
whichPlDet = mkDeterminer Pl "which" ;
|
||||
whichPlDet = mkDeterminerNum Pl "which" ;
|
||||
|
||||
whichDet = whichSgDet ; --- API
|
||||
|
||||
indefNoun : Number -> CommNoun -> Str = \n,man ->
|
||||
(indefNounPhrase n man).s ! NomP ;
|
||||
|
||||
indefNounPhrase : Number -> CommNounPhrase -> NounPhrase = \n,man ->
|
||||
indefNounPhrase : Number -> CommNounPhrase -> NounPhrase = \n ->
|
||||
indefNounPhraseNum n noNum ;
|
||||
|
||||
indefNounPhraseNum : Number -> Numeral ->CommNounPhrase -> NounPhrase =
|
||||
\n,two,man ->
|
||||
{s = \\c => case n of {
|
||||
Sg => artIndef ++ man.s ! n ! toCase c ;
|
||||
Pl => man.s ! n ! toCase c
|
||||
Sg => artIndef ++ two.s ! Nom ++ man.s ! n ! toCase c ;
|
||||
Pl => two.s ! Nom ++ man.s ! n ! toCase c
|
||||
} ;
|
||||
n = n ; p = P3
|
||||
} ;
|
||||
|
||||
defNounPhrase : Number -> CommNounPhrase -> NounPhrase = \n,car ->
|
||||
{s = \\c => artDef ++ car.s ! n ! toCase c ; n = n ; p = P3} ;
|
||||
defNounPhrase : Number -> CommNounPhrase -> NounPhrase = \n ->
|
||||
defNounPhraseNum n noNum ;
|
||||
defNounPhraseNum : Number -> Numeral -> CommNounPhrase -> NounPhrase =
|
||||
\n,two,car ->
|
||||
{s = \\c => artDef ++ two.s ! Nom ++ car.s ! n ! toCase c ;
|
||||
n = n ;
|
||||
p = P3
|
||||
} ;
|
||||
|
||||
-- Genitives of noun phrases can be used like determiners, to build noun phrases.
|
||||
-- The number argument makes the difference between "my house" - "my houses".
|
||||
--
|
||||
-- We have the variation "the car of John / the car of John's / John's car"
|
||||
|
||||
npGenDet : Number -> NounPhrase -> CommNounPhrase -> NounPhrase =
|
||||
\n,john,car ->
|
||||
npGenDet : Number -> Numeral -> NounPhrase -> CommNounPhrase -> NounPhrase =
|
||||
\n,two,john,car ->
|
||||
{s = \\c => variants {
|
||||
artDef ++ car.s ! n ! Nom ++ "of" ++ john.s ! GenSP ;
|
||||
john.s ! GenP ++ car.s ! n ! toCase c
|
||||
artDef ++ two.s ! Nom ++ car.s ! n ! Nom ++ "of" ++ john.s ! GenSP ;
|
||||
john.s ! GenP ++ two.s ! Nom ++ car.s ! n ! toCase c
|
||||
} ;
|
||||
n = n ;
|
||||
p = P3
|
||||
@@ -134,7 +160,7 @@ oper
|
||||
adj2adjPhrase : Adjective -> AdjPhrase = \new -> new ** {p = True} ;
|
||||
|
||||
simpleAdjPhrase : Str -> AdjPhrase = \French ->
|
||||
adj2adjPhrase (simpleAdj French) ;
|
||||
adj2adjPhrase (regAdjective French) ;
|
||||
|
||||
|
||||
--3 Comparison adjectives
|
||||
@@ -144,13 +170,13 @@ oper
|
||||
-- Positive forms are used alone, as adjectival phrases ("big").
|
||||
|
||||
positAdjPhrase : AdjDegr -> AdjPhrase = \big ->
|
||||
adj2adjPhrase (ss (big.s ! Pos)) ;
|
||||
adj2adjPhrase {s = big.s ! Pos} ;
|
||||
|
||||
-- Comparative forms are used with an object of comparison, as
|
||||
-- adjectival phrases ("bigger then you").
|
||||
|
||||
comparAdjPhrase : AdjDegr -> NounPhrase -> AdjPhrase = \big, you ->
|
||||
{s = big.s ! Comp ++ "than" ++ you.s ! NomP ;
|
||||
{s = \\a => big.s ! Comp ! a ++ "than" ++ you.s ! NomP ;
|
||||
p = False
|
||||
} ;
|
||||
|
||||
@@ -158,7 +184,7 @@ oper
|
||||
-- maximal representative of a domain ("the biggest house").
|
||||
|
||||
superlNounPhrase : AdjDegr -> CommNoun -> NounPhrase = \big, house ->
|
||||
{s = \\c => "the" ++ big.s ! Sup ++ house.s ! Sg ! toCase c ;
|
||||
{s = \\c => "the" ++ big.s ! Sup ! AAdj ++ house.s ! Sg ! toCase c ;
|
||||
n = Sg ;
|
||||
p = P3
|
||||
} ;
|
||||
@@ -174,7 +200,7 @@ oper
|
||||
AdjCompl = Adjective ** {s2 : Preposition} ;
|
||||
|
||||
complAdj : AdjCompl -> NounPhrase -> AdjPhrase = \related,john ->
|
||||
{s = related.s ++ related.s2 ++ john.s ! AccP ;
|
||||
{s = \\a => related.s ! a ++ related.s2 ++ john.s ! AccP ;
|
||||
p = False
|
||||
} ;
|
||||
|
||||
@@ -190,8 +216,8 @@ oper
|
||||
|
||||
modCommNounPhrase : AdjPhrase -> CommNounPhrase -> CommNounPhrase = \big, car ->
|
||||
{s = \\n => if_then_else (Case => Str) big.p
|
||||
(\\c => big.s ++ car.s ! n ! c)
|
||||
(table {Nom => car.s ! n ! Nom ++ big.s ; Gen => variants {}}) ;
|
||||
(\\c => big.s ! AAdj ++ car.s ! n ! c)
|
||||
(table {Nom => car.s ! n ! Nom ++ big.s ! AAdj ; Gen => variants {}}) ;
|
||||
g = car.g
|
||||
} ;
|
||||
|
||||
@@ -234,7 +260,7 @@ oper
|
||||
let {n = john.n ; nf = if_then_else Number coll Sg n} in
|
||||
variants {
|
||||
defNounPhrase nf (appFunComm mother john) ;
|
||||
npGenDet nf john mother
|
||||
npGenDet nf noNum john mother
|
||||
} ;
|
||||
|
||||
-- The commonest case is functions with the preposition "of".
|
||||
@@ -305,7 +331,7 @@ oper
|
||||
|
||||
predAdjective : Bool -> Adjective -> VerbPhrase = \b,old ->
|
||||
{s = beOrNotBe b ;
|
||||
s2 = \\_ => old.s ;
|
||||
s2 = \\_ => old.s ! AAdj ;
|
||||
isAux = True
|
||||
} ;
|
||||
|
||||
@@ -321,6 +347,12 @@ oper
|
||||
isAux = True
|
||||
} ;
|
||||
|
||||
predAdverb : Bool -> Adverb -> VerbPhrase = \b,elsewhere ->
|
||||
{s = beOrNotBe b ;
|
||||
s2 = \\_ => elsewhere.s ;
|
||||
isAux = True
|
||||
} ;
|
||||
|
||||
-- We use an auxiliary giving all forms of "be".
|
||||
|
||||
beOrNotBe : Bool -> (VForm => Str) = \b ->
|
||||
@@ -376,7 +408,7 @@ oper
|
||||
-- The syntax is the same as for adjectival predication.
|
||||
|
||||
passVerb : Bool -> Verb -> VerbPhrase = \b,love ->
|
||||
predAdjective b (adj2adjPhrase (ss (love.s ! PPart))) ;
|
||||
predAdjective b (adj2adjPhrase (regAdjective (love.s ! PPart))) ;
|
||||
|
||||
-- Transitive verbs can be used elliptically as verbs. The semantics
|
||||
-- is left to applications. The definition is trivial, due to record
|
||||
@@ -434,7 +466,7 @@ oper
|
||||
} ;
|
||||
|
||||
advAdjPhrase : SS -> AdjPhrase -> AdjPhrase = \very, good ->
|
||||
{s = very.s ++ good.s ;
|
||||
{s = \\a => very.s ++ good.s ! a ;
|
||||
p = good.p
|
||||
} ;
|
||||
|
||||
@@ -504,6 +536,50 @@ oper
|
||||
s2 = \\_ => say.s ! InfImp ++ thatjohnruns ;
|
||||
isAux = True} ;
|
||||
|
||||
--3 Verb-complement verbs
|
||||
--
|
||||
-- Sentence-complement verbs take verb phrases as complements.
|
||||
-- They can be auxiliaries ("can", "must") or ordinary verbs
|
||||
-- ("try"); this distinction cannot be done in the multilingual
|
||||
-- API and leads to some anomalies in English, such as the necessity
|
||||
-- to create the infinitive form "to be able to" for "can" so that
|
||||
-- the construction can be iterated, and the corresponding complication
|
||||
-- in the parameter structure.
|
||||
|
||||
VerbVerb : Type = Verb ** {isAux : Bool} ;
|
||||
|
||||
-- To generate "can walk"/"can't walk"; "tries to walk"/"does not try to walk":
|
||||
-- The contraction of "not" is not provided, since it would require changing
|
||||
-- the verb parameter type.
|
||||
|
||||
complVerbVerb : Bool -> VerbVerb -> VerbPhrase -> VerbPhrase = \b,try,run ->
|
||||
let to = if_then_else Str try.isAux [] "to"
|
||||
in
|
||||
if_then_else VerbPhrase b
|
||||
{s = \\v => try.s ! v ++ try.s1 ++ to ++ run.s ! InfImp ;
|
||||
s2 = run.s2 ;
|
||||
isAux = try.isAux
|
||||
}
|
||||
{s = \\v => try.s ! v ++ "not" ;
|
||||
s2 = \\n => run.s ! InfImp ++ run.s2 ! n ;
|
||||
isAux = True
|
||||
} ;
|
||||
|
||||
-- The three most important example auxiliaries.
|
||||
|
||||
mkVerbAux : (_,_,_,_: Str) -> VerbVerb = \beable, can, could, beenable ->
|
||||
{s = table {
|
||||
InfImp => beable ;
|
||||
Indic _ => can ;
|
||||
Past _ => could ;
|
||||
PPart => beenable
|
||||
} ;
|
||||
s1 = [] ;
|
||||
isAux = True
|
||||
} ;
|
||||
|
||||
vvCan : VerbVerb = mkVerbAux ["be able to"] "can" "could" ["been able to"] ;
|
||||
vvMust : VerbVerb = mkVerbAux ["have to"] "must" ["had to"] ["had to"] ;
|
||||
|
||||
--2 Sentences missing noun phrases
|
||||
--
|
||||
@@ -687,13 +763,13 @@ oper
|
||||
}
|
||||
} ;
|
||||
|
||||
isThere : Number -> CommNounPhrase -> Question = \n,bar ->
|
||||
isThere : Number -> Numeral -> CommNounPhrase -> Question = \n,num,bar ->
|
||||
questVerbPhrase
|
||||
(case n of {
|
||||
Sg => nameNounPhrase (nameReg "there") ;
|
||||
Pl => {s = \\_ => "there" ; n = Pl ; p = P3}
|
||||
})
|
||||
(predNounPhrase True (indefNounPhrase n bar)) ;
|
||||
(predNounPhrase True (indefNounPhraseNum n num bar)) ;
|
||||
|
||||
|
||||
--3 Wh-questions
|
||||
@@ -815,20 +891,20 @@ oper
|
||||
-- The structure is the same as for sentences. The result is a prefix adjective
|
||||
-- if and only if all elements are prefix.
|
||||
|
||||
ListAdjPhrase : Type = SD2 ** {p : Bool} ;
|
||||
ListAdjPhrase : Type = {s1,s2 : AForm => Str ; p : Bool} ;
|
||||
|
||||
twoAdjPhrase : (_,_ : AdjPhrase) -> ListAdjPhrase = \x,y ->
|
||||
CO.twoStr x.s y.s ** {p = andB x.p y.p} ;
|
||||
CO.twoTable AForm x y ** {p = andB x.p y.p} ;
|
||||
|
||||
consAdjPhrase : ListAdjPhrase -> AdjPhrase -> ListAdjPhrase = \xs,x ->
|
||||
CO.consStr CO.comma xs x.s ** {p = andB xs.p x.p} ;
|
||||
CO.consTable AForm CO.comma xs x ** {p = andB xs.p x.p} ;
|
||||
|
||||
conjunctAdjPhrase : Conjunction -> ListAdjPhrase -> AdjPhrase = \c,xs ->
|
||||
ss (CO.conjunctX c xs) ** {p = xs.p} ;
|
||||
CO.conjunctTable AForm c xs ** {p = xs.p} ;
|
||||
|
||||
conjunctDistrAdjPhrase : ConjunctionDistr -> ListAdjPhrase -> AdjPhrase =
|
||||
\c,xs ->
|
||||
ss (CO.conjunctDistrX c xs) ** {p = xs.p} ;
|
||||
CO.conjunctDistrTable AForm c xs ** {p = xs.p} ;
|
||||
|
||||
|
||||
--3 Coordinating noun phrases
|
||||
|
||||
@@ -8,18 +8,22 @@ flags startcat=Phr ; lexer=literals ; parser=chart ; unlexer=text ;
|
||||
-- a random sample from the lexicon
|
||||
|
||||
lin
|
||||
Big = mkAdjDegr "big" "bigger" "biggest";
|
||||
Big = adjDegrIrreg "big" "bigger" "biggest";
|
||||
Happy = adjDegrReg "happy" ;
|
||||
Small = adjDegrReg "small" ;
|
||||
Old = adjDegrReg "old" ;
|
||||
Young = adjDegrReg "young" ;
|
||||
American = simpleAdj "American" ;
|
||||
Finnish = simpleAdj "Finnish" ;
|
||||
Married = simpleAdj "married" ** {s2 = "to"} ;
|
||||
American = regAdjective "American" ;
|
||||
Finnish = regAdjective "Finnish" ;
|
||||
Married = regAdjective "married" ** {s2 = "to"} ;
|
||||
Man = cnHum (mkNoun "man" "men" "man's" "men's") ;
|
||||
Woman = cnHum (mkNoun "woman" "women" "woman's" "women's") ;
|
||||
Car = cnNoHum (nounReg "car") ;
|
||||
House = cnNoHum (nounReg "house") ;
|
||||
Light = cnNoHum (nounReg "light") ;
|
||||
Bar = cnNoHum (nounReg "bar") ;
|
||||
Bottle = cnNoHum (nounReg "bottle") ;
|
||||
Wine = cnNoHum (nounReg "wine") ;
|
||||
Walk = verbNoPart (regVerbP3 "walk") ;
|
||||
Run = verbNoPart (mkVerb "run" "ran" "run") ;
|
||||
Say = verbNoPart (mkVerb "say" "said" "said") ;
|
||||
@@ -27,6 +31,7 @@ lin
|
||||
Send = mkTransVerbDir (verbNoPart (mkVerb "send" "sent" "sent")) ;
|
||||
Love = mkTransVerbDir (verbNoPart (verbP3e "love")) ;
|
||||
Wait = mkTransVerb (verbNoPart (regVerbP3 "wait")) "for" ;
|
||||
Drink = mkTransVerbDir (verbNoPart (mkVerb "drink" "drank" "drunk")) ;
|
||||
Give = mkDitransVerb (verbNoPart (mkVerb "give" "gave" "given")) [] [] ;
|
||||
Prefer = mkDitransVerb
|
||||
(verbNoPart (mkVerb "prefer" "preferred" "preferred")) [] "to" ;
|
||||
|
||||
@@ -48,10 +48,13 @@ oper
|
||||
--
|
||||
-- The major division is between the comparison degrees, but it
|
||||
-- is also good to leave room for adjectives that cannon be compared.
|
||||
-- Such adjectives are simply strings.
|
||||
-- It is, however, productive to form an adverbial from any adjective.
|
||||
|
||||
Adjective : Type = SS ;
|
||||
AdjDegr = SS1 Degree ;
|
||||
param AForm = AAdj | AAdv ;
|
||||
|
||||
oper
|
||||
Adjective : Type = SS1 AForm ;
|
||||
AdjDegr = {s : Degree => AForm => Str} ;
|
||||
|
||||
--3 Verbs
|
||||
--
|
||||
|
||||
Reference in New Issue
Block a user