mirror of
https://github.com/GrammaticalFramework/gf-core.git
synced 2026-04-23 11:42:49 -06:00
coordination to built-in lists
This commit is contained in:
@@ -102,4 +102,17 @@ oper
|
|||||||
|
|
||||||
comma = "," ;
|
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"
|
CAdv ; -- comparative adverb e.g. "more", "less"
|
||||||
Subj ; -- subjunction, e.g. "if", "when"
|
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"
|
Voc ; -- vocative or "please"
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,26 +2,22 @@ abstract Conjunction = Cat ** {
|
|||||||
|
|
||||||
fun
|
fun
|
||||||
|
|
||||||
ConjS : Conj -> SeqS -> S ; -- "John walks and Mary runs"
|
ConjS : Conj -> [S] -> S ; -- "John walks and Mary runs"
|
||||||
ConjAP : Conj -> SeqAP -> AP ; -- "even and prime"
|
ConjAP : Conj -> [AP] -> AP ; -- "even and prime"
|
||||||
ConjNP : Conj -> SeqNP -> NP ; -- "John or Mary"
|
ConjNP : Conj -> [NP] -> NP ; -- "John or Mary"
|
||||||
ConjAdv : Conj -> SeqAdv -> Adv ; -- "quickly or slowly"
|
ConjAdv : Conj -> [Adv] -> Adv ; -- "quickly or slowly"
|
||||||
|
|
||||||
DConjS : DConj -> SeqS -> S ; -- "either John walks or Mary runs"
|
DConjS : DConj -> [S] -> S ; -- "either John walks or Mary runs"
|
||||||
DConjAP : DConj -> SeqAP -> AP ; -- "both even and prime"
|
DConjAP : DConj -> [AP] -> AP ; -- "both even and prime"
|
||||||
DConjNP : DConj -> SeqNP -> NP ; -- "either John or Mary"
|
DConjNP : DConj -> [NP] -> NP ; -- "either John or Mary"
|
||||||
DConjAdv : DConj -> SeqAdv -> Adv ; -- "both badly and slowly"
|
DConjAdv : DConj -> [Adv] -> Adv ; -- "both badly and slowly"
|
||||||
|
|
||||||
|
-- These categories are internal to this module.
|
||||||
|
|
||||||
-- these are rather uninteresting
|
cat
|
||||||
|
[S]{2} ;
|
||||||
TwoS : S -> S -> SeqS ;
|
[Adv]{2} ;
|
||||||
AddS : SeqS -> S -> SeqS ;
|
[NP]{2} ;
|
||||||
TwoAdv : Adv -> Adv -> SeqAdv ;
|
[AP]{2} ;
|
||||||
AddAdv : SeqAdv -> Adv -> SeqAdv ;
|
|
||||||
TwoNP : NP -> NP -> SeqNP ;
|
|
||||||
AddNP : SeqNP -> NP -> SeqNP ;
|
|
||||||
TwoAP : AP -> AP -> SeqAP ;
|
|
||||||
AddAP : SeqAP -> AP -> SeqAP ;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,10 +20,12 @@ will give some hints how to extend the API.
|
|||||||
|
|
||||||
<p>
|
<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
|
yet been released. You can find the beginnings of it
|
||||||
in <tt>GF/lib/resource-1.0/gf</tt>, but the locations of
|
in <a href=".."><tt>GF/lib/resource-1.0/</tt></a>. See the
|
||||||
files are not yet final.
|
<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>
|
<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:
|
and rename them:
|
||||||
<pre>
|
<pre>
|
||||||
cp ../english/*Eng.gf .
|
cp ../english/*Eng.gf .
|
||||||
rename -n 's/Eng/Dut/' *Eng.gf
|
rename 's/Eng/Dut/' *Eng.gf
|
||||||
</pre>
|
</pre>
|
||||||
|
|
||||||
<li> Change the <tt>Eng</tt> module references to <tt>Dut</tt> references
|
<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>
|
</pre>
|
||||||
But you will have to make lots of manual changes in all files anyway!
|
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
|
<li> Comment out the contents of these files:
|
||||||
brackets. This will give you a set of templates out of which the grammar
|
<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.
|
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>
|
</ol>
|
||||||
|
|
||||||
|
|
||||||
<h3>The develop-test cycle</h3>
|
<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
|
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>
|
<ol>
|
||||||
<li> Select a phrase category module, e.g. <tt>NounDut</tt>, and uncomment one
|
<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} ;
|
Conj = {s : Str ; n : Number} ;
|
||||||
DConj = {s1,s2 : 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
|
isPre = ss.isPre
|
||||||
} ;
|
} ;
|
||||||
|
|
||||||
TwoS = twoSS ;
|
-- These fun's are generated from the list cat's.
|
||||||
AddS = consSS comma ;
|
|
||||||
TwoAdv = twoSS ;
|
BaseS = twoSS ;
|
||||||
AddAdv = consSS comma ;
|
ConsS = consrSS comma ;
|
||||||
TwoNP x y = twoTable Case x y ** {a = conjAgr x.a y.a} ;
|
BaseAdv = twoSS ;
|
||||||
AddNP xs x = consTable Case comma xs x ** {a = conjAgr xs.a x.a} ;
|
ConsAdv = consrSS comma ;
|
||||||
TwoAP x y = twoTable Agr x y ** {isPre = andB x.isPre y.isPre} ;
|
BaseNP x y = twoTable Case x y ** {a = conjAgr x.a y.a} ;
|
||||||
AddAP xs x = consTable Agr comma xs x ** {isPre = andB xs.isPre x.isPre} ;
|
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 {
|
concrete IrregEng of IrregEngAbs = CatEng ** open ParadigmsEng in {
|
||||||
|
|
||||||
|
flags optimize=values ;
|
||||||
|
|
||||||
lin
|
lin
|
||||||
awake_V = irregV "awake" "awoke" "awoken" ;
|
awake_V = irregV "awake" "awoke" "awoken" ;
|
||||||
bear_V = irregV "bear" "bore" "born" ;
|
bear_V = irregV "bear" "bore" "born" ;
|
||||||
|
|||||||
Reference in New Issue
Block a user