From a62523e09f14bd311e9be762c65843dbfaa6b2bd Mon Sep 17 00:00:00 2001 From: aarne Date: Wed, 16 Nov 2005 10:28:47 +0000 Subject: [PATCH] ordinals --- lib/resource/english/MorphoEng.gf | 32 ++++++++--- lib/resource/english/NumeralsEng.gf | 52 ++++++++++-------- lib/resource/english/StructuralEng.gf | 3 +- lib/resource/english/TimeEng.gf | 6 +-- lib/resource/exper/Adj.cf | 11 +--- lib/resource/exper/Adverb.cf | 7 +-- lib/resource/exper/Lex.cf | 37 +++++++++++-- lib/resource/exper/Noun.cf | 52 ++++++++---------- lib/resource/exper/Numeral.cf | 77 +++++++++++++++++++++++++++ lib/resource/exper/Phrase.cf | 12 +++-- lib/resource/exper/Rules.cf | 2 +- lib/resource/exper/Sent.cf | 28 ++++++---- lib/resource/exper/Structural.cf | 31 +++++++++++ lib/resource/exper/Verb.cf | 18 ++----- 14 files changed, 255 insertions(+), 113 deletions(-) create mode 100644 lib/resource/exper/Numeral.cf create mode 100644 lib/resource/exper/Structural.cf diff --git a/lib/resource/english/MorphoEng.gf b/lib/resource/english/MorphoEng.gf index 5e6060c2d..c87558618 100644 --- a/lib/resource/english/MorphoEng.gf +++ b/lib/resource/english/MorphoEng.gf @@ -310,12 +310,32 @@ oper -- From $numerals$. -param DForm = unit | teen | ten ; -oper mkNum : Str -> Str -> Str -> {s : DForm => Str} = - \two -> \twelve -> \twenty -> - {s = table {unit => two ; teen => twelve ; ten => twenty}} ; -oper regNum : Str -> {s : DForm => Str} = - \six -> mkNum six (six + "teen") (six + "ty") ; +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/english/NumeralsEng.gf b/lib/resource/english/NumeralsEng.gf index fa8198859..1d2a14a9d 100644 --- a/lib/resource/english/NumeralsEng.gf +++ b/lib/resource/english/NumeralsEng.gf @@ -1,35 +1,45 @@ concrete NumeralsEng of Numerals = open Prelude, MorphoEng in { -lincat Numeral = {s : Str ; n : Number} ; -lincat Digit = {s : DForm => Str} ; -lincat Sub10 = {s : DForm => Str ; n : Number} ; - Sub100 = {s : Str ; n : Number} ; - Sub1000 = {s : Str ; n : Number} ; - Sub1000000 = {s : Str ; n : Number} ; +lincat Numeral = {s : CardOrd => Str ; n : Number} ; +lincat Digit = {s : DForm => CardOrd => Str} ; +lincat + 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 = mkNum "two" "twelve" "twenty" ; -lin n3 = mkNum "three" "thirteen" "thirty" ; -lin n4 = mkNum "four" "fourteen" "forty" ; -lin n5 = mkNum "five" "fifteen" "fifty" ; +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" ; +lin n8 = mkNum "eight" "eighteen" "eighty" "eighth" ; lin n9 = regNum "nine" ; -lin pot01 = {s = table {f => "one"} ; n = Sg} ; -lin pot0 d = {s = table {f => d.s ! f} ; n = Pl} ; -lin pot110 = ss "ten" ** {n = Pl} ; -lin pot111 = ss "eleven" ** {n = Pl} ; +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 = d.s ! ten ++ "-" ++ e.s ! unit} ** {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 = d.s ! unit ++ "hundred"} ** {n = Pl} ; -lin pot2plus d e = {s = d.s ! unit ++ "hundred" ++ "and" ++ e.s} ** {n = Pl} ; +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 = n.s ++ "thousand"} ** {n = Pl} ; -lin pot3plus n m = {s = n.s ++ "thousand" ++ m.s} ** {n = Pl} ; - +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/english/StructuralEng.gf b/lib/resource/english/StructuralEng.gf index 2e6b0d62a..d6f318c03 100644 --- a/lib/resource/english/StructuralEng.gf +++ b/lib/resource/english/StructuralEng.gf @@ -10,7 +10,8 @@ concrete StructuralEng of Structural = flags optimize=all ; lin - UseNumeral i = {s = table {Nom => i.s ; Gen => i.s ++ "'s"} ; n = i.n} ; --- + UseNumeral i = { + s = table {Nom => i.s ! NCard ; Gen => i.s ! NCard ++ "'s"} ; n = i.n} ; --- above_Prep = ss "above" ; diff --git a/lib/resource/english/TimeEng.gf b/lib/resource/english/TimeEng.gf index b5759fda1..330804f2c 100644 --- a/lib/resource/english/TimeEng.gf +++ b/lib/resource/english/TimeEng.gf @@ -1,5 +1,5 @@ concrete TimeEng of Time = NumeralsEng ** - open Prelude, CategoriesEng, ParadigmsEng in { + open Prelude, CategoriesEng, ParadigmsEng, MorphoEng in { lincat Date = SS ; @@ -17,8 +17,8 @@ PastTime h m = ss (m.s ++ "past" ++ h.s) ; ToTime h m = ss (m.s ++ "to" ++ h.s) ; ExactTime h = ss (h.s ++ "sharp") ; -NumHour n = n ; -NumMinute n = n ; +NumHour n = {s = n.s ! NCard} ; +NumMinute n = {s = n.s ! NCard} ; monday = regN "Monday" ; tuesday = regN "Tuesday" ; diff --git a/lib/resource/exper/Adj.cf b/lib/resource/exper/Adj.cf index 720d7f768..a93ccfe6e 100644 --- a/lib/resource/exper/Adj.cf +++ b/lib/resource/exper/Adj.cf @@ -1,6 +1,7 @@ PositA. AP ::= A ; ComplA2. AP_post ::= A2 Prep NP ; ComparA. AP_post ::= "more" A "than" NP ; +AP_post ::= "less" A "than" NP ; -- superlatives à la CLE @@ -10,17 +11,9 @@ Num_Pl ::= "most" A ; ComplAV. AP_post ::= AV Prep VP ; UseA2V. AV ::= A2V Prep NP ; -PredAS. Cl ::= "it" "be" AS "that" S ; +PredAS. Cl ::= "it" Cop AS "that" S ; ComplAQ. AP ::= AQ "of" QS ; ---- TODO: comparison of AV etc --- lexicon - -A ::= "intelligent" ; -A2 ::= "devoted" ; -AV ::= "tedious" ; -AV ::= "difficult" ; -AS ::= "marvellous" ; -AQ ::= "independent" ; diff --git a/lib/resource/exper/Adverb.cf b/lib/resource/exper/Adverb.cf index 94ccd5a5b..6e6da9098 100644 --- a/lib/resource/exper/Adverb.cf +++ b/lib/resource/exper/Adverb.cf @@ -2,7 +2,7 @@ AdjAdv. Adv ::= A "+ly" ; AdvPP. Adv ::= PP ; -PrepNP. Adv ::= Prep NP ; +PrepNP. PP ::= Prep NP ; -- NO AdvCN AdvVP. VP ::= VP Adv ; @@ -14,9 +14,4 @@ AdvAdv. Adv ::= AdA Adv ; VP ::= AdV VP ; --- lexicon -Prep ::= "of" | "to" ; -Adv ::= "here" ; -AdA ::= "very" ; -AdV ::= "always" ; diff --git a/lib/resource/exper/Lex.cf b/lib/resource/exper/Lex.cf index 518a4ea3e..c0e1d64e7 100644 --- a/lib/resource/exper/Lex.cf +++ b/lib/resource/exper/Lex.cf @@ -1,9 +1,36 @@ --- a bigger lexicon +-- some open lexicon -Pron ::= "I" | "me" | "he" | "she" ; -Pron ::= "us" | "we" ; -Poss ::= "your" | "his" | "her" | "our" ; -Prep ::= "about" | "for" | "from" | "in" ; +N_Pl ::= "sons" ; +N ::= "son" ; + +N ::= "wine" ; + +N2 ::= "plan" ; +N3 ::= "value" ; + +PN ::= "John" ; + +A ::= "intelligent" ; +A2 ::= "devoted" ; +AV ::= "tedious" ; +AV ::= "difficult" ; +AS ::= "marvellous" ; +AQ ::= "independent" ; + +V0 ::= "rain" | "rains" ; +V ::= "sleeps" | "sleep" ; +V2 ::= "loves" | "love" ; +V3 ::= "sends" | "send" ; +VV ::= "wants" | "want" ; + +Adv ::= "here" ; +AdA ::= "very" ; +AdV ::= "always" ; + + +-- a bigger lexicon N ::= "car" | "house" | "flight" | "aircraft" ; N_Pl ::= "cars" | "houses" | "flights" | "aircraft" ; + +PN ::= "Boston" | "New" "York" | "Baltimore" ; diff --git a/lib/resource/exper/Noun.cf b/lib/resource/exper/Noun.cf index c5318bcf4..1874fd2cf 100644 --- a/lib/resource/exper/Noun.cf +++ b/lib/resource/exper/Noun.cf @@ -1,45 +1,49 @@ NP ::= Det CN ; NP ::= PN ; NP ::= Pron ; -Det ::= Predet Quant Num ; -Det ::= Predet Quant ; +NP ::= Predet Quant Num ; +Det ::= Predet Quant OptNum ; Predet ::= ; -Predet ::= "only" | "just" ; -Quant ::= "this" | "the" | "a" | "every" | "some" ; - -Num ::= "one" ; +-- examples +-- Predet ::= "only" | "just" ; +-- Quant ::= "this" | "the" | "a" | "every" | "some" ; +-- Num ::= "one" ; Quant ::= Poss ; -Quant ::= ; -- for NMass +OptNum ::= | Num ; + +Num ::= Ordinal ; + +-- instead of NMass +Quant ::= ; ---NP ::= DetMass NMass ; ---DetMass ::= Predet Quant ; ---DetMass ::= Predet ; ---NMass ::= "wine" ; -Pron ::= "you" ; + + NP ::= Det_Pl CN_Pl ; NP ::= Predet_Pl Quant_Pl Num_Pl ; -- nonempty det -Det_Pl ::= Predet_Pl Quant_Pl Num_Pl ; -Det_Pl ::= Predet_Pl Quant_Pl ; +Det_Pl ::= Predet_Pl Quant_Pl OptNum_Pl ; Predet_Pl ::= ; Quant_Pl ::= ; -Predet_Pl ::= "all" | "only" | "just" ; - -Quant_Pl ::= "these" | "many" | "some" ; - Quant_Pl ::= Poss ; -Poss ::= NP "'s" | "my" ; +Poss ::= NP "'s" ; -- also "my" ; +OptNum_Pl ::= | Num_Pl ; + +Num_Pl ::= Ordinal ; Num_Pl ::= Int ; -Num_Pl ::= "four" ; +Num_Pl ::= Numeral ; CN_Pl ::= N_Pl ; CN ::= N ; @@ -47,8 +51,8 @@ CN ::= N ; -- prepositions cannot be expressed generally here -- NB relational nouns explain why complements are closer than adjuncts -CN ::= N2 "for" NP ; -N2 ::= N3 "of" NP ; +CN ::= N2 Prep NP ; +N2 ::= N3 Prep NP ; -- elliptical constructions @@ -64,15 +68,3 @@ CN ::= CN "that" S ; CN_Pl ::= AP CN_Pl ; CN_Pl ::= CN_Pl AP_post ; --- some open lexicon - -N_Pl ::= "sons" ; -N ::= "son" ; - -N2 ::= "plan" ; -N3 ::= "value" ; - -N ::= "wine" ; - -PN ::= "John" ; - diff --git a/lib/resource/exper/Numeral.cf b/lib/resource/exper/Numeral.cf new file mode 100644 index 000000000..427eea8c3 --- /dev/null +++ b/lib/resource/exper/Numeral.cf @@ -0,0 +1,77 @@ +-- overgenerating from NumeralsEng + +Ordinal ::= DigitO | Numeral DigitO ; + +-- usable in Sg +Num ::= "one" ; + +pot2as3. Sub1000000 ::= Sub1000 ; +pot3. Sub1000000 ::= Sub1000 "thousand" ; +pot3plus. Sub1000000 ::= Sub1000 "thousand" Sub1000 ; +pot1as2. Sub1000 ::= Sub100 ; +pot2. Sub1000 ::= Sub10 "hundred" ; +pot2plus. Sub1000 ::= Sub10 "hundred" "and" Sub100 ; +pot0as1. Sub100 ::= Sub10 ; +pot1. Sub100 ::= Digit ; +pot110. Sub100 ::= "ten" ; +pot111. Sub100 ::= "eleven" ; +pot1plus. Sub100 ::= Digit "-" Sub10 ; +pot1to19. Sub100 ::= Digit ; +pot0. Sub10 ::= Digit ; +pot01. Sub10 ::= "one" ; +num. Numeral ::= Sub1000000 ; +n2a. Digit ::= "twelve" ; +n2b. Digit ::= "twenty" ; +n2c. Digit ::= "two" ; +n3a. Digit ::= "thirteen" ; +n3b. Digit ::= "thirty" ; +n3c. Digit ::= "three" ; +n4a. Digit ::= "forty" ; +n4b. Digit ::= "four" ; +n4c. Digit ::= "fourteen" ; +n5a. Digit ::= "fifteen" ; +n5b. Digit ::= "fifty" ; +n5c. Digit ::= "five" ; +n6a. Digit ::= "six" ; +n6b. Digit ::= "sixteen" ; +n6c. Digit ::= "sixty" ; +n7a. Digit ::= "seven" ; +n7b. Digit ::= "seventeen" ; +n7c. Digit ::= "seventy" ; +n8a. Digit ::= "eight" ; +n8b. Digit ::= "eighteen" ; +n8c. Digit ::= "eighty" ; +n9a. Digit ::= "nine" ; +n9b. Digit ::= "nineteen" ; +n9c. Digit ::= "ninety" ; + +n1d. DigitO ::= "first" ; +n1e. DigitO ::= "elevent" ; +n1f. DigitO ::= "tenth" ; +n1g. DigitO ::= "hundredth" ; +n1h. DigitO ::= "thousandth" ; + +n2d. DigitO ::= "second" ; +n2e. DigitO ::= "twelfth" ; +n2f. DigitO ::= "twentieth" ; +n3d. DigitO ::= "thirteenth" ; +n3e. DigitO ::= "third" ; +n3f. DigitO ::= "thirtieth" ; +n4d. DigitO ::= "fourth" ; +n4e. DigitO ::= "fourteenth" ; +n4f. DigitO ::= "fortieth" ; +n5d. DigitO ::= "fifteenth" ; +n5e. DigitO ::= "fifth" ; +n5f. DigitO ::= "fiftieth" ; +n6d. DigitO ::= "sixth" ; +n6e. DigitO ::= "sixteenth" ; +n6f. DigitO ::= "sixtieth" ; +n7d. DigitO ::= "seventh" ; +n7e. DigitO ::= "seventeenth" ; +n7f. DigitO ::= "seventieth" ; +n8d. DigitO ::= "eighth" ; +n8e. DigitO ::= "eighteenth" ; +n8f. DigitO ::= "eightieth" ; +n9d. DigitO ::= "nineth" ; +n9e. DigitO ::= "nineteenth" ; +n9f. DigitO ::= "ninetieth" ; diff --git a/lib/resource/exper/Phrase.cf b/lib/resource/exper/Phrase.cf index 128b725cf..b4e9d30d5 100644 --- a/lib/resource/exper/Phrase.cf +++ b/lib/resource/exper/Phrase.cf @@ -1,8 +1,10 @@ -Phr ::= PConj Imp ; Phr ::= PConj S ; -Phr ::= PConj QS ; -Phr ::= PConj "please" Imp | PConj QS "please" ; -Phr ::= PConj NP | PConj NP "please" ; +Phr ::= PConj Imp Please ; +Phr ::= PConj QS Please ; +Phr ::= PConj NP Please ; +Phr ::= PConj PP Please ; +Phr ::= PConj "to" VP Please ; -PConj ::= | "and" | "but" | "therefore" ; + +Please ::= | "please" ; diff --git a/lib/resource/exper/Rules.cf b/lib/resource/exper/Rules.cf index fd8dc284d..fdbee556d 100644 --- a/lib/resource/exper/Rules.cf +++ b/lib/resource/exper/Rules.cf @@ -1,2 +1,2 @@ --- include Det.cf Adj.cf Verb.cf Sent.cf Adverb.cf Phrase.cf Lex.cf +-- include Noun.cf Adj.cf Verb.cf Sent.cf Adverb.cf Phrase.cf Numeral.cf Structural.cf Lex.cf diff --git a/lib/resource/exper/Sent.cf b/lib/resource/exper/Sent.cf index a0c48eece..51d9fb77c 100644 --- a/lib/resource/exper/Sent.cf +++ b/lib/resource/exper/Sent.cf @@ -1,6 +1,7 @@ --- just one tense considered; no agreement forced -S ::= NP Do VP ; +S ::= NP VP ; +S ::= NP Mod VP ; S ::= Adv "," S ; -- slash category instead of gaps @@ -13,35 +14,40 @@ Slash ::= Slash Adv ; -- who does my son love here -- questions -QS ::= Do NP VP ; +QS ::= Mod NP VP ; -- this will be eliminated via richer lintypes QS ::= Cop NP Comp ; IntVP. QS ::= IP VP ; -QS ::= IP Do VP ; -IntSlash. QS ::= IP Do Slash ; +QS ::= IP Mod VP ; +IntSlash. QS ::= IP Mod Slash ; -- general: QuestAdv : IAdv -> Cl -> QCl ; -QS ::= IAdv Do NP VP ; +QS ::= IAdv Mod NP VP ; QS ::= IAdv Cop NP ; -IAdv ::= "why" | "where" | "when" ; +IAdv ::= Prep IP ; -- relatives RelVP. RS ::= RP VP ; -RS ::= RP "doesn't" VP ; +RS ::= RP Mod VP ; RelSlash. RS ::= RP Slash ; +RS ::= Slash ; -- CLE syntax of relatives NP ::= NP RS ; -IP ::= "who" ; -FunIP. IP ::= "the" N2 "of" IP ; +FunIP. IP ::= "the" N2 Prep IP ; -RP ::= "which" ; -FunRP. RP ::= "the" N2 "of" RP ; -- ? +IP ::= IDet OptNum CN ; +IP ::= IDet OptNum_Pl CN_Pl ; +IP ::= IP PP ; + +FunRP. RP ::= "the" N2 Prep RP ; -- ? +RP ::= "whose" OptNum CN ; +RP ::= "whose" OptNum_Pl CN_Pl ; -- imperative diff --git a/lib/resource/exper/Structural.cf b/lib/resource/exper/Structural.cf new file mode 100644 index 000000000..22af455cc --- /dev/null +++ b/lib/resource/exper/Structural.cf @@ -0,0 +1,31 @@ +-- structural words + +Predet ::= "only" | "just" ; + +Quant ::= "this" | "that" | "the" | "a" | "every" | "some" ; + +Predet_Pl ::= "all" | "only" | "just" | "most" "of" ; + +Quant_Pl ::= "these" | "those" | "the" | "many" | "some" ; + +Pron ::= "I" | "you" | "he" | "she" | "we" | "they" ; +Pron ::= "me" | "him" | "her" | "us" | "them" ; +Poss ::= "my" | "your" | "his" | "her" | "our" | "their" ; + +Prep ::= "about" | "at" | "by" | "for" | "from" | "in" | "on" | "to" | "with" ; + +IAdv ::= "why" | "where" | "when" | "how" ; + +IP ::= "who" | "what" ; + +IDet ::= "which" | "how" "many" | "whose" ; + +RP ::= "which" | "who" | "that" | "whom" ; + +PConj ::= | "and" | "but" | "therefore" ; + +-- these may be eliminated in gf + +Cop ::= "is" | "are" | "isn't" | "aren't" | "be" | "am" | "am" "not" ; +Do ::= "do" | "does" | "doesn't" | "don't" ; +Mod ::= "can" | "can't" | "would" | "wouldn't" | "will" | "won't" ; diff --git a/lib/resource/exper/Verb.cf b/lib/resource/exper/Verb.cf index 6be647d9c..36b45aef4 100644 --- a/lib/resource/exper/Verb.cf +++ b/lib/resource/exper/Verb.cf @@ -9,20 +9,8 @@ ComplVV. VP ::= VV "to" VP ; VP ::= Cop Comp ; Comp ::= AP | NP | Adv ; +Comp ::= AP_post ; -- not needed in gf + +Mod ::= Do ; -- partial saturation - - - --- in the lexicon, we must give up verb agreement - -V0 ::= "rain" | "rains" ; -V ::= "sleeps" | "sleep" ; -V2 ::= "loves" | "love" ; -V3 ::= "sends" | "send" ; -VV ::= "wants" | "want" ; - --- these may be eliminated - -Cop ::= "is" | "are" | "isn't" | "aren't" | "be" ; -Do ::= "do" | "does" | "doesn't" | "don't" ;