From 7e9ce03dce2dad01d7d835b560594d9fa0b2df55 Mon Sep 17 00:00:00 2001 From: aarne Date: Sun, 22 May 2005 18:43:00 +0000 Subject: [PATCH] improved resource doc --- resource/doc/Makefile | 2 +- resource/doc/example/Animals.gf | 2 +- resource/doc/example/AnimalsEng.gf | 2 +- resource/doc/example/AnimalsFre.gf | 2 +- resource/doc/example/AnimalsSwe.gf | 2 +- resource/doc/example/QuestionsI.gf | 2 +- .../example/{mkAnimals.gfcm => mkAnimals.gfs} | 0 resource/doc/gf-resource.html | 163 +++++++++++------- resource/french/StructuralFre.gf | 2 +- resource/italian/StructuralIta.gf | 2 +- resource/romance/CategoriesRomance.gf | 2 +- resource/romance/RulesRomance.gf | 2 +- resource/romance/SyntaxRomance.gf | 13 +- resource/spanish/StructuralSpa.gf | 2 +- 14 files changed, 123 insertions(+), 75 deletions(-) rename resource/doc/example/{mkAnimals.gfcm => mkAnimals.gfs} (100%) diff --git a/resource/doc/Makefile b/resource/doc/Makefile index 8e3c79697..af91c3a1b 100644 --- a/resource/doc/Makefile +++ b/resource/doc/Makefile @@ -31,7 +31,7 @@ gfdoc: gfdoc ../italian/BeschIta.gf ; mv ../italian/BeschIta.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 . gifs: api lang scand low diff --git a/resource/doc/example/Animals.gf b/resource/doc/example/Animals.gf index e6d084243..17e64c7b1 100644 --- a/resource/doc/example/Animals.gf +++ b/resource/doc/example/Animals.gf @@ -5,6 +5,6 @@ abstract Animals = Questions ** { fun -- a lexicon of animals and actions among them Dog, Cat, Mouse, Lion, Zebra : Entity ; - Chase, Eat, Like : Action ; + Chase, Eat, See : Action ; } diff --git a/resource/doc/example/AnimalsEng.gf b/resource/doc/example/AnimalsEng.gf index a25a95ae2..e8a9c474a 100644 --- a/resource/doc/example/AnimalsEng.gf +++ b/resource/doc/example/AnimalsEng.gf @@ -11,5 +11,5 @@ concrete AnimalsEng of Animals = QuestionsEng ** Zebra = regN "zebra" ; Chase = dirV2 (regV "chase") ; Eat = dirV2 eat_V ; - Like = dirV2 (regV "like") ; + See = dirV2 see_V ; } diff --git a/resource/doc/example/AnimalsFre.gf b/resource/doc/example/AnimalsFre.gf index 635f47208..d35de8243 100644 --- a/resource/doc/example/AnimalsFre.gf +++ b/resource/doc/example/AnimalsFre.gf @@ -11,5 +11,5 @@ concrete AnimalsFre of Animals = QuestionsFre ** Zebra = regN "zèbre" masculine ; Chase = dirV2 (regV "chasser") ; Eat = dirV2 (regV "manger") ; - Like = dirV2 (regV "aimer") ; + See = voir_V2 ; } diff --git a/resource/doc/example/AnimalsSwe.gf b/resource/doc/example/AnimalsSwe.gf index f7aaa0cd6..acd839317 100644 --- a/resource/doc/example/AnimalsSwe.gf +++ b/resource/doc/example/AnimalsSwe.gf @@ -11,5 +11,5 @@ concrete AnimalsSwe of Animals = QuestionsSwe ** Zebra = regN "zebra" utrum ; Chase = dirV2 (regV "jaga") ; Eat = dirV2 äta_V ; - Like = mkV2 (mk2V "tycka" "tycker") "om" ; + See = dirV2 se_V ; } diff --git a/resource/doc/example/QuestionsI.gf b/resource/doc/example/QuestionsI.gf index 7dda8ca8c..9915cc8d5 100644 --- a/resource/doc/example/QuestionsI.gf +++ b/resource/doc/example/QuestionsI.gf @@ -1,6 +1,6 @@ --# -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 { lincat diff --git a/resource/doc/example/mkAnimals.gfcm b/resource/doc/example/mkAnimals.gfs similarity index 100% rename from resource/doc/example/mkAnimals.gfcm rename to resource/doc/example/mkAnimals.gfs diff --git a/resource/doc/gf-resource.html b/resource/doc/gf-resource.html index 902cc5432..795f333f6 100644 --- a/resource/doc/gf-resource.html +++ b/resource/doc/gf-resource.html @@ -9,9 +9,11 @@

-Second Version, Gothenburg, 1 March 2005 +Third Version, 22 May 2005
-First Draft, Gothenburg, 7 February 2005 +Second Version, 1 March 2005 +
+First Draft, 7 February 2005

@@ -31,7 +33,8 @@ A grammar formalism based on functional programming and type theory.

-Designed to be nice for ordinary programmers to use. +Designed to be nice for ordinary programmers to use: by this +we mean programmers without training in linguistics.

@@ -47,6 +50,7 @@ Thus not primarily another theoretical framework for linguists. +

Multilingual grammars

@@ -90,6 +94,7 @@ wenn 2 ist gerade, dann 2+2 ist gerade
om 2 är jämnt, 2+2 är jämnt
+

Solving the difficulties

@@ -197,17 +202,15 @@ Where do we get the data from?
  • automatic extraction or hand-writing?
  • reuse of existing resources? - -

    - -Extra constraint: we want open-source free software. - +
    +Extra constraint: we want open-source free software and +hence cannot use existing proprietary resources. -

    The scope of the resource grammar library

    +

    The scope of a resource grammar library for a language

    All morphological paradigms @@ -228,6 +231,7 @@ Currently,
    +

    Success criteria

    @@ -251,24 +255,33 @@ families, using the module system of GF.

    These are not our success criteria

    -Language coverage: you can parse all expressions. Example: +Language coverage: to be able to parse all expressions. +
    +Example: the French passé simple tense, although covered by the -morhology, is not used in the language-independent API, but -only the passé composé is. +morphology, is not used in the language-independent API, but +only the passé composé is. However, an application +accessing the French-specific (or Romance-specific) +modules can use the passé simple.

    -Semantic correctness +Semantic correctness: only to produce meaningful expressions. +
    +Example: the following sentences can be generated

       colourless green ideas sleep furiously
     
       the time is seventy past forty-two
     
    +However, an applicatio grammar can use a domain-specific +semantics to guarantee semantic well-formedness.

    (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 (Dan etc) are used in grammar module names +

    Library structure 1: language-independent API

    @@ -351,6 +365,7 @@ conjunctions, pronouns), e.g. and_Conj : Conj ; +

    Library structure 2: language-dependent modules

    @@ -477,6 +492,8 @@ Alternative views on sentence formation: Spanish paradigms
    +example use of Spanish paradigms +
    Spanish verb conjugations

    @@ -491,7 +508,7 @@ Alternative views on sentence formation:

    Use as top-level grammar: testing

    -Import a set of $LangX$ grammars: +Import a set of LangX grammars:
       i english/LangEng.gf
       i swedish/LangSwe.gf
    @@ -532,11 +549,14 @@ Import directly by open:
     
       concrete AppNor of App = open LangNor, ParadigmsNor in {...}
     
    -No more dummy reuse modules and bulky .gfr files! +(Note for the users of GF 2.1 and older: +the dummy reuse modules and their bulky .gfr versions +are no longer needed!)

    -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

       Predef.toStr : (L : Type) -> L -> Str ; 
     
    @@ -548,65 +568,99 @@ If you need to convert resource category records to/from strings, use +

    Use as library through parser

    -Use the parser when developing a resource. +You can use the parser with a LangX grammar +when developing a resource. + +

    + +Using the -v option shows if the parser fails because +of unknown words.

       > p -cat=S -v "jag ska åka till Chalmers"
       unknown tokens [TS "åka",TS "Chalmers"]
    -
    +
    +Then try to select words that LangX recognizes: +
       > p -cat=S "jag ska gå till Danmark"
       UseCl (PosTP TFuture ASimul)
         (AdvCl (SPredV i_NP go_V)
         (AdvPP (PrepNP to_Prep (UsePN (PNCountry Denmark)))))
     
    -Extend vocabulary at need. +Use these API structures and extend vocabulary to match your need.
       åka_V = lexV "åker" ; 
       Chalmers = regPN "Chalmers" neutrum ;
     
    + +

    Syntax editor as library browser

    + +You can run the syntax editor on LangX to +find resource API functions through context-sensitive menus. +For instance, the shell command +
    +  jgf LangEng.gf LangFre.gf
    +
    +opens the editor with English and French views. The + +Editor User Manual gives more information on the use of the editor. + +

    + +A restriction of the editor is that it does not give access to +ParadigmsX modules. An IDE environment extending the editor +to a grammar programming tool is work in progress. + + +

    Example application: a small translation system

    -You can say things like the following: +In this system, you can express questions and answers of +the following forms:
    -  who chases mice ?
    -  whom does the lion chase ?
    -  the dog chases cats
    +  Who chases mice ?
    +  Whom does the lion chase ?
    +  The dog chases cats.
     
    -Source modules: +We build the abstract syntax in two phases: +
      +
    • Questions defines question and + answer forms independently of domain +
    • Animals defines a lexicon with + animals and things that animals do. +

    -Abstract syntax: -Questions, -Animals +The concrete syntax of English is built in three phases: +

      +
    • QuestionsI is a parametrized module + using the API module Resource. +
    • QuestionsEng is an instantiation + of the API with ResourceEng. +
    • AnimalsEng is a concrete syntax + of Animals using ParadigmsEng and VerbsEng. +

    -Concrete syntax of questions parametrized on the resource API: -QuestionsI +The concrete syntax of Swedish is built upon QuestionsI +in a similar way, with the modules +QuestionsSwe and. +AnimalsSwe.

    -English concrete syntax: -QuestionsEng, -AnimalsEng +The concrete syntax of French consists similarly of the modules +QuestionsFre and +AnimalsFre. -

    - -French concrete syntax: -QuestionsFre, -AnimalsFre - -

    - -Swedish concrete syntax: -QuestionsSwe, -AnimalsSwe @@ -635,27 +689,13 @@ and you get an end-user grammar animals.gfcm. You can also write the commands in a gfs (GF script) file, say -mkAnimals.gfs, +mkAnimals.gfs, and then call GF with

       gf <mkAnimals.gfs
     
    - -

    Further simplifications of the application grammar

    - -Step 1: use a simplified access to present-tense sentences, -SentenceX (to be written...) - -

    - -Step 2: factor out the categories and purely combinational -rules into an incomplete module (to be shown... but -this does not work for French, which uses different structures: -e.g. Qui aime les lions ? with a definite phrase -where English has Who loves lions? -

    Implementation details: the structure of low-level files

    @@ -678,6 +718,7 @@ In two language families: +

    Current status

    @@ -701,6 +742,7 @@ X = implemented (few exceptions may occur) - = not implemented +

    Known bugs and limitations

    @@ -737,10 +779,11 @@ some verbs in Basic should be reflexive Swedish +

    Obtaining it

    -Get the grammar package atDownload from +Get the grammar package from GF Download Page. The current libraries are in lib/resource. Version 0.6 is in diff --git a/resource/french/StructuralFre.gf b/resource/french/StructuralFre.gf index 2665b3607..4016d7c03 100644 --- a/resource/french/StructuralFre.gf +++ b/resource/french/StructuralFre.gf @@ -6,7 +6,7 @@ concrete StructuralFre of Structural = 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} ; after_Prep = justPrep "après" ; diff --git a/resource/italian/StructuralIta.gf b/resource/italian/StructuralIta.gf index c37abbf21..1eec02262 100644 --- a/resource/italian/StructuralIta.gf +++ b/resource/italian/StructuralIta.gf @@ -5,7 +5,7 @@ concrete StructuralIta of Structural = CategoriesIta, NumeralsIta ** 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" ; after_Prep = justPrep "dopo" ; diff --git a/resource/romance/CategoriesRomance.gf b/resource/romance/CategoriesRomance.gf index abeb751d2..c5b063091 100644 --- a/resource/romance/CategoriesRomance.gf +++ b/resource/romance/CategoriesRomance.gf @@ -40,7 +40,7 @@ lincat -- = CommNoun ** {s2 : Preposition ; c : CaseA} ; N3 = Function ** {s3 : Preposition ; c3 : CaseA} ; Prep = {s : Preposition ; c : CaseA} ; - Num = {s : Gender => Str ; n : Number} ; + Num = {s : Gender => Str ; n : Number ; isNo : Bool} ; A = Adjective ; -- = {s : AForm => Str ; p : Bool} ; diff --git a/resource/romance/RulesRomance.gf b/resource/romance/RulesRomance.gf index 19abcc3a9..886cf4b20 100644 --- a/resource/romance/RulesRomance.gf +++ b/resource/romance/RulesRomance.gf @@ -35,7 +35,7 @@ lin ModGenOne = npGenDet singular ; ModGenNum = npGenDetNum ; - UseInt i = {s = \\_ => i.s ; n = Pl} ; ---- n + UseInt i = {s = \\_ => i.s ; n = Pl ; isNo = False} ; ---- n NoNum = noNum ; UseA = adj2adjPhrase ; diff --git a/resource/romance/SyntaxRomance.gf b/resource/romance/SyntaxRomance.gf index 6e4778264..2b87e8cf7 100644 --- a/resource/romance/SyntaxRomance.gf +++ b/resource/romance/SyntaxRomance.gf @@ -60,9 +60,10 @@ oper pronNounPhrase : Pronoun -> NounPhrase = \pro -> pro ; -- 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 -> {s = \\c => nous.s ! c ++ deux.s ! pgen2gen nous.g ; @@ -72,7 +73,7 @@ oper 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, -- and ad hoc, in each language. @@ -138,7 +139,11 @@ oper indefNounPhraseNum : Numeral -> CommNounPhrase -> NounPhrase = \nu,mec -> 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 nu.n ; diff --git a/resource/spanish/StructuralSpa.gf b/resource/spanish/StructuralSpa.gf index 0dee0ec74..afd6b0e94 100644 --- a/resource/spanish/StructuralSpa.gf +++ b/resource/spanish/StructuralSpa.gf @@ -6,7 +6,7 @@ concrete StructuralSpa of Structural = CategoriesSpa, NumeralsSpa ** 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" ; after_Prep = {s = "después" ; c = genitive} ;