diff --git a/lib/prelude/Coordination.gf b/lib/prelude/Coordination.gf index 6ed4af791..85073da24 100644 --- a/lib/prelude/Coordination.gf +++ b/lib/prelude/Coordination.gf @@ -102,4 +102,17 @@ oper comma = "," ; +-- you can also do this to right-associative lists: + + consrStr : Str -> Str -> ListX -> ListX = \comma,x,xs -> + {s1 = x ++ comma ++ xs.s1 ; s2 = xs.s2 } ; + + consrSS : Str -> SS -> ListX -> ListX = \comma,x,xs -> + consrStr comma x.s xs ; + + consrTable : (P : Type) -> Str -> {s : P => Str} -> ListTable P -> ListTable P = + \P,c,x,xs -> + {s1 = table P {o => x.s ! o ++ c ++ xs.s1 ! o} ; s2 = xs.s2} ; + + } ; diff --git a/lib/resource-1.0/abstract/Cat.gf b/lib/resource-1.0/abstract/Cat.gf index f68f79b10..8cc264920 100644 --- a/lib/resource-1.0/abstract/Cat.gf +++ b/lib/resource-1.0/abstract/Cat.gf @@ -74,13 +74,6 @@ abstract Cat = { CAdv ; -- comparative adverb e.g. "more", "less" Subj ; -- subjunction, e.g. "if", "when" - SeqS ; -- sequence of sentences - SeqVP ; -- sequence of verb phrases - SeqAP ; -- sequence of adjectival phrases - SeqNP ; -- sequence of noun phrases - SeqAdv ; -- sequence of adverbs - Voc ; -- vocative or "please" - } diff --git a/lib/resource-1.0/abstract/Conjunction.gf b/lib/resource-1.0/abstract/Conjunction.gf index 0c8ea9559..cb817559b 100644 --- a/lib/resource-1.0/abstract/Conjunction.gf +++ b/lib/resource-1.0/abstract/Conjunction.gf @@ -2,26 +2,22 @@ abstract Conjunction = Cat ** { fun - ConjS : Conj -> SeqS -> S ; -- "John walks and Mary runs" - ConjAP : Conj -> SeqAP -> AP ; -- "even and prime" - ConjNP : Conj -> SeqNP -> NP ; -- "John or Mary" - ConjAdv : Conj -> SeqAdv -> Adv ; -- "quickly or slowly" + ConjS : Conj -> [S] -> S ; -- "John walks and Mary runs" + ConjAP : Conj -> [AP] -> AP ; -- "even and prime" + ConjNP : Conj -> [NP] -> NP ; -- "John or Mary" + ConjAdv : Conj -> [Adv] -> Adv ; -- "quickly or slowly" - DConjS : DConj -> SeqS -> S ; -- "either John walks or Mary runs" - DConjAP : DConj -> SeqAP -> AP ; -- "both even and prime" - DConjNP : DConj -> SeqNP -> NP ; -- "either John or Mary" - DConjAdv : DConj -> SeqAdv -> Adv ; -- "both badly and slowly" + DConjS : DConj -> [S] -> S ; -- "either John walks or Mary runs" + DConjAP : DConj -> [AP] -> AP ; -- "both even and prime" + DConjNP : DConj -> [NP] -> NP ; -- "either John or Mary" + DConjAdv : DConj -> [Adv] -> Adv ; -- "both badly and slowly" +-- These categories are internal to this module. --- these are rather uninteresting - - TwoS : S -> S -> SeqS ; - AddS : SeqS -> S -> SeqS ; - TwoAdv : Adv -> Adv -> SeqAdv ; - AddAdv : SeqAdv -> Adv -> SeqAdv ; - TwoNP : NP -> NP -> SeqNP ; - AddNP : SeqNP -> NP -> SeqNP ; - TwoAP : AP -> AP -> SeqAP ; - AddAP : SeqAP -> AP -> SeqAP ; + cat + [S]{2} ; + [Adv]{2} ; + [NP]{2} ; + [AP]{2} ; } diff --git a/lib/resource-1.0/doc/Resource-HOWTO.html b/lib/resource-1.0/doc/Resource-HOWTO.html index 20815c929..20a099074 100644 --- a/lib/resource-1.0/doc/Resource-HOWTO.html +++ b/lib/resource-1.0/doc/Resource-HOWTO.html @@ -20,10 +20,12 @@ will give some hints how to extend the API.

-Notice. This document concerns the API V. 1.0 which has not +Notice. This document concerns the API v. 1.0 which has not yet been released. You can find the beginnings of it -in GF/lib/resource-1.0/gf, but the locations of -files are not yet final. +in GF/lib/resource-1.0/. See the +resource-1.0/README for +details on how this differs from previous versions. +

The resource grammar API

@@ -178,7 +180,7 @@ are building a grammar for the Dutch language. Here are the first steps. and rename them:
        cp ../english/*Eng.gf .
-       rename -n 's/Eng/Dut/' *Eng.gf
+       rename 's/Eng/Dut/' *Eng.gf
      
  • Change the Eng module references to Dut references @@ -194,18 +196,34 @@ are building a grammar for the Dutch language. Here are the first steps. But you will have to make lots of manual changes in all files anyway! -
  • Comment out the contents of these files, except their headers and module - brackets. This will give you a set of templates out of which the grammar +
  • Comment out the contents of these files: +
    +       sed -i 's/^/--/' *Dut.gf
    +     
    + This will give you a set of templates out of which the grammar will grow as you uncomment and modify the files rule by rule. +
  • In the file TestDut.gf, uncomment all lines except the list + of inherited modules. Now you can open the grammar in GF: +
    +       gf TestDut.gf
    +     
    + +
  • Now you will at all following steps have a valid, but incomplete + GF grammar. The GF command +
    +       pg -printer=missing
    +     
    + tells you what exactly is missing. +

    The develop-test cycle

    -Now starts the real work. The order in which the Phrase modules +The real work starts now. The order in which the Phrase modules were introduced above is a natural order to proceed, even though not the -only one. So you will find yourseld iterating the following steps: +only one. So you will find yourself iterating the following steps:
    1. Select a phrase category module, e.g. NounDut, and uncomment one diff --git a/lib/resource-1.0/english/CatEng.gf b/lib/resource-1.0/english/CatEng.gf index 663315ae7..2cc48064b 100644 --- a/lib/resource-1.0/english/CatEng.gf +++ b/lib/resource-1.0/english/CatEng.gf @@ -57,9 +57,4 @@ concrete CatEng of Cat = open ResEng, Prelude, (R = ParamX) in { Conj = {s : Str ; n : Number} ; DConj = {s1,s2 : Str ; n : Number} ; - SeqS = {s1,s2 : Str} ; - SeqAdv = {s1,s2 : Str} ; - SeqNP = {s1,s2 : Case => Str ; a : Agr} ; - SeqAP = {s1,s2 : Agr => Str ; isPre : Bool} ; - } diff --git a/lib/resource-1.0/english/ConjunctionEng.gf b/lib/resource-1.0/english/ConjunctionEng.gf index 6bc13bc58..f34c42f16 100644 --- a/lib/resource-1.0/english/ConjunctionEng.gf +++ b/lib/resource-1.0/english/ConjunctionEng.gf @@ -23,13 +23,21 @@ concrete ConjunctionEng of Conjunction = isPre = ss.isPre } ; - TwoS = twoSS ; - AddS = consSS comma ; - TwoAdv = twoSS ; - AddAdv = consSS comma ; - TwoNP x y = twoTable Case x y ** {a = conjAgr x.a y.a} ; - AddNP xs x = consTable Case comma xs x ** {a = conjAgr xs.a x.a} ; - TwoAP x y = twoTable Agr x y ** {isPre = andB x.isPre y.isPre} ; - AddAP xs x = consTable Agr comma xs x ** {isPre = andB xs.isPre x.isPre} ; +-- These fun's are generated from the list cat's. + + BaseS = twoSS ; + ConsS = consrSS comma ; + BaseAdv = twoSS ; + ConsAdv = consrSS comma ; + BaseNP x y = twoTable Case x y ** {a = conjAgr x.a y.a} ; + ConsNP xs x = consrTable Case comma xs x ** {a = conjAgr xs.a x.a} ; + BaseAP x y = twoTable Agr x y ** {isPre = andB x.isPre y.isPre} ; + ConsAP xs x = consrTable Agr comma xs x ** {isPre = andB xs.isPre x.isPre} ; + + lincat + [S] = {s1,s2 : Str} ; + [Adv] = {s1,s2 : Str} ; + [NP] = {s1,s2 : Case => Str ; a : Agr} ; + [AP] = {s1,s2 : Agr => Str ; isPre : Bool} ; } diff --git a/lib/resource-1.0/english/IrregEng.gf b/lib/resource-1.0/english/IrregEng.gf index 6297e46e0..fa5cc2936 100644 --- a/lib/resource-1.0/english/IrregEng.gf +++ b/lib/resource-1.0/english/IrregEng.gf @@ -2,6 +2,8 @@ concrete IrregEng of IrregEngAbs = CatEng ** open ParadigmsEng in { +flags optimize=values ; + lin awake_V = irregV "awake" "awoke" "awoken" ; bear_V = irregV "bear" "bore" "born" ;