diff --git a/lib/resource-1.0/gf/Adjective.gf b/lib/resource-1.0/gf/Adjective.gf new file mode 100644 index 000000000..c4b721049 --- /dev/null +++ b/lib/resource-1.0/gf/Adjective.gf @@ -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 ; + +} diff --git a/lib/resource-1.0/gf/AdjectiveEng.gf b/lib/resource-1.0/gf/AdjectiveEng.gf new file mode 100644 index 000000000..01312dadf --- /dev/null +++ b/lib/resource-1.0/gf/AdjectiveEng.gf @@ -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 ; + +} diff --git a/lib/resource-1.0/gf/Cat.gf b/lib/resource-1.0/gf/Cat.gf index b74198ad5..018cdeddd 100644 --- a/lib/resource-1.0/gf/Cat.gf +++ b/lib/resource-1.0/gf/Cat.gf @@ -19,7 +19,13 @@ abstract Cat = { AP ; Comp ; + A ; + A2 ; + Adv ; + AdV ; + AdA ; + AdS ; CN ; N ; @@ -42,4 +48,6 @@ abstract Cat = { RP ; -} \ No newline at end of file + Numeral ; + +} diff --git a/lib/resource-1.0/gf/CatEng.gf b/lib/resource-1.0/gf/CatEng.gf index a63134af5..ee34f7a09 100644 --- a/lib/resource-1.0/gf/CatEng.gf +++ b/lib/resource-1.0/gf/CatEng.gf @@ -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} ; + } diff --git a/lib/resource-1.0/gf/Lex.gf b/lib/resource-1.0/gf/Lex.gf index 5e3b6bdb0..0e9185718 100644 --- a/lib/resource-1.0/gf/Lex.gf +++ b/lib/resource-1.0/gf/Lex.gf @@ -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 ; } diff --git a/lib/resource-1.0/gf/LexEng.gf b/lib/resource-1.0/gf/LexEng.gf index 72c74787e..7fe74aaa3 100644 --- a/lib/resource-1.0/gf/LexEng.gf +++ b/lib/resource-1.0/gf/LexEng.gf @@ -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} ; diff --git a/lib/resource-1.0/gf/Noun.gf b/lib/resource-1.0/gf/Noun.gf index 6c3dca9f8..5a7d6454c 100644 --- a/lib/resource-1.0/gf/Noun.gf +++ b/lib/resource-1.0/gf/Noun.gf @@ -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 ; diff --git a/lib/resource-1.0/gf/NounEng.gf b/lib/resource-1.0/gf/NounEng.gf index 68de2e676..57a48bb45 100644 --- a/lib/resource-1.0/gf/NounEng.gf +++ b/lib/resource-1.0/gf/NounEng.gf @@ -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 ; } diff --git a/lib/resource-1.0/gf/Numeral.gf b/lib/resource-1.0/gf/Numeral.gf new file mode 100644 index 000000000..ea9260aa0 --- /dev/null +++ b/lib/resource-1.0/gf/Numeral.gf @@ -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 +} diff --git a/lib/resource-1.0/gf/NumeralEng.gf b/lib/resource-1.0/gf/NumeralEng.gf new file mode 100644 index 000000000..142d82eed --- /dev/null +++ b/lib/resource-1.0/gf/NumeralEng.gf @@ -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 of { + => "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} ; +} diff --git a/lib/resource-1.0/gf/ParamX.gf b/lib/resource-1.0/gf/ParamX.gf index 0aa321b59..61bb60c9a 100644 --- a/lib/resource-1.0/gf/ParamX.gf +++ b/lib/resource-1.0/gf/ParamX.gf @@ -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 ; diff --git a/lib/resource-1.0/gf/ResEng.gf b/lib/resource-1.0/gf/ResEng.gf index 75c0258d9..2784a67c0 100644 --- a/lib/resource-1.0/gf/ResEng.gf +++ b/lib/resource-1.0/gf/ResEng.gf @@ -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" + } ; + } diff --git a/lib/resource-1.0/gf/Test.gf b/lib/resource-1.0/gf/Test.gf index dfb43e693..0aafc7b79 100644 --- a/lib/resource-1.0/gf/Test.gf +++ b/lib/resource-1.0/gf/Test.gf @@ -1,6 +1,8 @@ abstract Test = Noun, Verb, + Adjective, + Numeral, Sentence, Question, Untensed, diff --git a/lib/resource-1.0/gf/TestEng.gf b/lib/resource-1.0/gf/TestEng.gf index b006ebf28..1938a7f1a 100644 --- a/lib/resource-1.0/gf/TestEng.gf +++ b/lib/resource-1.0/gf/TestEng.gf @@ -1,6 +1,10 @@ +--# -path=.:prelude + concrete TestEng of Test = NounEng, VerbEng, + AdjectiveEng, + NumeralEng, SentenceEng, QuestionEng, UntensedEng,