1
0
forked from GitHub/gf-rgl

improved resource doc

This commit is contained in:
aarne
2005-05-22 18:43:00 +00:00
parent ace67e1b70
commit 7e9ce03dce
14 changed files with 123 additions and 75 deletions

View File

@@ -31,7 +31,7 @@ gfdoc:
gfdoc ../italian/BeschIta.gf ; mv ../italian/BeschIta.html . gfdoc ../italian/BeschIta.gf ; mv ../italian/BeschIta.html .
gfdoc ../spanish/ParadigmsSpa.gf ; mv ../spanish/ParadigmsSpa.html . gfdoc ../spanish/ParadigmsSpa.gf ; mv ../spanish/ParadigmsSpa.html .
# gfdoc ../spanish/BasicSpa.gf ; mv ../spanish/BasicSpa.html . gfdoc ../spanish/BasicSpa.gf ; mv ../spanish/BasicSpa.html .
gfdoc ../spanish/BeschSpa.gf ; mv ../spanish/BeschSpa.html . gfdoc ../spanish/BeschSpa.gf ; mv ../spanish/BeschSpa.html .
gifs: api lang scand low gifs: api lang scand low

View File

@@ -5,6 +5,6 @@ abstract Animals = Questions ** {
fun fun
-- a lexicon of animals and actions among them -- a lexicon of animals and actions among them
Dog, Cat, Mouse, Lion, Zebra : Entity ; Dog, Cat, Mouse, Lion, Zebra : Entity ;
Chase, Eat, Like : Action ; Chase, Eat, See : Action ;
} }

View File

@@ -11,5 +11,5 @@ concrete AnimalsEng of Animals = QuestionsEng **
Zebra = regN "zebra" ; Zebra = regN "zebra" ;
Chase = dirV2 (regV "chase") ; Chase = dirV2 (regV "chase") ;
Eat = dirV2 eat_V ; Eat = dirV2 eat_V ;
Like = dirV2 (regV "like") ; See = dirV2 see_V ;
} }

View File

@@ -11,5 +11,5 @@ concrete AnimalsFre of Animals = QuestionsFre **
Zebra = regN "zèbre" masculine ; Zebra = regN "zèbre" masculine ;
Chase = dirV2 (regV "chasser") ; Chase = dirV2 (regV "chasser") ;
Eat = dirV2 (regV "manger") ; Eat = dirV2 (regV "manger") ;
Like = dirV2 (regV "aimer") ; See = voir_V2 ;
} }

View File

@@ -11,5 +11,5 @@ concrete AnimalsSwe of Animals = QuestionsSwe **
Zebra = regN "zebra" utrum ; Zebra = regN "zebra" utrum ;
Chase = dirV2 (regV "jaga") ; Chase = dirV2 (regV "jaga") ;
Eat = dirV2 äta_V ; Eat = dirV2 äta_V ;
Like = mkV2 (mk2V "tycka" "tycker") "om" ; See = dirV2 se_V ;
} }

View File

@@ -1,6 +1,6 @@
--# -path=.:resource/abstract:resource/../prelude --# -path=.:resource/abstract:resource/../prelude
-- Language-independent question grammar parametwized on Resource. -- Language-independent question grammar parametrized on Resource.
incomplete concrete QuestionsI of Questions = open Resource in { incomplete concrete QuestionsI of Questions = open Resource in {
lincat lincat

View File

@@ -9,9 +9,11 @@
<p> <p>
Second Version, Gothenburg, 1 March 2005 Third Version, 22 May 2005
<br> <br>
First Draft, Gothenburg, 7 February 2005 Second Version, 1 March 2005
<br>
First Draft, 7 February 2005
</p><p> </p><p>
@@ -31,7 +33,8 @@ A grammar formalism based on functional programming and type theory.
<p> <p>
Designed to be nice for <i>ordinary programmers</i> to use. Designed to be nice for <i>ordinary programmers</i> to use: by this
we mean programmers without training in linguistics.
<p> <p>
@@ -47,6 +50,7 @@ Thus <i>not</i> primarily another theoretical framework for
linguists. linguists.
<!-- NEW --> <!-- NEW -->
<h2>Multilingual grammars</h2> <h2>Multilingual grammars</h2>
@@ -90,6 +94,7 @@ wenn 2 ist gerade, dann 2+2 ist gerade<br>
om 2 är jämnt, 2+2 är jämnt<br> om 2 är jämnt, 2+2 är jämnt<br>
</i> </i>
<!-- NEW --> <!-- NEW -->
<h2>Solving the difficulties</h2> <h2>Solving the difficulties</h2>
@@ -197,17 +202,15 @@ Where do we get the data from?
<li> automatic extraction or hand-writing? <li> automatic extraction or hand-writing?
<br> <br>
<li> reuse of existing resources? <li> reuse of existing resources?
<br>
<p> Extra constraint: we want open-source free software and
hence cannot use existing proprietary resources.
Extra constraint: we want open-source free software.
<!-- NEW --> <!-- NEW -->
<h2>The scope of the resource grammar library</h2> <h2>The scope of a resource grammar library for a language</h2>
All morphological paradigms All morphological paradigms
@@ -228,6 +231,7 @@ Currently,<br>
<!-- NEW --> <!-- NEW -->
<h2>Success criteria</h2> <h2>Success criteria</h2>
@@ -251,24 +255,33 @@ families, using the module system of GF.
<!-- NEW --> <!-- NEW -->
<h2>These are not our success criteria</h2> <h2>These are not our success criteria</h2>
Language coverage: you can parse all expressions. Example: Language coverage: to be able to parse all expressions.
<br>
Example:
the French <i>passé simple</i> tense, although covered by the the French <i>passé simple</i> tense, although covered by the
morhology, is not used in the language-independent API, but morphology, is not used in the language-independent API, but
only the <i>passé composé</i> is. only the <i>passé composé</i> is. However, an application
accessing the French-specific (or Romance-specific)
modules can use the passé simple.
<p> <p>
Semantic correctness Semantic correctness: only to produce meaningful expressions.
<br>
Example: the following sentences can be generated
<pre> <pre>
colourless green ideas sleep furiously colourless green ideas sleep furiously
the time is seventy past forty-two the time is seventy past forty-two
</pre> </pre>
However, an applicatio grammar can use a domain-specific
semantics to guarantee semantic well-formedness.
<p> <p>
(Warning for linguists:) theoretical innovation in (Warning for linguists:) theoretical innovation in
syntax (and it will all be hidden anyway!) syntax is not among the goals
(and it would be hidden from users anyway!).
@@ -334,6 +347,7 @@ The current GF Resource Project covers ten languages:
The first three letters (<tt>Dan</tt> etc) are used in grammar module names The first three letters (<tt>Dan</tt> etc) are used in grammar module names
<!-- NEW --> <!-- NEW -->
<h2>Library structure 1: language-independent API</h2> <h2>Library structure 1: language-independent API</h2>
@@ -351,6 +365,7 @@ conjunctions, pronouns), e.g.
and_Conj : Conj ; and_Conj : Conj ;
</pre> </pre>
<!-- NEW --> <!-- NEW -->
<h2>Library structure 2: language-dependent modules</h2> <h2>Library structure 2: language-dependent modules</h2>
@@ -477,6 +492,8 @@ Alternative views on sentence formation:
<a href="ParadigmsSpa.html">Spanish paradigms</a> <a href="ParadigmsSpa.html">Spanish paradigms</a>
<br> <br>
<a href="BasicSpa.html">example use of Spanish paradigms</a>
<br>
<a href="BeschSpa.html">Spanish verb conjugations</a> <a href="BeschSpa.html">Spanish verb conjugations</a>
<p> <p>
@@ -491,7 +508,7 @@ Alternative views on sentence formation:
<!-- NEW --> <!-- NEW -->
<h2>Use as top-level grammar: testing</h2> <h2>Use as top-level grammar: testing</h2>
Import a set of $LangX$ grammars: Import a set of <tt>LangX</tt> grammars:
<pre> <pre>
i english/LangEng.gf i english/LangEng.gf
i swedish/LangSwe.gf i swedish/LangSwe.gf
@@ -532,11 +549,14 @@ Import directly by <tt>open</tt>:
<pre> <pre>
concrete AppNor of App = open LangNor, ParadigmsNor in {...} concrete AppNor of App = open LangNor, ParadigmsNor in {...}
</pre> </pre>
No more dummy <tt>reuse</tt> modules and bulky <tt>.gfr</tt> files! (Note for the users of GF 2.1 and older:
the dummy <tt>reuse</tt> modules and their bulky <tt>.gfr</tt> versions
are no longer needed!)
<p> <p>
If you need to convert resource category records to/from strings, use If you need to convert resource records to strings, and don't want to know
the concrete type (as you never should), you can use
<pre> <pre>
Predef.toStr : (L : Type) -> L -> Str ; Predef.toStr : (L : Type) -> L -> Str ;
</pre> </pre>
@@ -548,65 +568,99 @@ If you need to convert resource category records to/from strings, use
<!-- NEW --> <!-- NEW -->
<h2>Use as library through parser</h2> <h2>Use as library through parser</h2>
Use the parser when developing a resource. You can use the parser with a <tt>LangX</tt> grammar
when developing a resource.
<p>
Using the <tt>-v</tt> option shows if the parser fails because
of unknown words.
<pre> <pre>
> p -cat=S -v "jag ska åka till Chalmers" > p -cat=S -v "jag ska åka till Chalmers"
unknown tokens [TS "åka",TS "Chalmers"] unknown tokens [TS "åka",TS "Chalmers"]
</pre>
Then try to select words that <tt>LangX</tt> recognizes:
<pre>
> p -cat=S "jag ska gå till Danmark" > p -cat=S "jag ska gå till Danmark"
UseCl (PosTP TFuture ASimul) UseCl (PosTP TFuture ASimul)
(AdvCl (SPredV i_NP go_V) (AdvCl (SPredV i_NP go_V)
(AdvPP (PrepNP to_Prep (UsePN (PNCountry Denmark))))) (AdvPP (PrepNP to_Prep (UsePN (PNCountry Denmark)))))
</pre> </pre>
Extend vocabulary at need. Use these API structures and extend vocabulary to match your need.
<pre> <pre>
åka_V = lexV "åker" ; åka_V = lexV "åker" ;
Chalmers = regPN "Chalmers" neutrum ; Chalmers = regPN "Chalmers" neutrum ;
</pre> </pre>
<!-- NEW -->
<h2>Syntax editor as library browser</h2>
You can run the syntax editor on <tt>LangX</tt> to
find resource API functions through context-sensitive menus.
For instance, the shell command
<pre>
jgf LangEng.gf LangFre.gf
</pre>
opens the editor with English and French views. The
<a href="http://www.cs.chalmers.se/%7Eaarne/GF2.0/doc/javaGUImanual/javaGUImanual.htm">
Editor User Manual</a> gives more information on the use of the editor.
<p>
A restriction of the editor is that it does not give access to
<tt>ParadigmsX</tt> modules. An IDE environment extending the editor
to a grammar programming tool is work in progress.
<!-- NEW --> <!-- NEW -->
<h2>Example application: a small translation system</h2> <h2>Example application: a small translation system</h2>
You can say things like the following: In this system, you can express questions and answers of
the following forms:
<pre> <pre>
who chases mice ? Who chases mice ?
whom does the lion chase ? Whom does the lion chase ?
the dog chases cats The dog chases cats.
</pre> </pre>
Source modules: We build the abstract syntax in two phases:
<ul>
<li> <a href=example/Questions.gf>Questions</a> defines question and
answer forms independently of domain
<li> <a href=example/Animals.gf>Animals</a> defines a lexicon with
animals and things that animals do.
</ul>
<p> <p>
Abstract syntax: The concrete syntax of English is built in three phases:
<a href=example/Questions.gf>Questions</a>, <ul>
<a href=example/Animals.gf>Animals</a> <li> <a href="example/QuestionsI.gf">QuestionsI</a> is a parametrized module
using the API module <tt>Resource</tt>.
<li> <a href="example/QuestionsEng.gf">QuestionsEng</a> is an instantiation
of the API with <tt>ResourceEng</tt>.
<li> <a href="example/AnimalsEng.gf">AnimalsEng</a> is a concrete syntax
of <tt>Animals</tt> using <tt>ParadigmsEng</tt> and <tt>VerbsEng</tt>.
</ul>
<p> <p>
Concrete syntax of questions parametrized on the resource API: The concrete syntax of Swedish is built upon <tt>QuestionsI</tt>
<a href=example/QuestionsI.gf>QuestionsI</a> in a similar way, with the modules
<a href=example/QuestionsSwe.gf>QuestionsSwe</a> and.
<a href=example/AnimalsSwe.gf>AnimalsSwe</a>.
<p> <p>
English concrete syntax: The concrete syntax of French consists similarly of the modules
<a href=example/QuestionsEng.gf>QuestionsEng</a>, <a href=example/QuestionsFre.gf>QuestionsFre</a> and
<a href=example/AnimalsEng.gf>AnimalsEng</a> <a href=example/AnimalsFre.gf>AnimalsFre</a>.
<p>
French concrete syntax:
<a href=example/QuestionsFre.gf>QuestionsFre</a>,
<a href=example/AnimalsFre.gf>AnimalsFre</a>
<p>
Swedish concrete syntax:
<a href=example/QuestionsSwe.gf>QuestionsSwe</a>,
<a href=example/AnimalsSwe.gf>AnimalsSwe</a>
@@ -635,27 +689,13 @@ and you get an end-user grammar <tt>animals.gfcm</tt>.
You can also write the commands in a <tt>gfs</tt> (<b>GF script</b>) You can also write the commands in a <tt>gfs</tt> (<b>GF script</b>)
file, say file, say
<a href=mkAnimals.gfc><tt>mkAnimals.gfs</tt></a>, <a href="example/mkAnimals.gfs"><tt>mkAnimals.gfs</tt></a>,
and then call GF with and then call GF with
<pre> <pre>
gf &lt;mkAnimals.gfs gf &lt;mkAnimals.gfs
</pre> </pre>
<!-- NEW -->
<h2>Further simplifications of the application grammar</h2>
Step 1: use a simplified access to present-tense sentences,
<tt>SentenceX</tt> (to be written...)
<p>
Step 2: factor out the categories and purely combinational
rules into an <tt>incomplete</tt> module (to be shown... but
this does not work for French, which uses different structures:
e.g. <i>Qui aime les lions ?</i> with a definite phrase
where English has <i>Who loves lions?</i>
<!-- NEW --> <!-- NEW -->
<h2>Implementation details: the structure of low-level files</h2> <h2>Implementation details: the structure of low-level files</h2>
@@ -678,6 +718,7 @@ In two language families:
</center> </center>
<!-- NEW --> <!-- NEW -->
<h2>Current status</h2> <h2>Current status</h2>
@@ -701,6 +742,7 @@ X = implemented (few exceptions may occur)
- = not implemented - = not implemented
<!-- NEW --> <!-- NEW -->
<h2>Known bugs and limitations</h2> <h2>Known bugs and limitations</h2>
@@ -737,10 +779,11 @@ some verbs in Basic should be reflexive
Swedish Swedish
<!-- NEW --> <!-- NEW -->
<h2>Obtaining it</h2> <h2>Obtaining it</h2>
Get the grammar package atDownload from Get the grammar package from
<a href="http://sourceforge.net/project/showfiles.php?group_id=132285"> <a href="http://sourceforge.net/project/showfiles.php?group_id=132285">
GF Download Page</a>. The current libraries are in GF Download Page</a>. The current libraries are in
<tt>lib/resource</tt>. Version 0.6 is in <tt>lib/resource</tt>. Version 0.6 is in

View File

@@ -6,7 +6,7 @@ concrete StructuralFre of Structural =
lin lin
UseNumeral n = {s = \\g => n.s !g ; n = n.n} ; UseNumeral n = {s = \\g => n.s !g ; n = n.n ; isNo = False} ;
above_Prep = {s = ["au dessus"] ; c = genitive} ; above_Prep = {s = ["au dessus"] ; c = genitive} ;
after_Prep = justPrep "après" ; after_Prep = justPrep "après" ;

View File

@@ -5,7 +5,7 @@ concrete StructuralIta of Structural = CategoriesIta, NumeralsIta **
lin lin
UseNumeral n = {s = \\g => n.s !g ; n = n.n} ; UseNumeral n = {s = \\g => n.s !g ; n = n.n ; isNo = False} ;
above_Prep = justPrep "sopra" ; above_Prep = justPrep "sopra" ;
after_Prep = justPrep "dopo" ; after_Prep = justPrep "dopo" ;

View File

@@ -40,7 +40,7 @@ lincat
-- = CommNoun ** {s2 : Preposition ; c : CaseA} ; -- = CommNoun ** {s2 : Preposition ; c : CaseA} ;
N3 = Function ** {s3 : Preposition ; c3 : CaseA} ; N3 = Function ** {s3 : Preposition ; c3 : CaseA} ;
Prep = {s : Preposition ; c : CaseA} ; Prep = {s : Preposition ; c : CaseA} ;
Num = {s : Gender => Str ; n : Number} ; Num = {s : Gender => Str ; n : Number ; isNo : Bool} ;
A = Adjective ; A = Adjective ;
-- = {s : AForm => Str ; p : Bool} ; -- = {s : AForm => Str ; p : Bool} ;

View File

@@ -35,7 +35,7 @@ lin
ModGenOne = npGenDet singular ; ModGenOne = npGenDet singular ;
ModGenNum = npGenDetNum ; ModGenNum = npGenDetNum ;
UseInt i = {s = \\_ => i.s ; n = Pl} ; ---- n UseInt i = {s = \\_ => i.s ; n = Pl ; isNo = False} ; ---- n
NoNum = noNum ; NoNum = noNum ;
UseA = adj2adjPhrase ; UseA = adj2adjPhrase ;

View File

@@ -60,9 +60,10 @@ oper
pronNounPhrase : Pronoun -> NounPhrase = \pro -> pro ; pronNounPhrase : Pronoun -> NounPhrase = \pro -> pro ;
-- Many determiners can be modified with numerals, which may be inflected in -- Many determiners can be modified with numerals, which may be inflected in
-- gender. -- gender. The label $isNo$ is a hack used to force $des$ for plural
-- indefinite with $noNum$.
Numeral : Type = {s : Gender => Str ; n : Number} ; Numeral : Type = {s : Gender => Str ; n : Number ; isNo : Bool} ;
pronWithNum : Pronoun -> Numeral -> Pronoun = \nous,deux -> pronWithNum : Pronoun -> Numeral -> Pronoun = \nous,deux ->
{s = \\c => nous.s ! c ++ deux.s ! pgen2gen nous.g ; {s = \\c => nous.s ! c ++ deux.s ! pgen2gen nous.g ;
@@ -72,7 +73,7 @@ oper
c = nous.c c = nous.c
} ; } ;
noNum : Numeral = {s = \\_ => [] ; n = Pl} ; noNum : Numeral = {s = \\_ => [] ; n = Pl ; isNo = True} ;
-- The existence construction "il y a", "c'è / ci sono" is defined separately, -- The existence construction "il y a", "c'è / ci sono" is defined separately,
-- and ad hoc, in each language. -- and ad hoc, in each language.
@@ -138,7 +139,11 @@ oper
indefNounPhraseNum : Numeral -> CommNounPhrase -> NounPhrase = \nu,mec -> indefNounPhraseNum : Numeral -> CommNounPhrase -> NounPhrase = \nu,mec ->
normalNounPhrase normalNounPhrase
(\\c => prepCase c ++ nu.s ! mec.g ++ mec.s ! nu.n) (\\c => case nu.isNo of {
True => artIndef mec.g Pl c ++ mec.s ! Pl ;
_ => prepCase c ++ nu.s ! mec.g ++ mec.s ! nu.n
}
)
mec.g mec.g
nu.n ; nu.n ;

View File

@@ -6,7 +6,7 @@ concrete StructuralSpa of Structural = CategoriesSpa, NumeralsSpa **
lin lin
UseNumeral n = {s = \\g => n.s !g ; n = n.n} ; UseNumeral n = {s = \\g => n.s !g ; n = n.n ; isNo = False} ;
above_Prep = justPrep "sobre" ; above_Prep = justPrep "sobre" ;
after_Prep = {s = "después" ; c = genitive} ; after_Prep = {s = "después" ; c = genitive} ;