mirror of
https://github.com/GrammaticalFramework/gf-core.git
synced 2026-04-10 21:39:32 -06:00
coordination to built-in lists
This commit is contained in:
@@ -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} ;
|
||||
|
||||
|
||||
} ;
|
||||
|
||||
@@ -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"
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -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} ;
|
||||
|
||||
}
|
||||
|
||||
@@ -20,10 +20,12 @@ will give some hints how to extend the API.
|
||||
|
||||
<p>
|
||||
|
||||
<b>Notice</b>. This document concerns the API V. 1.0 which has not
|
||||
<b>Notice</b>. This document concerns the API v. 1.0 which has not
|
||||
yet been released. You can find the beginnings of it
|
||||
in <tt>GF/lib/resource-1.0/gf</tt>, but the locations of
|
||||
files are not yet final.
|
||||
in <a href=".."><tt>GF/lib/resource-1.0/</tt></a>. See the
|
||||
<a href="../README"><tt>resource-1.0/README</tt></a> for
|
||||
details on how this differs from previous versions.
|
||||
|
||||
|
||||
|
||||
<h2>The resource grammar API</h2>
|
||||
@@ -178,7 +180,7 @@ are building a grammar for the Dutch language. Here are the first steps.
|
||||
and rename them:
|
||||
<pre>
|
||||
cp ../english/*Eng.gf .
|
||||
rename -n 's/Eng/Dut/' *Eng.gf
|
||||
rename 's/Eng/Dut/' *Eng.gf
|
||||
</pre>
|
||||
|
||||
<li> Change the <tt>Eng</tt> module references to <tt>Dut</tt> references
|
||||
@@ -194,18 +196,34 @@ are building a grammar for the Dutch language. Here are the first steps.
|
||||
</pre>
|
||||
But you will have to make lots of manual changes in all files anyway!
|
||||
|
||||
<li> 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
|
||||
<li> Comment out the contents of these files:
|
||||
<pre>
|
||||
sed -i 's/^/--/' *Dut.gf
|
||||
</pre>
|
||||
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.
|
||||
|
||||
<li> In the file <tt>TestDut.gf</tt>, uncomment all lines except the list
|
||||
of inherited modules. Now you can open the grammar in GF:
|
||||
<pre>
|
||||
gf TestDut.gf
|
||||
</pre>
|
||||
|
||||
<li> Now you will at all following steps have a valid, but incomplete
|
||||
GF grammar. The GF command
|
||||
<pre>
|
||||
pg -printer=missing
|
||||
</pre>
|
||||
tells you what exactly is missing.
|
||||
|
||||
</ol>
|
||||
|
||||
|
||||
<h3>The develop-test cycle</h3>
|
||||
|
||||
Now starts the real work. The order in which the <tt>Phrase</tt> modules
|
||||
The real work starts now. The order in which the <tt>Phrase</tt> 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:
|
||||
|
||||
<ol>
|
||||
<li> Select a phrase category module, e.g. <tt>NounDut</tt>, and uncomment one
|
||||
|
||||
@@ -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} ;
|
||||
|
||||
}
|
||||
|
||||
@@ -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} ;
|
||||
|
||||
}
|
||||
|
||||
@@ -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" ;
|
||||
|
||||
Reference in New Issue
Block a user