1
0
forked from GitHub/gf-core

adjectives

This commit is contained in:
aarne
2005-11-28 20:53:54 +00:00
parent 2c0fdf6c3c
commit d5b8fc79fb
14 changed files with 238 additions and 20 deletions

View File

@@ -0,0 +1,23 @@
abstract Adjective = Cat ** {
fun
PositA : A -> AP ;
ComparA : A -> NP -> AP ;
-- $SuperlA$ belongs to determiner syntax in $Noun$.
ComplA2 : A2 -> NP -> AP ;
SentAP : AP -> S -> AP ;
QuestAP : AP -> QS -> AP ;
AdAP : AdA -> AP -> AP ;
-- $AdvA$ that forms adverbs belongs to $Adverb$.
-- Elliptic constructions as usual.
UseA2 : A2 -> A ;
}

View File

@@ -0,0 +1,37 @@
concrete AdjectiveEng of Adjective = CatEng ** open ResEng, Prelude in {
lin
PositA a = {
s = a.s ! AAdj Posit ;
isPre = True
} ;
ComparA a np = {
s = a.s ! AAdj Compar ++ "than" ++ np.s ! Nom ;
isPre = False
} ;
-- $SuperlA$ belongs to determiner syntax in $Noun$.
ComplA2 a np = {
s = a.s ! AAdj Posit ++ a.c2 ++ np.s ! Acc ;
isPre = False
} ;
SentAP ap s = {
s = ap.s ++ conjThat ++ s.s ;
isPre = False
} ;
QuestAP ap qs = {
s = ap.s ++ qs.s ! QIndir ;
isPre = False
} ;
AdAP ada ap = {
s = ada.s ++ ap.s ;
isPre = ap.isPre
} ;
UseA2 a = a ;
}

View File

@@ -19,7 +19,13 @@ abstract Cat = {
AP ;
Comp ;
A ;
A2 ;
Adv ;
AdV ;
AdA ;
AdS ;
CN ;
N ;
@@ -42,4 +48,6 @@ abstract Cat = {
RP ;
}
Numeral ;
}

View File

@@ -1,4 +1,4 @@
concrete CatEng of Cat = open ResEng in {
concrete CatEng of Cat = open ResEng, Prelude in {
lincat
S = {s : Str} ;
@@ -18,10 +18,13 @@ concrete CatEng of Cat = open ResEng in {
V2, VV = Verb ** {c2 : Str} ;
V3 = Verb ** {c2, c3 : Str} ;
AP = {s : Str} ;
AP = {s : Str ; isPre : Bool} ;
Comp = {s : Agr => Str} ;
Adv = {s : Str} ;
A = {s : AForm => Str} ;
A2 = {s : AForm => Str ; c2 : Str} ;
Adv, AdV, AdA, AdS = {s : Str} ;
Det, Quant = {s : Str ; n : Number} ;
Predet, Num = {s : Str} ;
@@ -36,4 +39,6 @@ concrete CatEng of Cat = open ResEng in {
IDet = {s : Str ; n : Number} ;
IAdv = {s : Str} ;
Numeral = {s : CardOrd => Str ; n : Number} ;
}

View File

@@ -2,17 +2,19 @@ abstract Lex = Cat ** {
fun
walk_V : V ;
kill_V2 : V2 ;
help_V2 : V2 ;
show_V3 : V3 ;
want_VV : VV ;
claim_VS : VS ;
ask_VQ : VQ ;
big_AP : AP ;
dog_N : N ;
son_N2 : N2 ;
way_N3 : N3 ;
warm_A : A ;
close_A2 : A2 ;
-- structural
@@ -30,4 +32,6 @@ abstract Lex = Cat ** {
whichSg_IDet, whichPl_IDet : IDet ;
here_Adv : Adv ;
very_AdA : AdA ;
}

View File

@@ -1,19 +1,22 @@
concrete LexEng of Lex = CatEng ** open ResEng in {
concrete LexEng of Lex = CatEng ** open ResEng, Prelude in {
lin
walk_V = regV "walk" ;
kill_V2 = regV "kill" ** {c2 = []} ;
help_V2 = regV "help" ** {c2 = []} ;
show_V3 = regV "show" ** {c2 = [] ; c3 = "to"} ;
want_VV = regV "want" ** {c2 = "to"} ;
claim_VS = regV "claim" ;
ask_VQ = regV "ask" ;
big_AP = {s = "big"} ;
dog_N = regN "dog" ;
son_N2 = regN "son" ** {c2 = "of"} ;
way_N3 = regN "way" ** {c2 = "from" ; c3 = "to"} ;
warm_A = regA "warm" ;
close_A2 = regA "close" ** {c2 = "to"} ;
here_Adv = {s = "here"} ;
very_AdA = {s = "very"} ;
only_Predet = {s = "only"} ;
this_Quant = {s = "this" ; n = Sg} ;

View File

@@ -1,3 +1,5 @@
--1 The construction of nouns, noun phrases, and determiners
abstract Noun = Cat ** {
fun
@@ -12,15 +14,16 @@ abstract Noun = Cat ** {
NoNum : Num ;
NumInt : Int -> Num ;
CardNumeral : Numeral -> Num ;
OrdNumeral : Numeral -> Num ;
NumSuperl : A -> Num ;
NoPredet : Predet ;
DefSg, DefPl : Quant ;
DefSg, DefPl : Quant ;
IndefSg, IndefPl : Quant ;
-- Num_Pl ::= Ordinal ;
-- Num_Pl ::= Numeral ;
ComplN2 : N2 -> NP -> CN ;
ComplN3 : N3 -> NP -> N2 ;

View File

@@ -1,4 +1,4 @@
concrete NounEng of Noun = CatEng ** open ResEng in {
concrete NounEng of Noun = CatEng ** open ResEng, Prelude in {
flags optimize=all_subs ;
@@ -18,16 +18,25 @@ concrete NounEng of Noun = CatEng ** open ResEng in {
NoNum, NoPredet = {s = []} ;
NumInt n = n ;
CardNumeral numeral = {s = numeral.s ! NCard} ;
OrdNumeral numeral = {s = numeral.s ! NOrd} ;
NumSuperl a = {s = a.s ! AAdj Superl} ;
DefSg = {s = "the" ; n = Sg} ;
DefPl = {s = "the" ; n = Pl} ;
IndefSg = {s = "a" ; n = Sg} ;
IndefPl = {s = [] ; n = Pl} ;
UseN n = n ;
ComplN2 f x = {s = \\n,c => f.s ! n ! Nom ++ f.c2 ++ x.s ! c} ;
ComplN3 f x = {s = \\n,c => f.s ! n ! Nom ++ f.c2 ++ x.s ! c ; c2 = f.c3} ;
AdjCN ap cn = {s = \\n,c => preOrPost ap.isPre ap.s (cn.s ! n ! c)} ;
SentCN cn s = {s = \\n,c => cn.s ! n ! c ++ conjThat ++ s.s} ;
QuestCN cn qs = {s = \\n,c => cn.s ! n ! c ++ qs.s ! QIndir} ;
UseN n = n ;
}

View File

@@ -0,0 +1,31 @@
-- numerals from 1 to 999999 in decimal notation
abstract Numeral = Cat ** {
cat
Digit ; -- 2..9
Sub10 ; -- 1..9
Sub100 ; -- 1..99
Sub1000 ; -- 1..999
Sub1000000 ; -- 1..999999
fun
num : Sub1000000 -> Numeral ;
n2, n3, n4, n5, n6, n7, n8, n9 : Digit ;
pot01 : Sub10 ; -- 1
pot0 : Digit -> Sub10 ; -- d * 1
pot110 : Sub100 ; -- 10
pot111 : Sub100 ; -- 11
pot1to19 : Digit -> Sub100 ; -- 10 + d
pot0as1 : Sub10 -> Sub100 ; -- coercion of 1..9
pot1 : Digit -> Sub100 ; -- d * 10
pot1plus : Digit -> Sub10 -> Sub100 ; -- d * 10 + n
pot1as2 : Sub100 -> Sub1000 ; -- coercion of 1..99
pot2 : Sub10 -> Sub1000 ; -- m * 100
pot2plus : Sub10 -> Sub100 -> Sub1000 ; -- m * 100 + n
pot2as3 : Sub1000 -> Sub1000000 ; -- coercion of 1..999
pot3 : Sub1000 -> Sub1000000 ; -- m * 1000
pot3plus : Sub1000 -> Sub1000 -> Sub1000000 ; -- m * 1000 + n
}

View File

@@ -0,0 +1,44 @@
concrete NumeralEng of Numeral = CatEng ** open ResEng in {
lincat
Digit = {s : DForm => CardOrd => Str} ;
Sub10 = {s : DForm => CardOrd => Str ; n : Number} ;
Sub100 = {s : CardOrd => Str ; n : Number} ;
Sub1000 = {s : CardOrd => Str ; n : Number} ;
Sub1000000 = {s : CardOrd => Str ; n : Number} ;
lin num x = x ;
lin n2 = let two = mkNum "two" "twelve" "twenty" "second" in
{s = \\f,c => case <f,c> of {
<teen,NOrd> => "twelfth" ;
_ => two.s ! f ! c
}
} ;
lin n3 = mkNum "three" "thirteen" "thirty" "third" ;
lin n4 = mkNum "four" "fourteen" "forty" "fourth" ;
lin n5 = mkNum "five" "fifteen" "fifty" "fifth" ;
lin n6 = regNum "six" ;
lin n7 = regNum "seven" ;
lin n8 = mkNum "eight" "eighteen" "eighty" "eighth" ;
lin n9 = regNum "nine" ;
lin pot01 = mkNum "one" "eleven" "ten" "first" ** {n = Sg} ;
lin pot0 d = d ** {n = Pl} ;
lin pot110 = regCardOrd "ten" ** {n = Pl} ;
lin pot111 = regCardOrd "eleven" ** {n = Pl} ;
lin pot1to19 d = {s = d.s ! teen} ** {n = Pl} ;
lin pot0as1 n = {s = n.s ! unit} ** {n = n.n} ;
lin pot1 d = {s = d.s ! ten} ** {n = Pl} ;
lin pot1plus d e = {
s = \\c => d.s ! ten ! NCard ++ "-" ++ e.s ! unit ! c ; n = Pl} ;
lin pot1as2 n = n ;
lin pot2 d = {s = \\c => d.s ! unit ! NCard ++ mkCard c "hundred"} ** {n = Pl} ;
lin pot2plus d e = {
s = \\c => d.s ! unit ! NCard ++ "hundred" ++ "and" ++ e.s ! c ; n = Pl} ;
lin pot2as3 n = n ;
lin pot3 n = {
s = \\c => n.s ! NCard ++ mkCard c "thousand" ; n = Pl} ;
lin pot3plus n m = {
s = \\c => n.s ! NCard ++ "thousand" ++ m.s ! c ; n = Pl} ;
}

View File

@@ -3,10 +3,11 @@ resource ParamX = {
param
Number = Sg | Pl ;
Person = P1 | P2 | P3 ;
Degree = Posit | Compar | Superl ;
Anteriority = Simul | Anter ;
Tense = Pres | Past | Fut | Cond ;
Polarity = Pos | Neg ;
Tense = Pres | Past | Fut | Cond ;
Polarity = Pos | Neg ;
QForm = QDir | QIndir ;

View File

@@ -1,4 +1,4 @@
resource ResEng = ParamX ** {
resource ResEng = ParamX ** open Prelude in {
param
@@ -161,4 +161,48 @@ resource ResEng = ParamX ** {
conjThat : Str = "that" ;
-- For $Adjective$.
param
AForm = AAdj Degree | AAdv ;
oper
regA : Str -> {s : AForm => Str} = \warm -> {
s = table {
AAdj Posit => warm ;
AAdj Compar => warm + "er" ;
AAdj Superl => warm + "est" ;
AAdv => warm + "ly"
}
} ;
-- For $Numeral$.
param
DForm = unit | teen | ten ;
CardOrd = NCard | NOrd ;
oper
mkNum : Str -> Str -> Str -> Str -> {s : DForm => CardOrd => Str} =
\two -> \twelve -> \twenty -> \second ->
{s = table {
unit => table {NCard => two ; NOrd => second} ;
teen => \\c => mkCard c twelve ;
ten => \\c => mkCard c twenty
}
} ;
regNum : Str -> {s : DForm => CardOrd => Str} =
\six -> mkNum six (six + "teen") (six + "ty") (regOrd six) ;
regCardOrd : Str -> {s : CardOrd => Str} = \ten ->
{s = table {NCard => ten ; NOrd => regOrd ten}} ;
mkCard : CardOrd -> Str -> Str = \c,ten -> (regCardOrd ten).s ! c ;
regOrd : Str -> Str = \ten -> case last ten of {
"y" => init ten + "ieth" ;
_ => ten + "th"
} ;
}

View File

@@ -1,6 +1,8 @@
abstract Test =
Noun,
Verb,
Adjective,
Numeral,
Sentence,
Question,
Untensed,

View File

@@ -1,6 +1,10 @@
--# -path=.:prelude
concrete TestEng of Test =
NounEng,
VerbEng,
AdjectiveEng,
NumeralEng,
SentenceEng,
QuestionEng,
UntensedEng,